Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Config] Fix signature generation with nested attributes on PHP 8.1#43267

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,7 +122,7 @@ private function generateSignature(\ReflectionClass $class): iterable
if (\PHP_VERSION_ID >= 80000) {
$attributes = [];
foreach ($class->getAttributes() as $a) {
$attributes[] = [$a->getName(), $a->getArguments()];
$attributes[] = [$a->getName(),\PHP_VERSION_ID >= 80100 ? (string) $a :$a->getArguments()];
}
yield print_r($attributes, true);
$attributes = [];
Expand All@@ -146,7 +146,7 @@ private function generateSignature(\ReflectionClass $class): iterable
foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC | \ReflectionProperty::IS_PROTECTED) as $p) {
if (\PHP_VERSION_ID >= 80000) {
foreach ($p->getAttributes() as $a) {
$attributes[] = [$a->getName(), $a->getArguments()];
$attributes[] = [$a->getName(),\PHP_VERSION_ID >= 80100 ? (string) $a :$a->getArguments()];
}
yield print_r($attributes, true);
$attributes = [];
Expand All@@ -166,7 +166,7 @@ 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()];
$attributes[] = [$a->getName(),\PHP_VERSION_ID >= 80100 ? (string) $a :$a->getArguments()];
}
yield print_r($attributes, true);
$attributes = [];
Expand All@@ -177,7 +177,7 @@ private function generateSignature(\ReflectionClass $class): iterable
foreach ($m->getParameters() as $p) {
if (\PHP_VERSION_ID >= 80000) {
foreach ($p->getAttributes() as $a) {
$attributes[] = [$a->getName(), $a->getArguments()];
$attributes[] = [$a->getName(),\PHP_VERSION_ID >= 80100 ? (string) $a :$a->getArguments()];
}
yield print_r($attributes, true);
$attributes = [];
Expand All@@ -189,6 +189,12 @@ private function generateSignature(\ReflectionClass $class): iterable
continue;
}

if (\PHP_VERSION_ID >= 80100) {
$defaults[$p->name] = (string) $p;

continue;
}

if (!$p->isDefaultValueConstant() || $defined($p->getDefaultValueConstantName())) {
$defaults[$p->name] = $p->getDefaultValue();

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -126,6 +126,10 @@ public function provideHashedSignature(): iterable
yield [true, 0, '#[Foo]'];
}

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

yield [true, 1, 'abstract class %s'];
yield [true, 1, 'final class %s'];
yield [true, 1, 'class %s extends Exception'];
Expand All@@ -135,6 +139,11 @@ public function provideHashedSignature(): iterable
yield [true, 4, '/** pub docblock */'];
yield [true, 5, 'protected $pub = [];'];
yield [true, 5, 'public $pub = [123];'];

if (\PHP_VERSION_ID >= 80100) {
yield [true, 5, '#[Foo(new MissingClass)] public $pub = [];'];
}

yield [true, 6, '/** prot docblock */'];
yield [true, 7, 'private $prot;'];
yield [false, 8, '/** priv docblock */'];
Expand All@@ -151,6 +160,11 @@ public function provideHashedSignature(): iterable
yield [true, 13, 'protected function prot(#[Foo] $a = []) {}'];
}

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

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

Expand All@@ -162,10 +176,16 @@ public function provideHashedSignature(): iterable
yield [false, 9, 'private string $priv;'];
}

if (\PHP_VERSION_ID >= 80100) {
yield [true, 17, 'public function __construct(private $bar = new \stdClass()) {}'];
yield [true, 17, 'public function ccc($bar = new \stdClass()) {}'];
yield [true, 17, 'public function ccc($bar = new MissingClass()) {}'];
}

yield [true, 17, 'public function ccc($bar = 187) {}'];
yield [true, 17, 'public function ccc($bar = ANOTHER_ONE_THAT_WILL_NEVER_BE_DEFINED_CCCCCCCCC) {}'];
yield [true, 17, 'public function ccc($bar = parent::BOOM) {}'];
yield [true, 17, null, static function () { \define('A_CONSTANT_THAT_FOR_SURE_WILL_NEVER_BE_DEFINED_CCCCCC', 'foo'); }];
yield [\PHP_VERSION_ID < 80100, 17, null, static function () { \define('A_CONSTANT_THAT_FOR_SURE_WILL_NEVER_BE_DEFINED_CCCCCC', 'foo'); }];
}

public function testEventSubscriber()
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp