Use PHP5.5 class name resolution operator

This commit is contained in:
Marco Hermo 2017-04-25 21:11:29 +12:00
parent d13601f827
commit e422ad48c9
10 changed files with 25 additions and 16 deletions

View File

@ -4,6 +4,7 @@ namespace SilverStripe\FullTextSearch\Solr;
use SilverStripe\Control\Director;
use SilverStripe\Core\Object;
use SilverStripe\FullTextSearch\Search\FullTextSearch;
use SilverStripe\FullTextSearch\Solr\SolrIndex;
class Solr
{
@ -137,7 +138,7 @@ class Solr
public static function get_indexes()
{
return FullTextSearch::get_indexes('SilverStripe\FullTextSearch\Solr\SolrIndex');
return FullTextSearch::get_indexes(SolrIndex::class);
}
/**
@ -157,4 +158,4 @@ class Solr
$included = true;
}
}
}
}

View File

@ -2,6 +2,8 @@
namespace SilverStripe\FullTextSearch\Solr\Reindex\Jobs;
use Monolog\Logger;
use Psr\Log\LoggerInterface;
use SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory;
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler;
if (!interface_exists('QueuedJob')) {
return;
@ -44,7 +46,7 @@ abstract class SolrReindexQueuedJobBase implements QueuedJob
*/
protected function getLoggerFactory()
{
return Injector::inst()->get('SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory');
return Injector::inst()->get(SearchLogFactory::class);
}
/**
@ -103,7 +105,7 @@ abstract class SolrReindexQueuedJobBase implements QueuedJob
*/
protected function getHandler()
{
return Injector::inst()->get('SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler');
return Injector::inst()->get(SolrReindexHandler::class);
}
public function jobFinished()

View File

@ -3,5 +3,5 @@ namespace SilverStripe\FullTextSearch\Solr\Services;
class Solr3Service extends SolrService
{
private static $core_class = 'SilverStripe\FullTextSearch\Solr\Services\Solr3Service';
private static $core_class = Solr3Service::class;
}

View File

@ -3,5 +3,5 @@ namespace SilverStripe\FullTextSearch\Solr\Services;
class Solr4Service extends SolrService
{
private static $core_class = 'SilverStripe\FullTextSearch\Solr\Services\Solr4Service';
private static $core_class = Solr4Service::class;
}

View File

@ -2,6 +2,7 @@
namespace SilverStripe\FullTextSearch\Solr\Services;
use SilverStripe\Core\Config\Config;
use SilverStripe\FullTextSearch\Solr\Solr;
use SilverStripe\FullTextSearch\Solr\Services\SolrService_Core;
Solr::include_client_api();
/**
* The API for accessing the primary Solr installation, which includes both SolrService_Core,
@ -10,7 +11,7 @@ Solr::include_client_api();
*/
class SolrService extends SolrService_Core
{
private static $core_class = 'SilverStripe\FullTextSearch\Solr\Services\SolrService_Core';
private static $core_class = SolrService_Core::class;
/**
* Handle encoding the GET parameters and making the HTTP call to execute a core command

View File

@ -25,7 +25,7 @@ class Solr_BuildTask extends BuildTask
*/
public function getLogger()
{
return Injector::inst()->get('Psr\Log\LoggerInterface');
return Injector::inst()->get(LoggerInterface::class);
}
/**
@ -43,7 +43,7 @@ class Solr_BuildTask extends BuildTask
*/
protected function getLoggerFactory()
{
return Injector::inst()->get('SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory');
return Injector::inst()->get(SearchLogFactory::class);
}
/**

View File

@ -5,6 +5,7 @@ use SilverStripe\Core\ClassInfo;
use SilverStripe\FullTextSearch\Solr\Solr;
use SilverStripe\FullTextSearch\Solr\Stores\SolrConfigStore_File;
use SilverStripe\FullTextSearch\Solr\Stores\SolrConfigStore_WebDAV;
use SilverStripe\FullTextSearch\Solr\Stores\SolrConfigStore;
class Solr_Configure extends Solr_BuildTask
{
@ -78,10 +79,10 @@ class Solr_Configure extends Solr_BuildTask
return new SolrConfigStore_File($indexstore);
} elseif ($mode == 'webdav') {
return new SolrConfigStore_WebDAV($indexstore);
} elseif (ClassInfo::exists($mode) && ClassInfo::classImplements($mode, 'SilverStripe\FullTextSearch\Solr\Stores\SolrConfigStore')) {
} elseif (ClassInfo::exists($mode) && ClassInfo::classImplements($mode, SolrConfigStore::class)) {
return new $mode($indexstore);
} else {
user_error('Unknown Solr index mode '.$indexstore['mode'], E_USER_ERROR);
}
}
}
}

View File

@ -6,6 +6,8 @@ use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
use SilverStripe\ORM\DataList;
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler;
use SilverStripe\FullTextSearch\Solr\SolrIndex;
/**
* Task used for both initiating a new reindex, as well as for processing incremental batches
@ -41,7 +43,7 @@ class Solr_Reindex extends Solr_BuildTask
*/
protected function getHandler()
{
return Injector::inst()->get('SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler');
return Injector::inst()->get(SolrReindexHandler::class);
}
/**
@ -70,7 +72,7 @@ class Solr_Reindex extends Solr_BuildTask
// this is for when index names do not match the class name (this can be done by overloading getIndexName() on
// indexes
if ($index && !ClassInfo::exists($index)) {
foreach(ClassInfo::subclassesFor('SilverStripe\FullTextSearch\Solr\SolrIndex') as $solrIndexClass) {
foreach(ClassInfo::subclassesFor(SolrIndex::class) as $solrIndexClass) {
$reflection = new ReflectionClass($solrIndexClass);
//skip over abstract classes
if (!$reflection->isInstantiable()) {

View File

@ -4,6 +4,7 @@ use SilverStripe\Dev\SapphireTest;
use SilverStripe\FullTextSearch\Search\FullTextSearch;
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Variant;
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler;
/**
* Additional tests of solr reindexing processes when run with queuedjobs
@ -106,7 +107,7 @@ class SolrReindexQueuedTest extends SapphireTest
*/
protected function getHandler()
{
return Injector::inst()->get('SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler');
return Injector::inst()->get(SolrReindexHandler::class);
}
/**
@ -158,7 +159,7 @@ class SolrReindexQueuedTest extends SapphireTest
$this->assertEquals(3, $logger->countMessages(' of SolrReindexTest_Item in {"SolrReindexTest_Variant":"1"}'));
$this->assertEquals(1, $logger->countMessages('Completed init of reindex'));
// Test that invalid classes are removed
$this->assertNotEmpty($logger->getMessages('Clearing obsolete classes from SolrReindexTest_Index'));
Phockito::verify($this->service, 1)

View File

@ -4,6 +4,7 @@ use SilverStripe\Dev\SapphireTest;
use SilverStripe\FullTextSearch\Search\FullTextSearch;
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Variant;
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler;
if (class_exists('Phockito')) {
Phockito::include_hamcrest(false);
@ -102,7 +103,7 @@ class SolrReindexTest extends SapphireTest
*/
protected function getHandler()
{
return Injector::inst()->get('SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler');
return Injector::inst()->get(SolrReindexHandler::class);
}
/**