From 794c12f0ad0605661588c257eb71355908c714e7 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Sun, 25 Oct 2020 00:42:09 +0800 Subject: [PATCH] Fix undefined property BaseConfig::$key --- phpstan.neon.dist | 1 - system/Config/BaseConfig.php | 14 +++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 8ca27d612c09..637f507a0f9c 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -45,7 +45,6 @@ parameters: - '#Return type \(bool\) of method CodeIgniter\\HTTP\\Files\\UploadedFile::move\(\) should be compatible with return type \(CodeIgniter\\Files\\File\) of method CodeIgniter\\Files\\File::move\(\)#' - '#Return type \(bool\) of method CodeIgniter\\Test\\TestLogger::log\(\) should be compatible with return type \(null\) of method Psr\\Log\\LoggerInterface::log\(\)#' - '#Unsafe usage of new static\(\)*#' - - '#Access to an undefined property CodeIgniter\\Config\\BaseConfig::\$key#' parallel: processTimeout: 300.0 scanDirectories: diff --git a/system/Config/BaseConfig.php b/system/Config/BaseConfig.php index a4c781859336..fc3f6a13cd7e 100644 --- a/system/Config/BaseConfig.php +++ b/system/Config/BaseConfig.php @@ -39,6 +39,7 @@ namespace CodeIgniter\Config; +use Config\Encryption; use Config\Modules; use Config\Services; use ReflectionClass; @@ -56,7 +57,6 @@ */ class BaseConfig { - /** * An optional array of classes that will act as Registrars * for rapidly setting config class properties. @@ -90,7 +90,7 @@ public function __construct() static::$moduleConfig = config('Modules'); $properties = array_keys(get_object_vars($this)); - $prefix = get_class($this); + $prefix = static::class; $slashAt = strrpos($prefix, '\\'); $shortPrefix = strtolower(substr($prefix, $slashAt === false ? 0 : $slashAt + 1)); @@ -98,7 +98,7 @@ public function __construct() { $this->initEnvValue($this->$property, $property, $prefix, $shortPrefix); - if ($shortPrefix === 'encryption' && $property === 'key') + if ($this instanceof Encryption && $property === 'key') { // Handle hex2bin prefix if (strpos($this->$property, 'hex2bin:') === 0) @@ -116,8 +116,6 @@ public function __construct() $this->registerProperties(); } - //-------------------------------------------------------------------- - /** * Initialization an environment-specific configuration setting * @@ -159,8 +157,6 @@ protected function initEnvValue(&$property, string $name, string $prefix, string return $property; } - //-------------------------------------------------------------------- - /** * Retrieve an environment-specific configuration setting * @@ -189,8 +185,6 @@ protected function getEnvValue(string $property, string $prefix, string $shortPr } } - //-------------------------------------------------------------------- - /** * Provides external libraries a simple way to register one or more * options into a config file. @@ -251,6 +245,4 @@ protected function registerProperties() } } } - - //-------------------------------------------------------------------- }