Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 3 additions & 11 deletions system/Config/BaseConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

namespace CodeIgniter\Config;

use Config\Encryption;
use Config\Modules;
use Config\Services;
use ReflectionClass;
Expand All @@ -56,7 +57,6 @@
*/
class BaseConfig
{

/**
* An optional array of classes that will act as Registrars
* for rapidly setting config class properties.
Expand Down Expand Up @@ -90,15 +90,15 @@ 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));

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

if ($shortPrefix === 'encryption' && $property === 'key')
if ($this instanceof Encryption && $property === 'key')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, parent should not know about the child implementation, but probably that next refactor, like have abstract method that called and overridden in child.

{
// Handle hex2bin prefix
if (strpos($this->$property, 'hex2bin:') === 0)
Expand All @@ -116,8 +116,6 @@ public function __construct()
$this->registerProperties();
}

//--------------------------------------------------------------------

/**
* Initialization an environment-specific configuration setting
*
Expand Down Expand Up @@ -159,8 +157,6 @@ protected function initEnvValue(&$property, string $name, string $prefix, string
return $property;
}

//--------------------------------------------------------------------

/**
* Retrieve an environment-specific configuration setting
*
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -251,6 +245,4 @@ protected function registerProperties()
}
}
}

//--------------------------------------------------------------------
}