Commit 284970df authored by Stefan Neufeind's avatar Stefan Neufeind Committed by Markus Klein
Browse files

[TASK] Use name-resolution instead of strings where possible: 3

(part for EXT:extbase)

Use name-resolution with ...::class instead of strings where
possible.
(needs PHP 5.5, which is meanwhile required for master)

Change-set Iedbb896607adddce2b23ab67f990fa2296c0d1bb
first introduced usage of ::class in master. We now add it
in various more places.

Change-Id: I7ead29b6dd71240c4a05a4bf9b1c501e6a513019
Resolves: #63477
Releases: master
Reviewed-on: http://review.typo3.org/34856


Reviewed-by: default avatarFrank Nägler <typo3@naegler.net>
Tested-by: default avatarFrank Nägler <typo3@naegler.net>
Reviewed-by: default avatarMarkus Klein <klein.t3@reelworx.at>
Tested-by: default avatarMarkus Klein <klein.t3@reelworx.at>
parent 03ba4186
......@@ -191,8 +191,8 @@ class BackendConfigurationManager extends \TYPO3\CMS\Extbase\Configuration\Abstr
protected function getContextSpecificFrameworkConfiguration(array $frameworkConfiguration) {
if (!isset($frameworkConfiguration['mvc']['requestHandlers'])) {
$frameworkConfiguration['mvc']['requestHandlers'] = array(
'TYPO3\\CMS\\Extbase\\Mvc\\Web\\FrontendRequestHandler' => 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\FrontendRequestHandler',
'TYPO3\\CMS\\Extbase\\Mvc\\Web\\BackendRequestHandler' => 'TYPO3\\CMS\\Extbase\\Mvc\\Web\\BackendRequestHandler'
\TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler::class => \TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler::class,
\TYPO3\CMS\Extbase\Mvc\Web\BackendRequestHandler::class => \TYPO3\CMS\Extbase\Mvc\Web\BackendRequestHandler::class
);
}
return $frameworkConfiguration;
......
......@@ -58,7 +58,7 @@ class RequestBuilder implements \TYPO3\CMS\Core\SingletonInterface {
public function build($commandLine = '', $callingScript = './typo3/cli_dispatch.phpsh extbase') {
$request = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Cli\Request::class);
$request->setCallingScript($callingScript);
$request->setControllerObjectName('TYPO3\\CMS\\Extbase\\Command\\HelpCommandController');
$request->setControllerObjectName(\TYPO3\CMS\Extbase\Command\HelpCommandController::class);
$rawCommandLineArguments = is_array($commandLine) ? $commandLine : explode(' ', $commandLine);
if (count($rawCommandLineArguments) === 0) {
$request->setControllerCommandName('helpStub');
......
......@@ -88,7 +88,7 @@ abstract class AbstractController implements ControllerInterface {
*
* @var array
*/
protected $supportedRequestTypes = array('TYPO3\\CMS\\Extbase\\Mvc\\Request');
protected $supportedRequestTypes = array(\TYPO3\CMS\Extbase\Mvc\Request::class);
/**
* @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
......
......@@ -71,7 +71,7 @@ class ActionController extends AbstractController {
* @var string
* @api
*/
protected $defaultViewObjectName = 'TYPO3\\CMS\\Fluid\\View\\TemplateView';
protected $defaultViewObjectName = \TYPO3\CMS\Fluid\View\TemplateView::class;
/**
* Name of the action method
......
......@@ -168,7 +168,7 @@ class CommandController implements CommandControllerInterface {
} elseif ($argument->isRequired()) {
$commandArgumentDefinition = $this->objectManager->get(CommandArgumentDefinition::class, $argumentName, TRUE, NULL);
$exception = new \TYPO3\CMS\Extbase\Mvc\Exception\CommandException('Required argument "' . $commandArgumentDefinition->getDashedName() . '" is not set.', 1306755520);
$this->forward('error', 'TYPO3\\CMS\\Extbase\\Command\\HelpCommandController', array('exception' => $exception));
$this->forward('error', \TYPO3\CMS\Extbase\Command\HelpCommandController::class, array('exception' => $exception));
}
}
}
......
......@@ -37,7 +37,7 @@ class MvcPropertyMappingConfiguration extends \TYPO3\CMS\Extbase\Property\Proper
* @api
*/
public function allowCreationForSubProperty($propertyPath) {
$this->forProperty($propertyPath)->setTypeConverterOption('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, TRUE);
$this->forProperty($propertyPath)->setTypeConverterOption(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, TRUE);
}
/**
......@@ -48,7 +48,7 @@ class MvcPropertyMappingConfiguration extends \TYPO3\CMS\Extbase\Property\Proper
* @api
*/
public function allowModificationForSubProperty($propertyPath) {
$this->forProperty($propertyPath)->setTypeConverterOption('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, TRUE);
$this->forProperty($propertyPath)->setTypeConverterOption(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, TRUE);
}
/**
......@@ -62,6 +62,6 @@ class MvcPropertyMappingConfiguration extends \TYPO3\CMS\Extbase\Property\Proper
* @api
*/
public function setTargetTypeForSubProperty($propertyPath, $targetType) {
$this->forProperty($propertyPath)->setTypeConverterOption('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_TARGET_TYPE, $targetType);
$this->forProperty($propertyPath)->setTypeConverterOption(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_TARGET_TYPE, $targetType);
}
}
......@@ -143,10 +143,10 @@ class MvcPropertyMappingConfigurationService implements \TYPO3\CMS\Core\Singleto
}
if (isset($propertyConfiguration['__identity'])) {
$propertyMappingConfiguration->setTypeConverterOption('TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, TRUE);
$propertyMappingConfiguration->setTypeConverterOption(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, TRUE);
unset($propertyConfiguration['__identity']);
} else {
$propertyMappingConfiguration->setTypeConverterOption('TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, TRUE);
$propertyMappingConfiguration->setTypeConverterOption(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, \TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, TRUE);
}
foreach ($propertyConfiguration as $innerKey => $innerValue) {
......
......@@ -146,7 +146,7 @@ class ClassInfoFactory {
* @return bool
*/
private function getIsSingleton($classname) {
return in_array('TYPO3\\CMS\\Core\\SingletonInterface', class_implements($classname));
return in_array(\TYPO3\CMS\Core\SingletonInterface::class, class_implements($classname));
}
/**
......
......@@ -134,13 +134,13 @@ class Container implements \TYPO3\CMS\Core\SingletonInterface {
*/
protected function getInstanceInternal($className, $givenConstructorArguments = array()) {
$className = $this->getImplementationClassName($className);
if ($className === 'TYPO3\\CMS\\Extbase\\Object\\Container\\Container') {
if ($className === \TYPO3\CMS\Extbase\Object\Container\Container::class) {
return $this;
}
if ($className === 'TYPO3\\CMS\\Core\\Cache\\CacheManager') {
if ($className === \TYPO3\CMS\Core\Cache\CacheManager::class) {
return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class);
}
if ($className === 'TYPO3\\CMS\\Core\\Package\\PackageManager') {
if ($className === \TYPO3\CMS\Core\Package\PackageManager::class) {
return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Package\PackageManager::class);
}
$className = \TYPO3\CMS\Core\Core\ClassLoader::getClassNameForAlias($className);
......@@ -187,7 +187,7 @@ class Container implements \TYPO3\CMS\Core\SingletonInterface {
}
$constructorArguments = $this->getConstructorArguments($className, $classInfo, $givenConstructorArguments);
array_unshift($constructorArguments, $className);
$instance = call_user_func_array(array('TYPO3\\CMS\\Core\\Utility\\GeneralUtility', 'makeInstance'), $constructorArguments);
$instance = call_user_func_array(array(\TYPO3\CMS\Core\Utility\GeneralUtility::class, 'makeInstance'), $constructorArguments);
if ($classIsSingleton) {
$this->singletonInstances[$className] = $instance;
}
......
......@@ -89,7 +89,7 @@ class ObjectManager implements ObjectManagerInterface {
array_shift($arguments);
if ($objectName === 'DateTime') {
array_unshift($arguments, $objectName);
$instance = call_user_func_array(array('TYPO3\\CMS\\Core\\Utility\\GeneralUtility', 'makeInstance'), $arguments);
$instance = call_user_func_array(array(\TYPO3\CMS\Core\Utility\GeneralUtility::class, 'makeInstance'), $arguments);
} else {
$instance = $this->objectContainer->getInstance($objectName, $arguments);
}
......
......@@ -111,7 +111,7 @@ class ObjectManagerException implements \TYPO3\CMS\Extbase\Object\ObjectManagerI
array_shift($arguments);
if ($objectName === 'DateTime') {
array_unshift($arguments, $objectName);
$instance = call_user_func_array(array('TYPO3\\CMS\\Core\\Utility\\GeneralUtility', 'makeInstance'), $arguments);
$instance = call_user_func_array(array(\TYPO3\CMS\Core\Utility\GeneralUtility::class, 'makeInstance'), $arguments);
} else {
$instance = $this->objectContainer->getInstance($objectName, $arguments);
}
......
......@@ -105,7 +105,7 @@ class DataMapFactory implements \TYPO3\CMS\Core\SingletonInterface {
}
$classHierarchy = array_merge(array($className), class_parents($className));
foreach ($classHierarchy as $currentClassName) {
if (in_array($currentClassName, array('TYPO3\\CMS\\Extbase\\DomainObject\\AbstractEntity', 'TYPO3\\CMS\\Extbase\\DomainObject\\AbstractValueObject'))) {
if (in_array($currentClassName, array(\TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class, \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject::class))) {
break;
}
$currentClassSettings = $frameworkConfiguration['persistence']['classes'][$currentClassName];
......
......@@ -155,7 +155,7 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface {
protected function createEmptyObject($className) {
// Note: The class_implements() function also invokes autoload to assure that the interfaces
// and the class are loaded. Would end up with __PHP_Incomplete_Class without it.
if (!in_array('TYPO3\\CMS\\Extbase\\DomainObject\\DomainObjectInterface', class_implements($className))) {
if (!in_array(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface::class, class_implements($className))) {
throw new CannotReconstituteObjectException('Cannot create empty instance of the class "' . $className
. '" because it does not implement the TYPO3\\CMS\\Extbase\\DomainObject\\DomainObjectInterface.', 1234386924);
}
......@@ -214,7 +214,7 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface {
// $propertyValue = $this->mapArray($row[$columnName]); // Not supported, yet!
break;
case 'SplObjectStorage':
case 'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage':
case \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class:
$propertyValue = $this->mapResultToPropertyValue(
$object,
$propertyName,
......@@ -288,7 +288,7 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface {
public function fetchRelated(DomainObjectInterface $parentObject, $propertyName, $fieldValue = '', $enableLazyLoading = TRUE) {
$propertyMetaData = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName);
if ($enableLazyLoading === TRUE && $propertyMetaData['lazy']) {
if ($propertyMetaData['type'] === 'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage') {
if ($propertyMetaData['type'] === \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class) {
$result = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage::class, $parentObject, $propertyName, $fieldValue);
} else {
if (empty($fieldValue)) {
......@@ -475,14 +475,14 @@ class DataMapper implements \TYPO3\CMS\Core\SingletonInterface {
$propertyValue = $result;
} else {
$propertyMetaData = $this->reflectionService->getClassSchema(get_class($parentObject))->getProperty($propertyName);
if (in_array($propertyMetaData['type'], array('array', 'ArrayObject', 'SplObjectStorage', 'TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage'), TRUE)) {
if (in_array($propertyMetaData['type'], array('array', 'ArrayObject', 'SplObjectStorage', \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class), TRUE)) {
$objects = array();
foreach ($result as $value) {
$objects[] = $value;
}
if ($propertyMetaData['type'] === 'ArrayObject') {
$propertyValue = new \ArrayObject($objects);
} elseif (in_array($propertyMetaData['type'], array('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage'), TRUE)) {
} elseif (in_array($propertyMetaData['type'], array(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class), TRUE)) {
$propertyValue = new Persistence\ObjectStorage();
foreach ($objects as $object) {
$propertyValue->attach($object);
......
......@@ -31,11 +31,11 @@ class PropertyMappingConfigurationBuilder implements \TYPO3\CMS\Core\SingletonIn
* @param string $type the implementation class name of the PropertyMappingConfiguration to instanciate; must be a subclass of \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration
* @return \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration
*/
public function build($type = 'TYPO3\\CMS\\Extbase\\Property\\PropertyMappingConfiguration') {
public function build($type = \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration::class) {
/** @var $configuration \TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration */
$configuration = new $type();
$configuration->setTypeConverterOptions('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\PersistentObjectConverter', array(
$configuration->setTypeConverterOptions(\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::class, array(
\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED => TRUE,
\TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED => TRUE
));
......
......@@ -39,7 +39,7 @@ class CoreTypeConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\Abstra
/**
* @var string
*/
protected $targetType = 'TYPO3\\CMS\\Core\\Type\\TypeInterface';
protected $targetType = \TYPO3\CMS\Core\Type\TypeInterface::class;
/**
* @var int
......
......@@ -31,7 +31,7 @@ namespace TYPO3\CMS\Extbase\Property\TypeConverter;
* $this->arguments['<argumentName>']
* ->getPropertyMappingConfiguration()
* ->forProperty('<propertyName>') // this line can be skipped in order to specify the format for all properties
* ->setTypeConverterOption('TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter', \TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, '<dateFormat>');
* ->setTypeConverterOption(\TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::class, \TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::CONFIGURATION_DATE_FORMAT, '<dateFormat>');
*
* If the source is of type array, it is possible to override the format in the source::
*
......@@ -192,7 +192,7 @@ class DateTimeConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\Abstra
if ($configuration === NULL) {
return self::DEFAULT_DATE_FORMAT;
}
$dateFormat = $configuration->getConfigurationValue('TYPO3\\CMS\\Extbase\\Property\\TypeConverter\\DateTimeConverter', self::CONFIGURATION_DATE_FORMAT);
$dateFormat = $configuration->getConfigurationValue(\TYPO3\CMS\Extbase\Property\TypeConverter\DateTimeConverter::class, self::CONFIGURATION_DATE_FORMAT);
if ($dateFormat === NULL) {
return self::DEFAULT_DATE_FORMAT;
} elseif ($dateFormat !== NULL && !is_string($dateFormat)) {
......
......@@ -28,12 +28,12 @@ class FileConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\AbstractFi
/**
* @var string
*/
protected $targetType = 'TYPO3\\CMS\\Extbase\\Domain\\Model\\File';
protected $targetType = \TYPO3\CMS\Extbase\Domain\Model\File::class;
/**
* @var string
*/
protected $expectedObjectType = 'TYPO3\\CMS\\Core\\Resource\\File';
protected $expectedObjectType = \TYPO3\CMS\Core\Resource\File::class;
/**
* @param string|int $source
......
......@@ -28,12 +28,12 @@ class FileReferenceConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\A
/**
* @var string
*/
protected $targetType = 'TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference';
protected $targetType = \TYPO3\CMS\Extbase\Domain\Model\FileReference::class;
/**
* @var string
*/
protected $expectedObjectType = 'TYPO3\\CMS\\Core\\Resource\\FileReference';
protected $expectedObjectType = \TYPO3\CMS\Core\Resource\FileReference::class;
/**
* @param int $source
......
......@@ -28,12 +28,12 @@ class FolderBasedFileCollectionConverter extends \TYPO3\CMS\Extbase\Property\Typ
/**
* @var string
*/
protected $targetType = 'TYPO3\\CMS\\Extbase\\Domain\\Model\\FolderBasedFileCollection';
protected $targetType = \TYPO3\CMS\Extbase\Domain\Model\FolderBasedFileCollection::class;
/**
* @var string
*/
protected $expectedObjectType = 'TYPO3\\CMS\\Core\\Resource\\Collection\\FolderBasedFileCollection';
protected $expectedObjectType = \TYPO3\CMS\Core\Resource\Collection\FolderBasedFileCollection::class;
/**
* @param int $source
......
......@@ -28,12 +28,12 @@ class FolderConverter extends \TYPO3\CMS\Extbase\Property\TypeConverter\Abstract
/**
* @var string
*/
protected $targetType = 'TYPO3\\CMS\\Extbase\\Domain\\Model\\Folder';
protected $targetType = \TYPO3\CMS\Extbase\Domain\Model\Folder::class;
/**
* @var string
*/
protected $expectedObjectType = 'TYPO3\\CMS\\Core\\Resource\\Folder';
protected $expectedObjectType = \TYPO3\CMS\Core\Resource\Folder::class;
/**
* @param string $source
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment