N°6934 - Symfony 6.4 - upgrade Symfony bundles to 6.4 (#580)

* Update Symfony lib to version ~6.4.0
* Update code missing return type
* Add an iTop general configuration entry to store application secret (Symfony mandatory parameter)
* Use dependency injection in ExceptionListener & UserProvider classes
This commit is contained in:
bdalsass
2023-12-05 13:56:56 +01:00
committed by GitHub
parent 863ab4560c
commit 27ce51ab07
1392 changed files with 44869 additions and 27799 deletions

View File

@@ -22,11 +22,11 @@ use Symfony\Contracts\Service\ServiceSubscriberInterface;
*/
class ReflectionClassResource implements SelfCheckingResourceInterface
{
private $files = [];
private $className;
private $classReflector;
private $excludedVendors = [];
private $hash;
private array $files = [];
private string $className;
private \ReflectionClass $classReflector;
private array $excludedVendors = [];
private string $hash;
public function __construct(\ReflectionClass $classReflector, array $excludedVendors = [])
{
@@ -35,12 +35,9 @@ class ReflectionClassResource implements SelfCheckingResourceInterface
$this->excludedVendors = $excludedVendors;
}
/**
* {@inheritdoc}
*/
public function isFresh(int $timestamp): bool
{
if (null === $this->hash) {
if (!isset($this->hash)) {
$this->hash = $this->computeHash();
$this->loadFiles($this->classReflector);
}
@@ -68,7 +65,7 @@ class ReflectionClassResource implements SelfCheckingResourceInterface
*/
public function __sleep(): array
{
if (null === $this->hash) {
if (!isset($this->hash)) {
$this->hash = $this->computeHash();
$this->loadFiles($this->classReflector);
}
@@ -76,7 +73,7 @@ class ReflectionClassResource implements SelfCheckingResourceInterface
return ['files', 'className', 'hash'];
}
private function loadFiles(\ReflectionClass $class)
private function loadFiles(\ReflectionClass $class): void
{
foreach ($class->getInterfaces() as $v) {
$this->loadFiles($v);
@@ -102,15 +99,13 @@ class ReflectionClassResource implements SelfCheckingResourceInterface
private function computeHash(): string
{
if (null === $this->classReflector) {
try {
$this->classReflector = new \ReflectionClass($this->className);
} catch (\ReflectionException $e) {
// the class does not exist anymore
return false;
}
try {
$this->classReflector ??= new \ReflectionClass($this->className);
} catch (\ReflectionException) {
// the class does not exist anymore
return false;
}
$hash = hash_init('md5');
$hash = hash_init('xxh128');
foreach ($this->generateSignature($this->classReflector) as $info) {
hash_update($hash, $info);
@@ -121,14 +116,12 @@ class ReflectionClassResource implements SelfCheckingResourceInterface
private function generateSignature(\ReflectionClass $class): iterable
{
if (\PHP_VERSION_ID >= 80000) {
$attributes = [];
foreach ($class->getAttributes() as $a) {
$attributes[] = [$a->getName(), \PHP_VERSION_ID >= 80100 ? (string) $a : $a->getArguments()];
}
yield print_r($attributes, true);
$attributes = [];
$attributes = [];
foreach ($class->getAttributes() as $a) {
$attributes[] = [$a->getName(), (string) $a];
}
yield print_r($attributes, true);
$attributes = [];
yield $class->getDocComment();
yield (int) $class->isFinal();
@@ -146,13 +139,11 @@ class ReflectionClassResource implements SelfCheckingResourceInterface
$defaults = $class->getDefaultProperties();
foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) {
if (\PHP_VERSION_ID >= 80000) {
foreach ($p->getAttributes() as $a) {
$attributes[] = [$a->getName(), \PHP_VERSION_ID >= 80100 ? (string) $a : $a->getArguments()];
}
yield print_r($attributes, true);
$attributes = [];
foreach ($p->getAttributes() as $a) {
$attributes[] = [$a->getName(), (string) $a];
}
yield print_r($attributes, true);
$attributes = [];
yield $p->getDocComment();
yield $p->isDefault() ? '<default>' : '';
@@ -163,27 +154,20 @@ class ReflectionClassResource implements SelfCheckingResourceInterface
}
}
$defined = \Closure::bind(static function ($c) { return \defined($c); }, null, $class->name);
foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $m) {
if (\PHP_VERSION_ID >= 80000) {
foreach ($m->getAttributes() as $a) {
$attributes[] = [$a->getName(), \PHP_VERSION_ID >= 80100 ? (string) $a : $a->getArguments()];
foreach ($m->getAttributes() as $a) {
$attributes[] = [$a->getName(), (string) $a];
}
yield print_r($attributes, true);
$attributes = [];
$defaults = [];
foreach ($m->getParameters() as $p) {
foreach ($p->getAttributes() as $a) {
$attributes[] = [$a->getName(), (string) $a];
}
yield print_r($attributes, true);
$attributes = [];
}
$defaults = [];
$parametersWithUndefinedConstants = [];
foreach ($m->getParameters() as $p) {
if (\PHP_VERSION_ID >= 80000) {
foreach ($p->getAttributes() as $a) {
$attributes[] = [$a->getName(), \PHP_VERSION_ID >= 80100 ? (string) $a : $a->getArguments()];
}
yield print_r($attributes, true);
$attributes = [];
}
if (!$p->isDefaultValueAvailable()) {
$defaults[$p->name] = null;
@@ -191,55 +175,10 @@ class ReflectionClassResource implements SelfCheckingResourceInterface
continue;
}
if (\PHP_VERSION_ID >= 80100) {
$defaults[$p->name] = (string) $p;
continue;
}
if (!$p->isDefaultValueConstant() || $defined($p->getDefaultValueConstantName())) {
$defaults[$p->name] = $p->getDefaultValue();
continue;
}
$defaults[$p->name] = $p->getDefaultValueConstantName();
$parametersWithUndefinedConstants[$p->name] = true;
}
if (!$parametersWithUndefinedConstants) {
yield preg_replace('/^ @@.*/m', '', $m);
} else {
$t = $m->getReturnType();
$stack = [
$m->getDocComment(),
$m->getName(),
$m->isAbstract(),
$m->isFinal(),
$m->isStatic(),
$m->isPublic(),
$m->isPrivate(),
$m->isProtected(),
$m->returnsReference(),
$t instanceof \ReflectionNamedType ? ((string) $t->allowsNull()).$t->getName() : (string) $t,
];
foreach ($m->getParameters() as $p) {
if (!isset($parametersWithUndefinedConstants[$p->name])) {
$stack[] = (string) $p;
} else {
$t = $p->getType();
$stack[] = $p->isOptional();
$stack[] = $t instanceof \ReflectionNamedType ? ((string) $t->allowsNull()).$t->getName() : (string) $t;
$stack[] = $p->isPassedByReference();
$stack[] = $p->isVariadic();
$stack[] = $p->getName();
}
}
yield implode(',', $stack);
$defaults[$p->name] = (string) $p;
}
yield preg_replace('/^ @@.*/m', '', $m);
yield print_r($defaults, true);
}