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

Commitda0e2f9

Browse files
bug#35870 [ErrorHandler] fix parsing static return type on interface method annotation (alekitto)
This PR was merged into the 4.4 branch.Discussion----------[ErrorHandler] fix parsing static return type on interface method annotation| Q | A| ------------- | ---| Branch? | 4.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Tickets |Fix#35836| License | MITAs suggested in the issue, the regex has been adapted to capture the return type, then it will be checked while determining if the method to be implemented should be static or just returns an instance of `static`.Commits-------55734a2 [ErrorHandler] fix parsing static return type on interface method annotation (fix#35836)
2 parents3057c68 +55734a2 commitda0e2f9

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

‎src/Symfony/Component/ErrorHandler/DebugClassLoader.php‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,17 +428,17 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array
428428
}
429429
}
430430

431-
if ($refl->isInterface() &&false !==strpos($doc,'method') &&preg_match_all('#\n \* @method\s+(static\s+)?+(?:[\w\|&\[\]\\\]+\s+)?(\w+(?:\s*\([^\)]*\))?)+(.+?([[:punct:]]\s*)?)?(?=\r?\n \*(?: @|/$|\r?\n))#',$doc,$notice,PREG_SET_ORDER)) {
431+
if ($refl->isInterface() &&false !==strpos($doc,'method') &&preg_match_all('#\n \* @method\s+(static\s+)?+([\w\|&\[\]\\\]+\s+)?(\w+(?:\s*\([^\)]*\))?)+(.+?([[:punct:]]\s*)?)?(?=\r?\n \*(?: @|/$|\r?\n))#',$doc,$notice,PREG_SET_ORDER)) {
432432
foreach ($noticeas$method) {
433-
$static ='' !==$method[1];
434-
$name =$method[2];
435-
$description =$method[3] ??null;
433+
$static ='' !==$method[1] && !empty($method[2]);
434+
$name =$method[3];
435+
$description =$method[4] ??null;
436436
if (false ===strpos($name,'(')) {
437437
$name .='()';
438438
}
439439
if (null !==$description) {
440440
$description =trim($description);
441-
if (!isset($method[4])) {
441+
if (!isset($method[5])) {
442442
$description .='.';
443443
}
444444
}

‎src/Symfony/Component/ErrorHandler/Tests/DebugClassLoaderTest.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ class_exists('Test\\'.ExtendsVirtual::class, true);
325325
restore_error_handler();
326326

327327
$this->assertSame([
328+
'Class "Test\Symfony\Component\ErrorHandler\Tests\ExtendsVirtualParent" should implement method "Symfony\Component\ErrorHandler\Tests\Fixtures\VirtualInterface::staticReturningMethod()".',
328329
'Class "Test\Symfony\Component\ErrorHandler\Tests\ExtendsVirtualParent" should implement method "Symfony\Component\ErrorHandler\Tests\Fixtures\VirtualInterface::sameLineInterfaceMethodNoBraces()".',
329330
'Class "Test\Symfony\Component\ErrorHandler\Tests\ExtendsVirtualParent" should implement method "Symfony\Component\ErrorHandler\Tests\Fixtures\VirtualInterface::newLineInterfaceMethod()": Some description!',
330331
'Class "Test\Symfony\Component\ErrorHandler\Tests\ExtendsVirtualParent" should implement method "Symfony\Component\ErrorHandler\Tests\Fixtures\VirtualInterface::newLineInterfaceMethodNoBraces()": Description.',

‎src/Symfony/Component/ErrorHandler/Tests/Fixtures/VirtualInterface.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
/**
66
* @method string interfaceMethod()
7+
* @method static staticReturningMethod()
78
* @method sameLineInterfaceMethod($arg)
89
* @method sameLineInterfaceMethodNoBraces
910
*
@@ -25,7 +26,7 @@
2526
*
2627
* Static
2728
* @method static Foo&Bar staticMethod()
28-
* @method static staticMethodNoBraces
29+
* @method staticmixedstaticMethodNoBraces
2930
* @method static \stdClass staticMethodTyped(int $arg) Description
3031
* @method static \stdClass[] staticMethodTypedNoBraces
3132
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp