From: Tim Düsterhus Date: Wed, 9 Jun 2021 12:41:29 +0000 (+0200) Subject: Use `static::class` instead of `get_called_class()` / `get_class($this)` X-Git-Tag: 5.5.0_Alpha_1~674 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0befcb4aaaab68001abcf372eb4ad2e48659a9b9;p=GitHub%2FWoltLab%2FWCF.git Use `static::class` instead of `get_called_class()` / `get_class($this)` --- diff --git a/wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php b/wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php index 09d731c90c..4c7f79cba2 100644 --- a/wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/AbstractBulkProcessingForm.class.php @@ -68,7 +68,7 @@ abstract class AbstractBulkProcessingForm extends AbstractForm { parent::assignVariables(); - $classParts = \explode('\\', \get_class($this)); + $classParts = \explode('\\', static::class); WCF::getTPL()->assign([ 'actions' => $this->actions, diff --git a/wcfsetup/install/files/lib/acp/form/AbstractCategoryAddForm.class.php b/wcfsetup/install/files/lib/acp/form/AbstractCategoryAddForm.class.php index ea9178b474..ea4d12db31 100644 --- a/wcfsetup/install/files/lib/acp/form/AbstractCategoryAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/AbstractCategoryAddForm.class.php @@ -122,7 +122,7 @@ abstract class AbstractCategoryAddForm extends AbstractForm */ public function __run() { - $classNameParts = \explode('\\', \get_called_class()); + $classNameParts = \explode('\\', static::class); $className = \array_pop($classNameParts); // autoset controllers diff --git a/wcfsetup/install/files/lib/acp/page/AbstractCategoryListPage.class.php b/wcfsetup/install/files/lib/acp/page/AbstractCategoryListPage.class.php index a84c6f25f7..9782a7610d 100644 --- a/wcfsetup/install/files/lib/acp/page/AbstractCategoryListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/AbstractCategoryListPage.class.php @@ -80,7 +80,7 @@ abstract class AbstractCategoryListPage extends AbstractPage */ public function __run() { - $classNameParts = \explode('\\', \get_called_class()); + $classNameParts = \explode('\\', static::class); $className = \array_pop($classNameParts); // autoset controllers diff --git a/wcfsetup/install/files/lib/action/AJAXInvokeAction.class.php b/wcfsetup/install/files/lib/action/AJAXInvokeAction.class.php index 337e308a35..8db8361c88 100644 --- a/wcfsetup/install/files/lib/action/AJAXInvokeAction.class.php +++ b/wcfsetup/install/files/lib/action/AJAXInvokeAction.class.php @@ -225,7 +225,7 @@ class AJAXInvokeAction extends AbstractSecureAction } // execute request - $className = \get_called_class(); + $className = static::class; /** @var AJAXInvokeAction $actionObject */ $actionObject = new $className(); diff --git a/wcfsetup/install/files/lib/action/AbstractDialogAction.class.php b/wcfsetup/install/files/lib/action/AbstractDialogAction.class.php index 850fb303bb..f7e5100514 100644 --- a/wcfsetup/install/files/lib/action/AbstractDialogAction.class.php +++ b/wcfsetup/install/files/lib/action/AbstractDialogAction.class.php @@ -66,7 +66,7 @@ abstract class AbstractDialogAction extends AbstractSecureAction $methodName = 'step' . StringUtil::firstCharToUpperCase($this->step); if (!\method_exists($this, $methodName)) { - throw new AJAXException("Class '" . \get_class($this) . "' does not implement the required method '" . $methodName . "'"); + throw new AJAXException("Class '" . static::class . "' does not implement the required method '" . $methodName . "'"); } // execute step diff --git a/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php b/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php index 0bdf307df1..0e8dd2f354 100644 --- a/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php +++ b/wcfsetup/install/files/lib/data/AbstractDatabaseObjectAction.class.php @@ -119,7 +119,7 @@ abstract class AbstractDatabaseObjectAction implements IDatabaseObjectAction, ID { // set class name if (empty($this->className)) { - $className = \get_called_class(); + $className = static::class; if (\mb_substr($className, -6) == 'Action') { $this->className = \mb_substr($className, 0, -6) . 'Editor'; diff --git a/wcfsetup/install/files/lib/data/DatabaseObject.class.php b/wcfsetup/install/files/lib/data/DatabaseObject.class.php index 3c0aae5ddf..6f3c90b91f 100644 --- a/wcfsetup/install/files/lib/data/DatabaseObject.class.php +++ b/wcfsetup/install/files/lib/data/DatabaseObject.class.php @@ -136,7 +136,7 @@ abstract class DatabaseObject implements IIDObject, IStorableObject */ public static function getDatabaseTableName() { - $className = \get_called_class(); + $className = static::class; $classParts = \explode('\\', $className); if (static::$databaseTableName !== '') { @@ -168,7 +168,7 @@ abstract class DatabaseObject implements IIDObject, IStorableObject return static::$databaseTableName; } - $className = \get_called_class(); + $className = static::class; static $databaseTableAliases = []; if (!isset($databaseTableAliases[$className])) { $classParts = \explode('\\', $className); @@ -205,7 +205,7 @@ abstract class DatabaseObject implements IIDObject, IStorableObject static $databaseTableIndexName = null; if ($databaseTableIndexName === null) { - $className = \explode('\\', \get_called_class()); + $className = \explode('\\', static::class); $parts = \preg_split( '~(?=[A-Z](?=[a-z]))~', \array_pop($className), diff --git a/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php b/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php index c47a762e7c..2dd251af64 100644 --- a/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php +++ b/wcfsetup/install/files/lib/data/DatabaseObjectList.class.php @@ -114,7 +114,7 @@ abstract class DatabaseObjectList implements \Countable, ITraversableObject { // set class name if (empty($this->className)) { - $className = \get_called_class(); + $className = static::class; if (\mb_substr($className, -4) == 'List') { $this->className = \mb_substr($className, 0, -4); diff --git a/wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php b/wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php index 69c43e4c48..4401f097bf 100644 --- a/wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php +++ b/wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php @@ -218,7 +218,7 @@ class UsersOnlineList extends SessionList break; } - EventHandler::getInstance()->fireAction(\get_called_class(), 'isVisible', $data); + EventHandler::getInstance()->fireAction(static::class, 'isVisible', $data); return $data['result']; } @@ -260,7 +260,7 @@ class UsersOnlineList extends SessionList break; } - EventHandler::getInstance()->fireAction(\get_called_class(), 'isVisibleUser', $data); + EventHandler::getInstance()->fireAction(static::class, 'isVisibleUser', $data); return $data['result']; } diff --git a/wcfsetup/install/files/lib/form/AbstractFormBuilderForm.class.php b/wcfsetup/install/files/lib/form/AbstractFormBuilderForm.class.php index ce2afe8368..46d2b0a062 100644 --- a/wcfsetup/install/files/lib/form/AbstractFormBuilderForm.class.php +++ b/wcfsetup/install/files/lib/form/AbstractFormBuilderForm.class.php @@ -113,7 +113,7 @@ abstract class AbstractFormBuilderForm extends AbstractForm */ protected function createForm() { - $classNamePieces = \explode('\\', \get_class($this)); + $classNamePieces = \explode('\\', static::class); $controller = \preg_replace('~Form$~', '', \end($classNamePieces)); $this->form = $this->formClassName::create(\lcfirst($controller)); diff --git a/wcfsetup/install/files/lib/form/MessageForm.class.php b/wcfsetup/install/files/lib/form/MessageForm.class.php index 3fc2464c8e..d570c8c00d 100644 --- a/wcfsetup/install/files/lib/form/MessageForm.class.php +++ b/wcfsetup/install/files/lib/form/MessageForm.class.php @@ -218,7 +218,7 @@ abstract class MessageForm extends AbstractCaptchaForm protected function validateText() { if (empty($this->messageObjectType)) { - throw new \RuntimeException("Expected non-empty message object type for '" . \get_class($this) . "'"); + throw new \RuntimeException("Expected non-empty message object type for '" . static::class . "'"); } if (empty($this->text)) { diff --git a/wcfsetup/install/files/lib/page/AbstractPage.class.php b/wcfsetup/install/files/lib/page/AbstractPage.class.php index a43a2ab86e..01c317264a 100644 --- a/wcfsetup/install/files/lib/page/AbstractPage.class.php +++ b/wcfsetup/install/files/lib/page/AbstractPage.class.php @@ -345,7 +345,7 @@ abstract class AbstractPage implements IPage EventHandler::getInstance()->fireAction($this, 'show'); // try to guess template name - $classParts = \explode('\\', \get_class($this)); + $classParts = \explode('\\', static::class); if (empty($this->templateName)) { $className = \preg_replace('~(Form|Page)$~', '', \array_pop($classParts)); @@ -401,7 +401,7 @@ abstract class AbstractPage implements IPage RegisterForm::class, RegisterNewActivationCodeForm::class, ]; - if (\in_array(\get_class($this), $allowedControllers)) { + if (\in_array(static::class, $allowedControllers)) { // controller is allowed return; } diff --git a/wcfsetup/install/files/lib/system/SingletonFactory.class.php b/wcfsetup/install/files/lib/system/SingletonFactory.class.php index a3d9a5a43f..d45ace6e50 100644 --- a/wcfsetup/install/files/lib/system/SingletonFactory.class.php +++ b/wcfsetup/install/files/lib/system/SingletonFactory.class.php @@ -81,7 +81,7 @@ abstract class SingletonFactory */ final public static function isInitialized() { - $className = \get_called_class(); + $className = static::class; return isset(self::$__singletonObjects[$className]); } diff --git a/wcfsetup/install/files/lib/system/application/AbstractApplication.class.php b/wcfsetup/install/files/lib/system/application/AbstractApplication.class.php index 48d27eb216..534f3fdde4 100644 --- a/wcfsetup/install/files/lib/system/application/AbstractApplication.class.php +++ b/wcfsetup/install/files/lib/system/application/AbstractApplication.class.php @@ -59,7 +59,7 @@ abstract class AbstractApplication extends SingletonFactory implements IApplicat final protected function init() { if (empty($this->abbreviation)) { - $classParts = \explode('\\', \get_called_class()); + $classParts = \explode('\\', static::class); $this->abbreviation = $classParts[0]; } elseif ($this->abbreviation == 'wcf') { throw new SystemException("Unable to determine application, abbreviation is missing"); diff --git a/wcfsetup/install/files/lib/system/bbcode/highlighter/Highlighter.class.php b/wcfsetup/install/files/lib/system/bbcode/highlighter/Highlighter.class.php index 4bbb192151..c59daf4866 100644 --- a/wcfsetup/install/files/lib/system/bbcode/highlighter/Highlighter.class.php +++ b/wcfsetup/install/files/lib/system/bbcode/highlighter/Highlighter.class.php @@ -134,7 +134,7 @@ abstract class Highlighter extends SingletonFactory $reType = new Regex('\\\\?wcf\\\\system\\\\bbcode\\\\highlighter\\\\(.*)Highlighter', Regex::CASE_INSENSITIVE); return WCF::getLanguage()->get('wcf.bbcode.code.' . $reType->replace( - \strtolower(\get_class($this)), + \strtolower(static::class), '\1' ) . '.title'); } diff --git a/wcfsetup/install/files/lib/system/bulk/processing/AbstractBulkProcessableObjectType.class.php b/wcfsetup/install/files/lib/system/bulk/processing/AbstractBulkProcessableObjectType.class.php index 65547ed93a..bf23e21d9f 100644 --- a/wcfsetup/install/files/lib/system/bulk/processing/AbstractBulkProcessableObjectType.class.php +++ b/wcfsetup/install/files/lib/system/bulk/processing/AbstractBulkProcessableObjectType.class.php @@ -58,7 +58,7 @@ abstract class AbstractBulkProcessableObjectType extends AbstractObjectTypeProce */ public function getConditionHTML() { - return WCF::getTPL()->fetch($this->templateName, \explode('\\', \get_class($this))[0]); + return WCF::getTPL()->fetch($this->templateName, \explode('\\', static::class)[0]); } /** @@ -79,7 +79,7 @@ abstract class AbstractBulkProcessableObjectType extends AbstractObjectTypeProce public function getLanguageItemPrefix() { if (empty($this->languageItemPrefix)) { - $application = \explode('\\', \get_class($this))[0]; + $application = \explode('\\', static::class)[0]; $objectTypePieces = \explode('.', $this->getDecoratedObject()->objectType); $this->languageItemPrefix = $application . '.acp.' . \end($objectTypePieces) . '.bulkProcessing'; diff --git a/wcfsetup/install/files/lib/system/category/AbstractCategoryType.class.php b/wcfsetup/install/files/lib/system/category/AbstractCategoryType.class.php index 9fa53b4cab..38fa50a29f 100644 --- a/wcfsetup/install/files/lib/system/category/AbstractCategoryType.class.php +++ b/wcfsetup/install/files/lib/system/category/AbstractCategoryType.class.php @@ -132,7 +132,7 @@ abstract class AbstractCategoryType extends SingletonFactory implements ICategor */ public function getApplication() { - $classParts = \explode('\\', \get_called_class()); + $classParts = \explode('\\', static::class); return $classParts[0]; } diff --git a/wcfsetup/install/files/lib/system/database/Database.class.php b/wcfsetup/install/files/lib/system/database/Database.class.php index 8ab5bab8f6..2633d043bc 100644 --- a/wcfsetup/install/files/lib/system/database/Database.class.php +++ b/wcfsetup/install/files/lib/system/database/Database.class.php @@ -427,7 +427,7 @@ abstract class Database */ public function getDBType() { - return \get_class($this); + return static::class; } /** diff --git a/wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php b/wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php index 0672f3d446..4f7452769e 100644 --- a/wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php +++ b/wcfsetup/install/files/lib/system/database/table/column/AbstractDatabaseTableColumn.class.php @@ -139,7 +139,7 @@ abstract class AbstractDatabaseTableColumn implements IDatabaseTableColumn { if ($this->type === null) { throw new \BadMethodCallException( - "Type of the database table column " . \get_class($this) . " has not been set yet" + "Type of the database table column " . static::class . " has not been set yet" ); } diff --git a/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php index 9f03cd06e5..2542e7229c 100644 --- a/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/devtools/pip/TXmlGuiPackageInstallationPlugin.class.php @@ -415,7 +415,7 @@ XML; */ protected function getXsdFilename() { - $classNamePieces = \explode('\\', \get_class($this)); + $classNamePieces = \explode('\\', static::class); return \lcfirst(\str_replace('PackageInstallationPlugin', '', \array_pop($classNamePieces))); } diff --git a/wcfsetup/install/files/lib/system/exception/NamedUserException.class.php b/wcfsetup/install/files/lib/system/exception/NamedUserException.class.php index 143de5e89b..9f22d68ce0 100644 --- a/wcfsetup/install/files/lib/system/exception/NamedUserException.class.php +++ b/wcfsetup/install/files/lib/system/exception/NamedUserException.class.php @@ -27,7 +27,7 @@ class NamedUserException extends UserException } SessionHandler::getInstance()->disableTracking(); - $name = \get_class($this); + $name = static::class; $exceptionClassName = \mb_substr($name, \mb_strrpos($name, '\\') + 1); WCF::getTPL()->assign([ diff --git a/wcfsetup/install/files/lib/system/exception/PermissionDeniedException.class.php b/wcfsetup/install/files/lib/system/exception/PermissionDeniedException.class.php index 3448834874..b89393b622 100644 --- a/wcfsetup/install/files/lib/system/exception/PermissionDeniedException.class.php +++ b/wcfsetup/install/files/lib/system/exception/PermissionDeniedException.class.php @@ -45,11 +45,11 @@ class PermissionDeniedException extends UserException @\header('HTTP/1.1 403 Forbidden'); - $name = \get_class($this); + $name = static::class; $exceptionClassName = \mb_substr($name, \mb_strrpos($name, '\\') + 1); WCF::getTPL()->assign([ - 'name' => \get_class($this), + 'name' => static::class, 'file' => $this->getFile(), 'line' => $this->getLine(), 'message' => $this->getMessage(), diff --git a/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNode.class.php b/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNode.class.php index 76b28384cf..851c41499f 100644 --- a/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNode.class.php +++ b/wcfsetup/install/files/lib/system/html/node/AbstractHtmlNode.class.php @@ -38,6 +38,6 @@ abstract class AbstractHtmlNode implements IHtmlNode */ public function replaceTag(array $data) { - throw new \BadMethodCallException("Method replaceTag() is not supported by " . \get_class($this)); + throw new \BadMethodCallException("Method replaceTag() is not supported by " . static::class); } } diff --git a/wcfsetup/install/files/lib/system/moderation/AbstractDeletedContentProvider.class.php b/wcfsetup/install/files/lib/system/moderation/AbstractDeletedContentProvider.class.php index c25bf27a1e..25b24fb3d0 100644 --- a/wcfsetup/install/files/lib/system/moderation/AbstractDeletedContentProvider.class.php +++ b/wcfsetup/install/files/lib/system/moderation/AbstractDeletedContentProvider.class.php @@ -19,7 +19,7 @@ abstract class AbstractDeletedContentProvider extends AbstractObjectTypeProcesso */ public function getApplication() { - $classParts = \explode('\\', \get_called_class()); + $classParts = \explode('\\', static::class); return $classParts[0]; } diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php index 50e9580e3a..f5b45805a2 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractOptionPackageInstallationPlugin.class.php @@ -512,7 +512,7 @@ abstract class AbstractOptionPackageInstallationPlugin extends AbstractXMLPackag break; case 'options': - $classnamePieces = \explode('\\', \get_class($this)); + $classnamePieces = \explode('\\', static::class); $pipPrefix = \str_replace('PackageInstallationPlugin', '', \array_pop($classnamePieces)); $dataContainer->appendChildren([ diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php index 1988cd0428..24f38c70a8 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php @@ -444,7 +444,7 @@ abstract class AbstractXMLPackageInstallationPlugin extends AbstractPackageInsta */ public static function getDefaultFilename() { - $classParts = \explode('\\', \get_called_class()); + $classParts = \explode('\\', static::class); return \lcfirst(\str_replace('PackageInstallationPlugin', '', \array_pop($classParts))) . '.xml'; } diff --git a/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php b/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php index d383a9d597..e25ce54b52 100644 --- a/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php +++ b/wcfsetup/install/files/lib/system/search/AbstractSearchableObjectType.class.php @@ -28,7 +28,7 @@ abstract class AbstractSearchableObjectType extends AbstractObjectTypeProcessor */ public function getApplication() { - $classParts = \explode('\\', \get_called_class()); + $classParts = \explode('\\', static::class); return $classParts[0]; } diff --git a/wcfsetup/install/files/lib/system/tagging/AbstractTaggable.class.php b/wcfsetup/install/files/lib/system/tagging/AbstractTaggable.class.php index 57f94c4858..afbbd6769c 100644 --- a/wcfsetup/install/files/lib/system/tagging/AbstractTaggable.class.php +++ b/wcfsetup/install/files/lib/system/tagging/AbstractTaggable.class.php @@ -19,7 +19,7 @@ abstract class AbstractTaggable extends AbstractObjectTypeProcessor implements I */ public function getApplication() { - $classParts = \explode('\\', \get_called_class()); + $classParts = \explode('\\', static::class); return $classParts[0]; }