Skip to content

Commit 30f60bf

Browse files
authored
Merge pull request #3808 from paulbalandan/undefined-baseconfig-prop
Fix undefined property BaseConfig::$key
2 parents 03ec56f + 794c12f commit 30f60bf

2 files changed

Lines changed: 3 additions & 12 deletions

File tree

phpstan.neon.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ parameters:
4444
- '#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\(\)#'
4545
- '#Return type \(bool\) of method CodeIgniter\\Test\\TestLogger::log\(\) should be compatible with return type \(null\) of method Psr\\Log\\LoggerInterface::log\(\)#'
4646
- '#Unsafe usage of new static\(\)*#'
47-
- '#Access to an undefined property CodeIgniter\\Config\\BaseConfig::\$key#'
4847
parallel:
4948
processTimeout: 300.0
5049
scanDirectories:

system/Config/BaseConfig.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
namespace CodeIgniter\Config;
4141

42+
use Config\Encryption;
4243
use Config\Modules;
4344
use Config\Services;
4445
use ReflectionClass;
@@ -56,7 +57,6 @@
5657
*/
5758
class BaseConfig
5859
{
59-
6060
/**
6161
* An optional array of classes that will act as Registrars
6262
* for rapidly setting config class properties.
@@ -90,15 +90,15 @@ public function __construct()
9090
static::$moduleConfig = config('Modules');
9191

9292
$properties = array_keys(get_object_vars($this));
93-
$prefix = get_class($this);
93+
$prefix = static::class;
9494
$slashAt = strrpos($prefix, '\\');
9595
$shortPrefix = strtolower(substr($prefix, $slashAt === false ? 0 : $slashAt + 1));
9696

9797
foreach ($properties as $property)
9898
{
9999
$this->initEnvValue($this->$property, $property, $prefix, $shortPrefix);
100100

101-
if ($shortPrefix === 'encryption' && $property === 'key')
101+
if ($this instanceof Encryption && $property === 'key')
102102
{
103103
// Handle hex2bin prefix
104104
if (strpos($this->$property, 'hex2bin:') === 0)
@@ -116,8 +116,6 @@ public function __construct()
116116
$this->registerProperties();
117117
}
118118

119-
//--------------------------------------------------------------------
120-
121119
/**
122120
* Initialization an environment-specific configuration setting
123121
*
@@ -159,8 +157,6 @@ protected function initEnvValue(&$property, string $name, string $prefix, string
159157
return $property;
160158
}
161159

162-
//--------------------------------------------------------------------
163-
164160
/**
165161
* Retrieve an environment-specific configuration setting
166162
*
@@ -189,8 +185,6 @@ protected function getEnvValue(string $property, string $prefix, string $shortPr
189185
}
190186
}
191187

192-
//--------------------------------------------------------------------
193-
194188
/**
195189
* Provides external libraries a simple way to register one or more
196190
* options into a config file.
@@ -251,6 +245,4 @@ protected function registerProperties()
251245
}
252246
}
253247
}
254-
255-
//--------------------------------------------------------------------
256248
}

0 commit comments

Comments
 (0)