8000 [Config] fix tracking attributes in ReflectionClassResource by nicolas-grekas · Pull Request #41644 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Config] fix tracking attributes in ReflectionClassResource #41644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2021
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
[Config] fix tracking attributes in ReflectionClassResource
  • Loading branch information
nicolas-grekas committed Jun 9, 2021
commit 7ad82474223e5951db3f9844b07a2afe8d16a9cd
33 changes: 33 additions & 0 deletions src/Symfony/Component/Config/Resource/ReflectionClassResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ private function computeHash(): string

private function generateSignature(\ReflectionClass $class): iterable
{
if (\PHP_VERSION_ID >= 80000) {
$attributes = [];
foreach ($class->getAttributes() as $a) {
$attributes[] = [$a->getName(), $a->getArguments()];
}
yield print_r($attributes, true);
$attributes = [];
}

yield $class->getDocComment();
yield (int) $class->isFinal();
yield (int) $class->isAbstract();
Expand All @@ -135,6 +144,14 @@ private function generateSignature(\ReflectionClass $class): iterable
$defaults = $class->getDefaultProperties();

foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) {
if (\PHP_VERSION_ID >= 80000) {
foreach ($p->getAttributes() a 8000 s $a) {
$attributes[] = [$a->getName(), $a->getArguments()];
}
yield print_r($attributes, true);
$attributes = [];
}

yield $p->getDocComment();
yield $p->isDefault() ? '<default>' : '';
yield $p->isPublic() ? 'public' : 'protected';
Expand All @@ -145,9 +162,25 @@ private function generateSignature(\ReflectionClass $class): iterable
}

foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $m) {
if (\PHP_VERSION_ID >= 80000) {
foreach ($m->getAttributes() as $a) {
$attributes[] = [$a->getName(), $a->getArguments()];
}
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(), $a->getArguments()];
}
yield print_r($attributes, true);
$attributes = [];
}

if (!$p->isDefaultValueAvailable()) {
$defaults[$p->name] = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ public function provideHashedSignature(): iterable
{
yield [false, 0, "// line change\n\n"];
yield [true, 0, '/** class docblock */'];

if (\PHP_VERSION_ID >= 80000) {
yield [true, 0, '#[Foo]'];
}

yield [true, 1, 'abstract class %s'];
yield [true, 1, 'final class %s'];
yield [true, 1, 'class %s extends Exception'];
Expand All @@ -140,6 +145,12 @@ public function provideHashedSignature(): iterable
yield [false, 11, "public function pub(\$arg = null) {\nreturn 123;\n}"];
yield [true, 12, '/** prot docblock */'];
yield [true, 13, 'protected function prot($a = [123]) {}'];

if (\PHP_VERSION_ID >= 80000) {
yield [true, 13, '#[Foo] protected function prot($a = []) {}'];
yield [true, 13, 'protected function prot(#[Foo] $a = []) {}'];
}

yield [false, 14, '/** priv docblock */'];
yield [false, 15, ''];

Expand Down
0