From d7ce554fed4bce46b2bb1a1d5c128adab81d0e1e Mon Sep 17 00:00:00 2001 From: Romain Canon <romain.hydrocanon@gmail.com> Date: Sat, 9 Sep 2017 18:13:26 +0200 Subject: [PATCH] [TASK] Replace `get_class($this)` calls with `static::class` Improves runtime performance of these calls by approximately 1/3. See https://belineperspectives.com/2017/03/13/get_classthis-vs-staticclass/ Resolves: #82416 Releases: master Change-Id: I7a069068ed66cbb4ebd83bdad56c621166bf8139 Reviewed-on: https://review.typo3.org/54069 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Simon Praetorius <simon@praetorius.me> Reviewed-by: Nathan Boiron <nathan.boiron@gmail.com> Reviewed-by: Matthias Vogel <typo3@kanti.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../backend/Classes/Module/AbstractModule.php | 2 +- .../Components/Buttons/AbstractButton.php | 2 +- .../Components/Buttons/Action/HelpButton.php | 2 +- .../Buttons/Action/ShortcutButton.php | 2 +- .../Components/Buttons/FullyRenderedButton.php | 2 +- .../backend/Classes/Tree/ExtDirectNode.php | 2 +- .../Classes/Tree/Pagetree/PagetreeNode.php | 2 +- typo3/sysext/backend/Classes/Tree/TreeNode.php | 4 ++-- .../Classes/Tree/TreeNodeCollection.php | 4 ++-- .../Tree/View/ElementBrowserFolderTreeView.php | 4 ++-- .../Classes/Tree/View/FolderTreeView.php | 2 +- .../Classes/Controller/AbstractController.php | 4 ++-- .../Classes/Cache/Backend/AbstractBackend.php | 2 +- .../Classes/Database/SoftReferenceIndex.php | 4 ++-- .../sysext/core/Classes/Html/RteHtmlParser.php | 2 +- .../Log/Processor/AbstractProcessor.php | 2 +- .../core/Classes/Log/Writer/AbstractWriter.php | 2 +- typo3/sysext/core/Classes/Package/Package.php | 2 +- .../core/Classes/Resource/ResourceStorage.php | 2 +- .../Session/Backend/DatabaseSessionBackend.php | 2 +- .../Classes/Type/Bitmask/JsConfirmation.php | 2 +- typo3/sysext/core/Classes/Type/Enumeration.php | 10 +++++----- .../core/Classes/Type/File/ImageInfo.php | 2 +- .../Unit/Resource/Driver/LocalDriverTest.php | 2 +- .../DomainObject/AbstractDomainObject.php | 2 +- .../Mvc/Controller/AbstractController.php | 4 ++-- .../Mvc/Controller/ActionController.php | 18 +++++++++--------- .../Mvc/Controller/CommandController.php | 8 ++++---- .../extbase/Classes/Persistence/Repository.php | 2 +- .../Property/PropertyMappingConfiguration.php | 2 +- .../Unit/Reflection/ReflectionServiceTest.php | 14 +++++++------- .../Utility/Importer/ExtensionListUtility.php | 2 +- .../Utility/Importer/MirrorListUtility.php | 2 +- .../ViewHelper/AbstractTagBasedViewHelper.php | 6 +++--- .../Core/ViewHelper/AbstractViewHelper.php | 8 ++++---- .../Core/Widget/AbstractWidgetViewHelper.php | 4 ++-- .../Widget/Controller/PaginateController.php | 2 +- .../ContentObject/ContentDataProcessorTest.php | 2 +- .../Menu/MenuContentObjectFactoryTest.php | 4 ++-- .../Classes/SystemEnvironment/Check.php | 2 +- .../install/Classes/Updates/AbstractUpdate.php | 4 ++-- .../scheduler/Classes/Task/AbstractTask.php | 10 +++++----- 42 files changed, 81 insertions(+), 81 deletions(-) diff --git a/typo3/sysext/backend/Classes/Module/AbstractModule.php b/typo3/sysext/backend/Classes/Module/AbstractModule.php index 1af0d0bee139..aeae8ab72db3 100644 --- a/typo3/sysext/backend/Classes/Module/AbstractModule.php +++ b/typo3/sysext/backend/Classes/Module/AbstractModule.php @@ -65,7 +65,7 @@ class AbstractModule $methodName = $request->getQueryParams()['action'] ?: 'index'; if (!is_callable([$this, $methodName])) { throw new \InvalidArgumentException( - 'The method "' . $methodName . '" is not callable within "' . get_class($this) . '".', + 'The method "' . $methodName . '" is not callable within "' . static::class . '".', 1442736343 ); } diff --git a/typo3/sysext/backend/Classes/Template/Components/Buttons/AbstractButton.php b/typo3/sysext/backend/Classes/Template/Components/Buttons/AbstractButton.php index 5a06230dd0a6..44609424fda6 100644 --- a/typo3/sysext/backend/Classes/Template/Components/Buttons/AbstractButton.php +++ b/typo3/sysext/backend/Classes/Template/Components/Buttons/AbstractButton.php @@ -83,7 +83,7 @@ class AbstractButton extends AbstractControl implements ButtonInterface */ public function getType() { - return get_class($this); + return static::class; } /** diff --git a/typo3/sysext/backend/Classes/Template/Components/Buttons/Action/HelpButton.php b/typo3/sysext/backend/Classes/Template/Components/Buttons/Action/HelpButton.php index cb964832026e..6ee8e4bde04b 100644 --- a/typo3/sysext/backend/Classes/Template/Components/Buttons/Action/HelpButton.php +++ b/typo3/sysext/backend/Classes/Template/Components/Buttons/Action/HelpButton.php @@ -116,7 +116,7 @@ class HelpButton implements ButtonInterface, PositionInterface */ public function getType() { - return get_class($this); + return static::class; } /** diff --git a/typo3/sysext/backend/Classes/Template/Components/Buttons/Action/ShortcutButton.php b/typo3/sysext/backend/Classes/Template/Components/Buttons/Action/ShortcutButton.php index b3b815041ad5..f5f7e9d99266 100644 --- a/typo3/sysext/backend/Classes/Template/Components/Buttons/Action/ShortcutButton.php +++ b/typo3/sysext/backend/Classes/Template/Components/Buttons/Action/ShortcutButton.php @@ -177,7 +177,7 @@ class ShortcutButton implements ButtonInterface, PositionInterface */ public function getType() { - return get_class($this); + return static::class; } /** diff --git a/typo3/sysext/backend/Classes/Template/Components/Buttons/FullyRenderedButton.php b/typo3/sysext/backend/Classes/Template/Components/Buttons/FullyRenderedButton.php index 99ebfbfd58f4..5cc3d62dd783 100644 --- a/typo3/sysext/backend/Classes/Template/Components/Buttons/FullyRenderedButton.php +++ b/typo3/sysext/backend/Classes/Template/Components/Buttons/FullyRenderedButton.php @@ -70,7 +70,7 @@ class FullyRenderedButton implements ButtonInterface */ public function getType() { - return get_class($this); + return static::class; } /** diff --git a/typo3/sysext/backend/Classes/Tree/ExtDirectNode.php b/typo3/sysext/backend/Classes/Tree/ExtDirectNode.php index fe1d51316a46..dff863037bdf 100644 --- a/typo3/sysext/backend/Classes/Tree/ExtDirectNode.php +++ b/typo3/sysext/backend/Classes/Tree/ExtDirectNode.php @@ -560,7 +560,7 @@ class ExtDirectNode extends \TYPO3\CMS\Backend\Tree\TreeNode public function toArray($addChildNodes = true) { $arrayRepresentation = [ - 'serializeClassName' => get_class($this), + 'serializeClassName' => static::class, 'id' => $this->getId(), 'type' => $this->getType(), 'editableText' => $this->getEditableText(), diff --git a/typo3/sysext/backend/Classes/Tree/Pagetree/PagetreeNode.php b/typo3/sysext/backend/Classes/Tree/Pagetree/PagetreeNode.php index c6ed33c7b849..71abfbe45886 100644 --- a/typo3/sysext/backend/Classes/Tree/Pagetree/PagetreeNode.php +++ b/typo3/sysext/backend/Classes/Tree/Pagetree/PagetreeNode.php @@ -425,7 +425,7 @@ class PagetreeNode extends \TYPO3\CMS\Backend\Tree\ExtDirectNode $arrayRepresentation['nodeData']['isMountPoint'] = $this->isMountPoint(); $arrayRepresentation['nodeData']['backgroundColor'] = htmlspecialchars($this->getBackgroundColor()); $arrayRepresentation['nodeData']['stopPageTree'] = $this->getStopPageTree(); - $arrayRepresentation['nodeData']['serializeClassName'] = get_class($this); + $arrayRepresentation['nodeData']['serializeClassName'] = static::class; return $arrayRepresentation; } diff --git a/typo3/sysext/backend/Classes/Tree/TreeNode.php b/typo3/sysext/backend/Classes/Tree/TreeNode.php index c46e38e12651..12e20128426c 100644 --- a/typo3/sysext/backend/Classes/Tree/TreeNode.php +++ b/typo3/sysext/backend/Classes/Tree/TreeNode.php @@ -180,7 +180,7 @@ class TreeNode implements \TYPO3\CMS\Backend\Tree\ComparableNodeInterface, \Seri public function toArray($addChildNodes = true) { $arrayRepresentation = [ - 'serializeClassName' => get_class($this), + 'serializeClassName' => static::class, 'id' => $this->id ]; if ($this->parentNode !== null) { @@ -231,7 +231,7 @@ class TreeNode implements \TYPO3\CMS\Backend\Tree\ComparableNodeInterface, \Seri public function unserialize($serializedString) { $arrayRepresentation = unserialize($serializedString); - if ($arrayRepresentation['serializeClassName'] !== get_class($this)) { + if ($arrayRepresentation['serializeClassName'] !== static::class) { throw new \TYPO3\CMS\Core\Exception('Deserialized object type is not identical!', 1294586646); } $this->dataFromArray($arrayRepresentation); diff --git a/typo3/sysext/backend/Classes/Tree/TreeNodeCollection.php b/typo3/sysext/backend/Classes/Tree/TreeNodeCollection.php index 1dc338a5fa5b..b1247dd78a53 100644 --- a/typo3/sysext/backend/Classes/Tree/TreeNodeCollection.php +++ b/typo3/sysext/backend/Classes/Tree/TreeNodeCollection.php @@ -73,7 +73,7 @@ class TreeNodeCollection extends \ArrayObject public function unserialize($serializedString) { $arrayRepresentation = unserialize($serializedString); - if ($arrayRepresentation['serializeClassName'] !== get_class($this)) { + if ($arrayRepresentation['serializeClassName'] !== static::class) { throw new \TYPO3\CMS\Core\Exception('Deserialized object type is not identical!', 1294586647); } $this->dataFromArray($arrayRepresentation); @@ -87,7 +87,7 @@ class TreeNodeCollection extends \ArrayObject public function toArray() { $arrayRepresentation = [ - 'serializeClassName' => get_class($this) + 'serializeClassName' => static::class ]; $iterator = $this->getIterator(); while ($iterator->valid()) { diff --git a/typo3/sysext/backend/Classes/Tree/View/ElementBrowserFolderTreeView.php b/typo3/sysext/backend/Classes/Tree/View/ElementBrowserFolderTreeView.php index 15392f634656..3912258caf1c 100644 --- a/typo3/sysext/backend/Classes/Tree/View/ElementBrowserFolderTreeView.php +++ b/typo3/sysext/backend/Classes/Tree/View/ElementBrowserFolderTreeView.php @@ -107,7 +107,7 @@ class ElementBrowserFolderTreeView extends FolderTreeView */ protected function renderPMIconAndLink($cmd, $isOpen) { - if (get_class($this) === __CLASS__) { + if (static::class === __CLASS__) { return $this->PMiconATagWrap('', $cmd, !$isOpen); } return parent::renderPMIconAndLink($cmd, $isOpen); @@ -146,7 +146,7 @@ class ElementBrowserFolderTreeView extends FolderTreeView { if (empty($this->scope)) { $this->scope = [ - 'class' => get_class($this), + 'class' => static::class, 'script' => $this->thisScript, 'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs, 'browser' => $this->linkParameterProvider->getUrlParameters([]), diff --git a/typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php b/typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php index b0875677ab0a..24b754584f97 100644 --- a/typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php +++ b/typo3/sysext/backend/Classes/Tree/View/FolderTreeView.php @@ -134,7 +134,7 @@ class FolderTreeView extends AbstractTreeView { if (empty($this->scope)) { $this->scope = [ - 'class' => get_class($this), + 'class' => static::class, 'script' => $this->thisScript, 'ext_noTempRecyclerDirs' => $this->ext_noTempRecyclerDirs ]; diff --git a/typo3/sysext/belog/Classes/Controller/AbstractController.php b/typo3/sysext/belog/Classes/Controller/AbstractController.php index 8e21899e60e4..a00b6e90c8ec 100644 --- a/typo3/sysext/belog/Classes/Controller/AbstractController.php +++ b/typo3/sysext/belog/Classes/Controller/AbstractController.php @@ -173,7 +173,7 @@ abstract class AbstractController extends ActionController */ protected function getConstraintFromBeUserData() { - $serializedConstraint = $GLOBALS['BE_USER']->getModuleData(get_class($this)); + $serializedConstraint = $GLOBALS['BE_USER']->getModuleData(static::class); if (!is_string($serializedConstraint) || empty($serializedConstraint)) { return null; } @@ -187,7 +187,7 @@ abstract class AbstractController extends ActionController */ protected function persistConstraintInBeUserData(\TYPO3\CMS\Belog\Domain\Model\Constraint $constraint) { - $GLOBALS['BE_USER']->pushModuleData(get_class($this), serialize($constraint)); + $GLOBALS['BE_USER']->pushModuleData(static::class, serialize($constraint)); } /** diff --git a/typo3/sysext/core/Classes/Cache/Backend/AbstractBackend.php b/typo3/sysext/core/Classes/Cache/Backend/AbstractBackend.php index 0540cf3338f2..6ef1d0225766 100644 --- a/typo3/sysext/core/Classes/Cache/Backend/AbstractBackend.php +++ b/typo3/sysext/core/Classes/Cache/Backend/AbstractBackend.php @@ -71,7 +71,7 @@ abstract class AbstractBackend implements \TYPO3\CMS\Core\Cache\Backend\BackendI if (method_exists($this, $methodName)) { $this->{$methodName}($optionValue); } else { - throw new \InvalidArgumentException('Invalid cache backend option "' . $optionKey . '" for backend of type "' . get_class($this) . '"', 1231267498); + throw new \InvalidArgumentException('Invalid cache backend option "' . $optionKey . '" for backend of type "' . static::class . '"', 1231267498); } } } diff --git a/typo3/sysext/core/Classes/Database/SoftReferenceIndex.php b/typo3/sysext/core/Classes/Database/SoftReferenceIndex.php index 8a12d240b45e..b3ed3dce8ddf 100644 --- a/typo3/sysext/core/Classes/Database/SoftReferenceIndex.php +++ b/typo3/sysext/core/Classes/Database/SoftReferenceIndex.php @@ -710,7 +710,7 @@ class SoftReferenceIndex */ protected function emitGetTypoLinkParts($linkHandlerFound, $finalTagParts, $linkHandlerKeyword, $linkHandlerValue) { - return $this->getSignalSlotDispatcher()->dispatch(get_class($this), 'getTypoLinkParts', [$linkHandlerFound, $finalTagParts, $linkHandlerKeyword, $linkHandlerValue]); + return $this->getSignalSlotDispatcher()->dispatch(static::class, 'getTypoLinkParts', [$linkHandlerFound, $finalTagParts, $linkHandlerKeyword, $linkHandlerValue]); } /** @@ -724,6 +724,6 @@ class SoftReferenceIndex */ protected function emitSetTypoLinkPartsElement($linkHandlerFound, $tLP, $content, $elements, $idx, $tokenID) { - return $this->getSignalSlotDispatcher()->dispatch(get_class($this), 'setTypoLinkPartsElement', [$linkHandlerFound, $tLP, $content, $elements, $idx, $tokenID, $this]); + return $this->getSignalSlotDispatcher()->dispatch(static::class, 'setTypoLinkPartsElement', [$linkHandlerFound, $tLP, $content, $elements, $idx, $tokenID, $this]); } } diff --git a/typo3/sysext/core/Classes/Html/RteHtmlParser.php b/typo3/sysext/core/Classes/Html/RteHtmlParser.php index 9c30b85c9d2e..05201f80c26d 100644 --- a/typo3/sysext/core/Classes/Html/RteHtmlParser.php +++ b/typo3/sysext/core/Classes/Html/RteHtmlParser.php @@ -1321,6 +1321,6 @@ class RteHtmlParser extends HtmlParser { /** @var $logManager LogManager */ $logManager = GeneralUtility::makeInstance(LogManager::class); - return $logManager->getLogger(get_class($this)); + return $logManager->getLogger(static::class); } } diff --git a/typo3/sysext/core/Classes/Log/Processor/AbstractProcessor.php b/typo3/sysext/core/Classes/Log/Processor/AbstractProcessor.php index 1e7143f64625..56b7a9dd5a8b 100644 --- a/typo3/sysext/core/Classes/Log/Processor/AbstractProcessor.php +++ b/typo3/sysext/core/Classes/Log/Processor/AbstractProcessor.php @@ -34,7 +34,7 @@ abstract class AbstractProcessor implements ProcessorInterface if (method_exists($this, $methodName)) { $this->{$methodName}($optionValue); } else { - throw new InvalidLogProcessorConfigurationException('Invalid LogProcessor configuration option "' . $optionKey . '" for log processor of type "' . get_class($this) . '"', 1321696151); + throw new InvalidLogProcessorConfigurationException('Invalid LogProcessor configuration option "' . $optionKey . '" for log processor of type "' . static::class . '"', 1321696151); } } } diff --git a/typo3/sysext/core/Classes/Log/Writer/AbstractWriter.php b/typo3/sysext/core/Classes/Log/Writer/AbstractWriter.php index 77adfa2a5ac2..50f851a96ec8 100644 --- a/typo3/sysext/core/Classes/Log/Writer/AbstractWriter.php +++ b/typo3/sysext/core/Classes/Log/Writer/AbstractWriter.php @@ -34,7 +34,7 @@ abstract class AbstractWriter implements WriterInterface if (method_exists($this, $methodName)) { $this->{$methodName}($optionValue); } else { - throw new InvalidLogWriterConfigurationException('Invalid LogWriter configuration option "' . $optionKey . '" for log writer of type "' . get_class($this) . '"', 1321696152); + throw new InvalidLogWriterConfigurationException('Invalid LogWriter configuration option "' . $optionKey . '" for log writer of type "' . static::class . '"', 1321696152); } } } diff --git a/typo3/sysext/core/Classes/Package/Package.php b/typo3/sysext/core/Classes/Package/Package.php index 3450a57030e4..e810a2956f83 100644 --- a/typo3/sysext/core/Classes/Package/Package.php +++ b/typo3/sysext/core/Classes/Package/Package.php @@ -264,7 +264,7 @@ class Package implements PackageInterface */ public function __sleep() { - $properties = get_class_vars(get_class($this)); + $properties = get_class_vars(static::class); unset($properties['packageManager']); return array_keys($properties); } diff --git a/typo3/sysext/core/Classes/Resource/ResourceStorage.php b/typo3/sysext/core/Classes/Resource/ResourceStorage.php index 4107be4b7466..d08ac765f5fb 100644 --- a/typo3/sysext/core/Classes/Resource/ResourceStorage.php +++ b/typo3/sysext/core/Classes/Resource/ResourceStorage.php @@ -3021,6 +3021,6 @@ class ResourceStorage implements ResourceStorageInterface $logManager = GeneralUtility::makeInstance( \TYPO3\CMS\Core\Log\LogManager::class ); - return $logManager->getLogger(get_class($this)); + return $logManager->getLogger(static::class); } } diff --git a/typo3/sysext/core/Classes/Session/Backend/DatabaseSessionBackend.php b/typo3/sysext/core/Classes/Session/Backend/DatabaseSessionBackend.php index 58a4a8b15f6a..ca733092c6a4 100644 --- a/typo3/sysext/core/Classes/Session/Backend/DatabaseSessionBackend.php +++ b/typo3/sysext/core/Classes/Session/Backend/DatabaseSessionBackend.php @@ -66,7 +66,7 @@ class DatabaseSessionBackend implements SessionBackendInterface { if (empty($this->configuration['table'])) { throw new \InvalidArgumentException( - 'The session backend "' . get_class($this) . '" needs a "table" configuration.', + 'The session backend "' . static::class . '" needs a "table" configuration.', 1442996707 ); } diff --git a/typo3/sysext/core/Classes/Type/Bitmask/JsConfirmation.php b/typo3/sysext/core/Classes/Type/Bitmask/JsConfirmation.php index 2308f04de664..bfc6ab20148a 100644 --- a/typo3/sysext/core/Classes/Type/Bitmask/JsConfirmation.php +++ b/typo3/sysext/core/Classes/Type/Bitmask/JsConfirmation.php @@ -110,7 +110,7 @@ class JsConfirmation extends Enumeration } $value = (string)$value; - foreach (static::$enumConstants[get_class($this)] as $constantValue) { + foreach (static::$enumConstants[static::class] as $constantValue) { if ($value === (string)$constantValue) { return true; } diff --git a/typo3/sysext/core/Classes/Type/Enumeration.php b/typo3/sysext/core/Classes/Type/Enumeration.php index 2bd65e8ce521..22167ee92e4a 100644 --- a/typo3/sysext/core/Classes/Type/Enumeration.php +++ b/typo3/sysext/core/Classes/Type/Enumeration.php @@ -41,7 +41,7 @@ abstract class Enumeration implements TypeInterface { if ($value === null && !defined('static::__default')) { throw new Exception\InvalidEnumerationValueException( - sprintf('A value for enumeration "%s" is required if no __default is defined.', get_class($this)), + sprintf('A value for enumeration "%s" is required if no __default is defined.', static::class), 1381512753 ); } @@ -51,7 +51,7 @@ abstract class Enumeration implements TypeInterface static::loadValues(); if (!$this->isValid($value)) { throw new Exception\InvalidEnumerationValueException( - sprintf('Invalid value "%s" for enumeration "%s"', $value, get_class($this)), + sprintf('Invalid value "%s" for enumeration "%s"', $value, static::class), 1381512761 ); } @@ -130,14 +130,14 @@ abstract class Enumeration implements TypeInterface */ protected function setValue($value) { - $enumKey = array_search($value, static::$enumConstants[get_class($this)]); + $enumKey = array_search($value, static::$enumConstants[static::class]); if ($enumKey === false) { throw new Exception\InvalidEnumerationValueException( sprintf('Invalid value "%s" for enumeration "%s"', $value, __CLASS__), 1381615295 ); } - $this->value = static::$enumConstants[get_class($this)][$enumKey]; + $this->value = static::$enumConstants[static::class][$enumKey]; } /** @@ -149,7 +149,7 @@ abstract class Enumeration implements TypeInterface protected function isValid($value) { $value = (string)$value; - foreach (static::$enumConstants[get_class($this)] as $constantValue) { + foreach (static::$enumConstants[static::class] as $constantValue) { if ($value === (string)$constantValue) { return true; } diff --git a/typo3/sysext/core/Classes/Type/File/ImageInfo.php b/typo3/sysext/core/Classes/Type/File/ImageInfo.php index c9de84dd4f56..7c6e5e63adab 100644 --- a/typo3/sysext/core/Classes/Type/File/ImageInfo.php +++ b/typo3/sysext/core/Classes/Type/File/ImageInfo.php @@ -113,7 +113,7 @@ class ImageInfo extends FileInfo /** @var $loggerManager LogManager */ $loggerManager = GeneralUtility::makeInstance(LogManager::class); - return $loggerManager->getLogger(get_class($this)); + return $loggerManager->getLogger(static::class); } /** diff --git a/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php b/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php index 24481d5d53db..f671d3188379 100644 --- a/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php +++ b/typo3/sysext/core/Tests/Unit/Resource/Driver/LocalDriverTest.php @@ -741,7 +741,7 @@ class LocalDriverTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase // register static callback to self $callback = [ [ - get_class($this), + static::class, 'callbackStaticTestFunction' ] ]; diff --git a/typo3/sysext/extbase/Classes/DomainObject/AbstractDomainObject.php b/typo3/sysext/extbase/Classes/DomainObject/AbstractDomainObject.php index 2ff8abfd1c68..8990f12924da 100644 --- a/typo3/sysext/extbase/Classes/DomainObject/AbstractDomainObject.php +++ b/typo3/sysext/extbase/Classes/DomainObject/AbstractDomainObject.php @@ -323,6 +323,6 @@ abstract class AbstractDomainObject implements DomainObjectInterface, \TYPO3\CMS */ public function __toString() { - return get_class($this) . ':' . (string)$this->uid; + return static::class . ':' . (string)$this->uid; } } diff --git a/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php b/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php index 441ec5a10fa6..1a6e9de921f5 100644 --- a/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php +++ b/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php @@ -130,7 +130,7 @@ abstract class AbstractController implements ControllerInterface */ public function __construct() { - $className = get_class($this); + $className = static::class; if (strpos($className, '\\') !== false) { $classNameParts = explode('\\', $className, 4); // Skip vendor and product name for core classes @@ -223,7 +223,7 @@ abstract class AbstractController implements ControllerInterface public function processRequest(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response) { if (!$this->canProcessRequest($request)) { - throw new UnsupportedRequestTypeException(get_class($this) . ' does not support requests of type "' . get_class($request) . '". Supported types are: ' . implode(' ', $this->supportedRequestTypes), 1187701132); + throw new UnsupportedRequestTypeException(static::class . ' does not support requests of type "' . get_class($request) . '". Supported types are: ' . implode(' ', $this->supportedRequestTypes), 1187701132); } if ($response instanceof \TYPO3\CMS\Extbase\Mvc\Web\Response && $request instanceof WebRequest) { $response->setRequest($request); diff --git a/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php b/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php index a3ff0745b133..c97960da0bcb 100644 --- a/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php +++ b/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php @@ -147,7 +147,7 @@ class ActionController extends AbstractController public function processRequest(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response) { if (!$this->canProcessRequest($request)) { - throw new \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException(get_class($this) . ' does not support requests of type "' . get_class($request) . '". Supported types are: ' . implode(' ', $this->supportedRequestTypes), 1187701131); + throw new \TYPO3\CMS\Extbase\Mvc\Exception\UnsupportedRequestTypeException(static::class . ' does not support requests of type "' . get_class($request) . '". Supported types are: ' . implode(' ', $this->supportedRequestTypes), 1187701131); } if ($response instanceof \TYPO3\CMS\Extbase\Mvc\Web\Response && $request instanceof WebRequest) { @@ -224,7 +224,7 @@ class ActionController extends AbstractController */ protected function initializeActionMethodArguments() { - $methodParameters = $this->reflectionService->getMethodParameters(get_class($this), $this->actionMethodName); + $methodParameters = $this->reflectionService->getMethodParameters(static::class, $this->actionMethodName); foreach ($methodParameters as $parameterName => $parameterInfo) { $dataType = null; if (isset($parameterInfo['type'])) { @@ -233,7 +233,7 @@ class ActionController extends AbstractController $dataType = 'array'; } if ($dataType === null) { - throw new \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentTypeException('The argument type for parameter $' . $parameterName . ' of method ' . get_class($this) . '->' . $this->actionMethodName . '() could not be detected.', 1253175643); + throw new \TYPO3\CMS\Extbase\Mvc\Exception\InvalidArgumentTypeException('The argument type for parameter $' . $parameterName . ' of method ' . static::class . '->' . $this->actionMethodName . '() could not be detected.', 1253175643); } $defaultValue = isset($parameterInfo['defaultValue']) ? $parameterInfo['defaultValue'] : null; $this->arguments->addNewArgument($parameterName, $dataType, $parameterInfo['optional'] === false, $defaultValue); @@ -266,7 +266,7 @@ class ActionController extends AbstractController * @todo: add resolving of $actionValidateAnnotations and pass them to * buildMethodArgumentsValidatorConjunctions as in TYPO3.Flow */ - $parameterValidators = $this->validatorResolver->buildMethodArgumentsValidatorConjunctions(get_class($this), $this->actionMethodName, $methodParameters); + $parameterValidators = $this->validatorResolver->buildMethodArgumentsValidatorConjunctions(static::class, $this->actionMethodName, $methodParameters); /** @var \TYPO3\CMS\Extbase\Mvc\Controller\Argument $argument */ foreach ($this->arguments as $argument) { $validator = $parameterValidators[$argument->getName()]; @@ -289,7 +289,7 @@ class ActionController extends AbstractController { $actionMethodName = $this->request->getControllerActionName() . 'Action'; if (!method_exists($this, $actionMethodName)) { - throw new \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchActionException('An action "' . $actionMethodName . '" does not exist in controller "' . get_class($this) . '".', 1186669086); + throw new \TYPO3\CMS\Extbase\Mvc\Exception\NoSuchActionException('An action "' . $actionMethodName . '" does not exist in controller "' . static::class . '".', 1186669086); } return $actionMethodName; } @@ -315,7 +315,7 @@ class ActionController extends AbstractController $this->emitBeforeCallActionMethodSignal($preparedArguments); $actionResult = call_user_func_array([$this, $this->actionMethodName], $preparedArguments); } else { - $methodTagsValues = $this->reflectionService->getMethodTagsValues(get_class($this), $this->actionMethodName); + $methodTagsValues = $this->reflectionService->getMethodTagsValues(static::class, $this->actionMethodName); $ignoreValidationAnnotations = []; if (isset($methodTagsValues['ignorevalidation'])) { $ignoreValidationAnnotations = $methodTagsValues['ignorevalidation']; @@ -357,7 +357,7 @@ class ActionController extends AbstractController */ protected function emitBeforeCallActionMethodSignal(array $preparedArguments) { - $this->signalSlotDispatcher->dispatch(__CLASS__, 'beforeCallActionMethod', [get_class($this), $this->actionMethodName, $preparedArguments]); + $this->signalSlotDispatcher->dispatch(__CLASS__, 'beforeCallActionMethod', [static::class, $this->actionMethodName, $preparedArguments]); } /** @@ -593,7 +593,7 @@ class ActionController extends AbstractController */ protected function getErrorFlashMessage() { - return 'An error occurred while trying to call ' . get_class($this) . '->' . $this->actionMethodName . '()'; + return 'An error occurred while trying to call ' . static::class . '->' . $this->actionMethodName . '()'; } /** @@ -628,7 +628,7 @@ class ActionController extends AbstractController */ protected function getFlattenedValidationErrorMessage() { - $outputMessage = 'Validation failed while trying to call ' . get_class($this) . '->' . $this->actionMethodName . '().' . PHP_EOL; + $outputMessage = 'Validation failed while trying to call ' . static::class . '->' . $this->actionMethodName . '().' . PHP_EOL; return $outputMessage; } diff --git a/typo3/sysext/extbase/Classes/Mvc/Controller/CommandController.php b/typo3/sysext/extbase/Classes/Mvc/Controller/CommandController.php index 377d2ab8ee20..ee0678458aa1 100644 --- a/typo3/sysext/extbase/Classes/Mvc/Controller/CommandController.php +++ b/typo3/sysext/extbase/Classes/Mvc/Controller/CommandController.php @@ -118,7 +118,7 @@ class CommandController implements CommandControllerInterface public function processRequest(RequestInterface $request, ResponseInterface $response) { if (!$this->canProcessRequest($request)) { - throw new UnsupportedRequestTypeException(sprintf('%s only supports command line requests – requests of type "%s" given.', get_class($this), get_class($request)), 1300787096); + throw new UnsupportedRequestTypeException(sprintf('%s only supports command line requests – requests of type "%s" given.', static::class, get_class($request)), 1300787096); } $this->request = $request; @@ -147,7 +147,7 @@ class CommandController implements CommandControllerInterface { $commandMethodName = $this->request->getControllerCommandName() . 'Command'; if (!is_callable([$this, $commandMethodName])) { - throw new NoSuchCommandException(sprintf('A command method "%s()" does not exist in controller "%s".', $commandMethodName, get_class($this)), 1300902143); + throw new NoSuchCommandException(sprintf('A command method "%s()" does not exist in controller "%s".', $commandMethodName, static::class), 1300902143); } return $commandMethodName; } @@ -161,7 +161,7 @@ class CommandController implements CommandControllerInterface */ protected function initializeCommandMethodArguments() { - $methodParameters = $this->reflectionService->getMethodParameters(get_class($this), $this->commandMethodName); + $methodParameters = $this->reflectionService->getMethodParameters(static::class, $this->commandMethodName); foreach ($methodParameters as $parameterName => $parameterInfo) { $dataType = null; @@ -171,7 +171,7 @@ class CommandController implements CommandControllerInterface $dataType = 'array'; } if ($dataType === null) { - throw new InvalidArgumentTypeException(sprintf('The argument type for parameter $%s of method %s->%s() could not be detected.', $parameterName, get_class($this), $this->commandMethodName), 1306755296); + throw new InvalidArgumentTypeException(sprintf('The argument type for parameter $%s of method %s->%s() could not be detected.', $parameterName, static::class, $this->commandMethodName), 1306755296); } $defaultValue = (isset($parameterInfo['defaultValue']) ? $parameterInfo['defaultValue'] : null); $this->arguments->addNewArgument($parameterName, $dataType, ($parameterInfo['optional'] === false), $defaultValue); diff --git a/typo3/sysext/extbase/Classes/Persistence/Repository.php b/typo3/sysext/extbase/Classes/Persistence/Repository.php index d3830d4e93cf..60c002788e9f 100644 --- a/typo3/sysext/extbase/Classes/Persistence/Repository.php +++ b/typo3/sysext/extbase/Classes/Persistence/Repository.php @@ -261,6 +261,6 @@ class Repository implements RepositoryInterface, \TYPO3\CMS\Core\SingletonInterf */ protected function getRepositoryClassName() { - return get_class($this); + return static::class; } } diff --git a/typo3/sysext/extbase/Classes/Property/PropertyMappingConfiguration.php b/typo3/sysext/extbase/Classes/Property/PropertyMappingConfiguration.php index 3ef22d5a740e..42a17d6e2b4f 100644 --- a/typo3/sysext/extbase/Classes/Property/PropertyMappingConfiguration.php +++ b/typo3/sysext/extbase/Classes/Property/PropertyMappingConfiguration.php @@ -378,7 +378,7 @@ class PropertyMappingConfiguration implements PropertyMappingConfigurationInterf $currentProperty = array_shift($splittedPropertyPath); if (!isset($this->subConfigurationForProperty[$currentProperty])) { - $type = get_class($this); + $type = static::class; if (isset($this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER])) { $this->subConfigurationForProperty[$currentProperty] = clone $this->subConfigurationForProperty[self::PROPERTY_PATH_PLACEHOLDER]; } else { diff --git a/typo3/sysext/extbase/Tests/Unit/Reflection/ReflectionServiceTest.php b/typo3/sysext/extbase/Tests/Unit/Reflection/ReflectionServiceTest.php index 3c1b93abfa8e..830700eaa5db 100644 --- a/typo3/sysext/extbase/Tests/Unit/Reflection/ReflectionServiceTest.php +++ b/typo3/sysext/extbase/Tests/Unit/Reflection/ReflectionServiceTest.php @@ -46,7 +46,7 @@ class ReflectionServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa public function getClassTagsValues() { $service = new ReflectionService(); - $classValues = $service->getClassTagsValues(get_class($this)); + $classValues = $service->getClassTagsValues(static::class); $this->assertEquals([ 'firsttest' => ['test for reflection'], 'anothertest' => ['second test for reflection', 'second test for reflection with second value'] @@ -59,7 +59,7 @@ class ReflectionServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa public function getClassTagValues() { $service = new ReflectionService(); - $classValues = $service->getClassTagValues(get_class($this), 'firsttest'); + $classValues = $service->getClassTagValues(static::class, 'firsttest'); $this->assertEquals([ 'test for reflection', ], $classValues); @@ -71,8 +71,8 @@ class ReflectionServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa public function hasMethod() { $service = new ReflectionService(); - $this->assertTrue($service->hasMethod(get_class($this), 'fixtureMethodForMethodTagsValues')); - $this->assertFalse($service->hasMethod(get_class($this), 'notExistentMethod')); + $this->assertTrue($service->hasMethod(static::class, 'fixtureMethodForMethodTagsValues')); + $this->assertFalse($service->hasMethod(static::class, 'notExistentMethod')); } /** @@ -81,7 +81,7 @@ class ReflectionServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa public function getMethodTagsValues() { $service = new ReflectionService(); - $tagsValues = $service->getMethodTagsValues(get_class($this), 'fixtureMethodForMethodTagsValues'); + $tagsValues = $service->getMethodTagsValues(static::class, 'fixtureMethodForMethodTagsValues'); $this->assertEquals([ 'param' => ['array $foo The foo parameter'], 'return' => ['string'] @@ -94,7 +94,7 @@ class ReflectionServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa public function getMethodParameters() { $service = new ReflectionService(); - $parameters = $service->getMethodParameters(get_class($this), 'fixtureMethodForMethodTagsValues'); + $parameters = $service->getMethodParameters(static::class, 'fixtureMethodForMethodTagsValues'); $this->assertSame([ 'foo' => [ 'position' => 0, @@ -114,7 +114,7 @@ class ReflectionServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCa public function getMethodParametersWithShortTypeNames() { $service = new ReflectionService(); - $parameters = $service->getMethodParameters(get_class($this), 'fixtureMethodForMethodTagsValuesWithShortTypes'); + $parameters = $service->getMethodParameters(static::class, 'fixtureMethodForMethodTagsValuesWithShortTypes'); $this->assertSame([ 'dummy' => [ 'position' => 0, diff --git a/typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionListUtility.php b/typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionListUtility.php index 988fd916c59b..05976c39be9f 100644 --- a/typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionListUtility.php +++ b/typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionListUtility.php @@ -121,7 +121,7 @@ class ExtensionListUtility implements \SplObserver $this->parser->attach($this); } else { throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException( - get_class($this) . ': No XML parser available.', + static::class . ': No XML parser available.', 1476108717 ); } diff --git a/typo3/sysext/extensionmanager/Classes/Utility/Importer/MirrorListUtility.php b/typo3/sysext/extensionmanager/Classes/Utility/Importer/MirrorListUtility.php index 20a41388b7f0..d13bf4350624 100644 --- a/typo3/sysext/extensionmanager/Classes/Utility/Importer/MirrorListUtility.php +++ b/typo3/sysext/extensionmanager/Classes/Utility/Importer/MirrorListUtility.php @@ -47,7 +47,7 @@ class MirrorListUtility implements \SplObserver $this->parser->attach($this); } else { throw new \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException( - get_class($this) . ': No XML parser available.', + static::class . ': No XML parser available.', 1476108687 ); } diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php index 64d0403eb5b9..fcc976df8104 100644 --- a/typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php +++ b/typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php @@ -92,8 +92,8 @@ abstract class AbstractTagBasedViewHelper extends AbstractViewHelper } } - if (isset(self::$tagAttributes[get_class($this)])) { - foreach (self::$tagAttributes[get_class($this)] as $attributeName) { + if (isset(self::$tagAttributes[static::class])) { + foreach (self::$tagAttributes[static::class] as $attributeName) { if ($this->hasArgument($attributeName) && $this->arguments[$attributeName] !== '') { $this->tag->addAttribute($attributeName, $this->arguments[$attributeName]); } @@ -114,7 +114,7 @@ abstract class AbstractTagBasedViewHelper extends AbstractViewHelper protected function registerTagAttribute($name, $type, $description, $required = false, $default = null) { $this->registerArgument($name, $type, $description, $required, $default); - self::$tagAttributes[get_class($this)][$name] = $name; + self::$tagAttributes[static::class][$name] = $name; } /** diff --git a/typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractViewHelper.php b/typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractViewHelper.php index 3dba9f82634f..ca5b1ce567a1 100644 --- a/typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractViewHelper.php +++ b/typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractViewHelper.php @@ -111,11 +111,11 @@ abstract class AbstractViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\Abst */ protected function registerRenderMethodArguments() { - GeneralUtility::deprecationLog(sprintf('Render method argument support is deprecated (used on class "%s"), switch to initializeArguments and registerArgument.', get_class($this))); + GeneralUtility::deprecationLog(sprintf('Render method argument support is deprecated (used on class "%s"), switch to initializeArguments and registerArgument.', static::class)); $reflectionService = $this->getReflectionService(); - $methodParameters = $reflectionService->getMethodParameters(get_class($this), 'render'); - $methodTags = $reflectionService->getMethodTagsValues(get_class($this), 'render'); + $methodParameters = $reflectionService->getMethodParameters(static::class, 'render'); + $methodTags = $reflectionService->getMethodTagsValues(static::class, 'render'); $paramAnnotations = []; if (isset($methodTags['param'])) { @@ -128,7 +128,7 @@ abstract class AbstractViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\Abst if (isset($parameterInfo['type'])) { $dataType = isset($parameterInfo['array']) && (bool)$parameterInfo['array'] ? 'array' : $parameterInfo['type']; } else { - throw new \TYPO3\CMS\Fluid\Core\Exception('Could not determine type of argument "' . $parameterName . '" of the render-method in ViewHelper "' . get_class($this) . '". Either the methods docComment is invalid or some PHP optimizer strips off comments.', 1242292003); + throw new \TYPO3\CMS\Fluid\Core\Exception('Could not determine type of argument "' . $parameterName . '" of the render-method in ViewHelper "' . static::class . '". Either the methods docComment is invalid or some PHP optimizer strips off comments.', 1242292003); } $description = ''; diff --git a/typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php b/typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php index d5db37a77bc7..65c27a9fcaff 100644 --- a/typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php +++ b/typo3/sysext/fluid/Classes/Core/Widget/AbstractWidgetViewHelper.php @@ -130,7 +130,7 @@ abstract class AbstractWidgetViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper $this->widgetContext->setParentPluginName($pluginName); $pluginNamespace = $this->extensionService->getPluginNamespace($extensionName, $pluginName); $this->widgetContext->setParentPluginNamespace($pluginNamespace); - $this->widgetContext->setWidgetViewHelperClassName(get_class($this)); + $this->widgetContext->setWidgetViewHelperClassName(static::class); if ($this->ajaxWidget === true) { $this->ajaxWidgetContextHolder->store($this->widgetContext); } @@ -177,7 +177,7 @@ abstract class AbstractWidgetViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper 'initiateSubRequest() can not be called if there is no valid controller extending ' . 'TYPO3\\CMS\\Fluid\\Core\\Widget\\AbstractWidgetController' . ' Got "' . ($this->controller ? get_class($this->controller) : gettype($this->controller)) . - '" in class "' . get_class($this) . '".', + '" in class "' . static::class . '".', 1289422564 ); } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/PaginateController.php b/typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/PaginateController.php index 878a60e742c7..4410caec3381 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/PaginateController.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Widget/Controller/PaginateController.php @@ -192,7 +192,7 @@ class PaginateController extends AbstractWidgetController return $modifiedObjects; } throw new \InvalidArgumentException( - 'The view helper "' . get_class($this) + 'The view helper "' . static::class . '" accepts as argument "QueryResultInterface", "\SplObjectStorage", "ObjectStorage" or an array. ' . 'given: ' . get_class($this->objects), 1385547291 diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentDataProcessorTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentDataProcessorTest.php index c14b6001e9d8..864b1432f525 100644 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentDataProcessorTest.php +++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/ContentDataProcessorTest.php @@ -62,7 +62,7 @@ class ContentDataProcessorTest extends \TYPO3\TestingFramework\Core\Unit\UnitTes $contentObjectRendererStub = new ContentObjectRenderer(); $config = [ 'dataProcessing.' => [ - '10' => get_class($this) + '10' => static::class ] ]; $variables = []; diff --git a/typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/MenuContentObjectFactoryTest.php b/typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/MenuContentObjectFactoryTest.php index 142d9a981340..f4270bfd596d 100644 --- a/typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/MenuContentObjectFactoryTest.php +++ b/typo3/sysext/frontend/Tests/Unit/ContentObject/Menu/MenuContentObjectFactoryTest.php @@ -57,7 +57,7 @@ class MenuContentObjectFactoryTest extends \TYPO3\TestingFramework\Core\Unit\Uni public function getMenuObjectByTypeReturnsInstanceOfOwnRegisteredTypeInsteadOfInternalType() { $factory = new MenuContentObjectFactory; - $selfClassName = get_class($this); + $selfClassName = static::class; $factory->registerMenuType('GMENU', $selfClassName); $this->assertInstanceOf($selfClassName, $factory->getMenuObjectByType('GMENU')); } @@ -68,7 +68,7 @@ class MenuContentObjectFactoryTest extends \TYPO3\TestingFramework\Core\Unit\Uni public function getMenuObjectByTypeReturnsInstanceOfNewRegisteredType() { $factory = new MenuContentObjectFactory; - $selfClassName = get_class($this); + $selfClassName = static::class; $uniqueMenuType = $this->getUniqueId('foo_'); $factory->registerMenuType($uniqueMenuType, $selfClassName); $this->assertInstanceOf($selfClassName, $factory->getMenuObjectByType($uniqueMenuType)); diff --git a/typo3/sysext/install/Classes/SystemEnvironment/Check.php b/typo3/sysext/install/Classes/SystemEnvironment/Check.php index dfbe9f5b1832..12889dbea9a8 100644 --- a/typo3/sysext/install/Classes/SystemEnvironment/Check.php +++ b/typo3/sysext/install/Classes/SystemEnvironment/Check.php @@ -579,7 +579,7 @@ class Check implements CheckInterface */ protected function checkReflectionDocComment() { - $testReflection = new \ReflectionMethod(get_class($this), __FUNCTION__); + $testReflection = new \ReflectionMethod(static::class, __FUNCTION__); if ($testReflection->getDocComment() === false) { $this->messageQueue->enqueue(new FlashMessage( 'TYPO3 CMS core extensions like extbase and fluid heavily rely on method' diff --git a/typo3/sysext/install/Classes/Updates/AbstractUpdate.php b/typo3/sysext/install/Classes/Updates/AbstractUpdate.php index 1cac4c4e5b97..8bcdb50bb8ee 100644 --- a/typo3/sysext/install/Classes/Updates/AbstractUpdate.php +++ b/typo3/sysext/install/Classes/Updates/AbstractUpdate.php @@ -162,7 +162,7 @@ abstract class AbstractUpdate */ protected function markWizardAsDone($confValue = 1) { - GeneralUtility::makeInstance(Registry::class)->set('installUpdate', get_class($this), $confValue); + GeneralUtility::makeInstance(Registry::class)->set('installUpdate', static::class, $confValue); } /** @@ -172,7 +172,7 @@ abstract class AbstractUpdate */ protected function isWizardDone() { - $wizardClassName = get_class($this); + $wizardClassName = static::class; return GeneralUtility::makeInstance(Registry::class)->get('installUpdate', $wizardClassName, false); } } diff --git a/typo3/sysext/scheduler/Classes/Task/AbstractTask.php b/typo3/sysext/scheduler/Classes/Task/AbstractTask.php index 3fc1bb7cdfdb..7a6fa94b1b53 100644 --- a/typo3/sysext/scheduler/Classes/Task/AbstractTask.php +++ b/typo3/sysext/scheduler/Classes/Task/AbstractTask.php @@ -145,7 +145,7 @@ abstract class AbstractTask */ public function getTaskTitle() { - return $GLOBALS['LANG']->sL($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][get_class($this)]['title']); + return $GLOBALS['LANG']->sL($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][static::class]['title']); } /** @@ -155,7 +155,7 @@ abstract class AbstractTask */ public function getTaskDescription() { - return $GLOBALS['LANG']->sL($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][get_class($this)]['description']); + return $GLOBALS['LANG']->sL($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][static::class]['description']); } /** @@ -165,7 +165,7 @@ abstract class AbstractTask */ public function getTaskClassName() { - return get_class($this); + return static::class; } /** @@ -490,7 +490,7 @@ abstract class AbstractTask } if ($failure instanceof \Exception) { // Log failed execution - $logMessage = 'Task failed to execute successfully. Class: ' . get_class($this) + $logMessage = 'Task failed to execute successfully. Class: ' . static::class . ', UID: ' . $this->taskUid . ', Code: ' . $failure->getCode() . ', ' . $failure->getMessage(); $this->scheduler->log($logMessage, 1); // Do not serialize the complete exception or the trace, this can lead to huge strings > 50MB @@ -608,6 +608,6 @@ abstract class AbstractTask protected function getLogger() { $logManager = GeneralUtility::makeInstance(LogManager::class); - return $logManager->getLogger(get_class($this)); + return $logManager->getLogger(static::class); } } -- GitLab