fix: resolve RedisCache array offset error and improve discovery diagnostics

- Fix RedisCache driver to handle MGET failures gracefully with fallback
- Add comprehensive discovery context comparison debug tools
- Identify root cause: WEB context discovery missing 166 items vs CLI
- WEB context missing RequestFactory class entirely (52 vs 69 commands)
- Improved exception handling with detailed binding diagnostics
This commit is contained in:
2025-09-12 20:05:18 +02:00
parent 8040d3e7a5
commit e30753ba0e
46990 changed files with 10789682 additions and 89639 deletions

View File

@@ -19,12 +19,15 @@ final readonly class ConfigValidator
/**
* Validate selected environment variables and return a list of issues.
* Each issue contains: key, issue, severity, recommendation.
* @return array<int, array<string, string>>
*/
public function validate(): array
{
/** @var array<int, array<string, string>> */
$issues = [];
// APP_ENV validation
/** @var array<int, string> */
$allowedEnvs = ['development', 'testing', 'production'];
$appEnv = $this->env->getString(EnvKey::APP_ENV, 'production');
if (! in_array($appEnv, $allowedEnvs, true)) {
@@ -76,14 +79,16 @@ final readonly class ConfigValidator
}
// Rate limit values if present: must be non-negative
foreach ([
/** @var array<int, string> */
$rateKeys = [
'RATE_LIMIT_DEFAULT',
'RATE_LIMIT_WINDOW',
'RATE_LIMIT_AUTH',
'RATE_LIMIT_AUTH_WINDOW',
'RATE_LIMIT_API',
'RATE_LIMIT_API_WINDOW',
] as $rateKey) {
];
foreach ($rateKeys as $rateKey) {
if ($this->env->has($rateKey)) {
$value = (int) $this->env->get($rateKey);
if ($value < 0) {
@@ -102,6 +107,7 @@ final readonly class ConfigValidator
/**
* Validate and log issues. Returns the list of issues for optional handling.
* @return array<int, array<string, string>>
*/
public function validateAndReport(): array
{

View File

@@ -10,6 +10,9 @@ use BackedEnum;
final readonly class Environment
{
/**
* @param array<string, mixed> $variables
*/
public function __construct(
private array $variables = []
) {
@@ -91,6 +94,9 @@ final readonly class Environment
return $this->get($key) !== null;
}
/**
* @return array<string, mixed>
*/
public function all(): array
{
return array_merge(
@@ -162,6 +168,9 @@ final readonly class Environment
return new self($variables);
}
/**
* @param array<string, mixed> $variables
*/
public function withVariables(array $variables): self
{
return new self(array_merge($this->variables, $variables));

View File

@@ -9,6 +9,7 @@ enum EnvironmentType: string
case DEV = 'development';
case STAGING = 'staging';
case PROD = 'production';
case TESTING = 'testing';
public function isProduction(): bool
{
@@ -25,6 +26,11 @@ enum EnvironmentType: string
return $this === self::STAGING;
}
public function isTesting(): bool
{
return $this === self::TESTING;
}
public function isDebugEnabled(): bool
{
return $this === self::DEV;
@@ -42,6 +48,7 @@ enum EnvironmentType: string
return match(strtolower($envValue)) {
'production', 'prod' => self::PROD,
'staging', 'stage' => self::STAGING,
'testing', 'test' => self::TESTING,
'development', 'dev', 'local' => self::DEV,
default => self::DEV
};