Enable Discovery debug logging for production troubleshooting

- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
2025-08-11 20:13:26 +02:00
parent 59fd3dd3b1
commit 55a330b223
3683 changed files with 2956207 additions and 16948 deletions

View File

@@ -0,0 +1,64 @@
<?php
declare(strict_types=1);
namespace App\Framework\Quality\PHPStan\Rules;
use PhpParser\Node;
use PhpParser\Node\Expr\New_;
use PHPStan\Analyser\Scope;
use PHPStan\Rules\Rule;
use PHPStan\Rules\RuleErrorBuilder;
/**
* @implements Rule<New_>
*/
final class UseFrameworkAbstractionsRule implements Rule
{
/** @var array<string, string> */
private array $forbiddenClasses = [
'DateTime' => 'Use App\\Framework\\DateTime\\DateTime instead',
'DateTimeImmutable' => 'Use App\\Framework\\DateTime\\DateTime instead',
'PDO' => 'Use App\\Framework\\Database\\ConnectionInterface instead',
'mysqli' => 'Use App\\Framework\\Database\\ConnectionInterface instead',
'Redis' => 'Use App\\Framework\\Cache\\CacheDriver instead',
'GuzzleHttp\\Client' => 'Use App\\Framework\\HttpClient\\HttpClient instead',
'Predis\\Client' => 'Use App\\Framework\\Cache\\CacheDriver instead',
];
public function getNodeType(): string
{
return New_::class;
}
public function processNode(Node $node, Scope $scope): array
{
if (! $node instanceof New_) {
return [];
}
if (! $node->class instanceof Node\Name) {
return [];
}
$className = $node->class->toString();
// Skip if we're already in Framework layer (allow direct usage there)
$currentClass = $scope->getClassReflection()?->getName() ?? '';
if (str_starts_with($currentClass, 'App\\Framework\\')) {
return [];
}
if (! isset($this->forbiddenClasses[$className])) {
return [];
}
return [
RuleErrorBuilder::message(sprintf(
'Direct instantiation of %s is forbidden: %s',
$className,
$this->forbiddenClasses[$className]
))->tip('Use dependency injection to get the framework abstraction')->build(),
];
}
}