From: Alexander Ebert Date: Sat, 17 Feb 2018 09:42:46 +0000 (+0100) Subject: Using a static local variable to hide internals X-Git-Tag: 3.1.0~24^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2e58d307deaca604e10c560f42fb91781e86a479;p=GitHub%2FWoltLab%2FWCF.git Using a static local variable to hide internals --- diff --git a/wcfsetup/install/files/lib/data/DatabaseObject.class.php b/wcfsetup/install/files/lib/data/DatabaseObject.class.php index 54b7f2e7fe..3c85e17fec 100644 --- a/wcfsetup/install/files/lib/data/DatabaseObject.class.php +++ b/wcfsetup/install/files/lib/data/DatabaseObject.class.php @@ -41,24 +41,6 @@ abstract class DatabaseObject implements IStorableObject { */ protected static $sortOrder = null; - /** - * The list of derived database table names based on the class name. - * - * WARNING: This is strictly an internal lookup table. DO NOT USE IT. - * - * @var string[] - */ - protected static $_derivedDatabaseTableName = []; - - /** - * The list of derived database table aliases based on the class name. - * - * WARNING: This is strictly an internal lookup table. DO NOT USE IT. - * - * @var string[] - */ - protected static $_derivedDatabaseTableAlias = []; - /** * object data * @var array @@ -152,11 +134,12 @@ abstract class DatabaseObject implements IStorableObject { return $classParts[0].WCF_N.'_'.static::$databaseTableName; } - if (!isset(self::$_derivedDatabaseTableName[$className])) { - self::$_derivedDatabaseTableName[$className] = $classParts[0].WCF_N.'_'.strtolower(implode('_', preg_split('~(?=[A-Z](?=[a-z]))~', array_pop($classParts), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY))); + static $databaseTableNames = []; + if (!isset($databaseTableNames[$className])) { + $databaseTableNames[$className] = $classParts[0].WCF_N.'_'.strtolower(implode('_', preg_split('~(?=[A-Z](?=[a-z]))~', array_pop($classParts), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY))); } - return self::$_derivedDatabaseTableName[$className]; + return $databaseTableNames[$className]; } /** @@ -168,12 +151,13 @@ abstract class DatabaseObject implements IStorableObject { } $className = get_called_class(); - if (!isset(self::$_derivedDatabaseTableAlias[$className])) { + static $databaseTableAliases = []; + if (!isset($databaseTableAliases[$className])) { $classParts = explode('\\', $className); - self::$_derivedDatabaseTableAlias[$className] = strtolower(implode('_', preg_split('~(?=[A-Z](?=[a-z]))~', array_pop($classParts), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY))); + $databaseTableAliases[$className] = strtolower(implode('_', preg_split('~(?=[A-Z](?=[a-z]))~', array_pop($classParts), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY))); } - return self::$_derivedDatabaseTableAlias[$className]; + return $databaseTableAliases[$className]; } /**