Skip to content

Commit 6ae57bd

Browse files
authored
Merge pull request #699 from PHPCSStandards/feature/objectdeclarations-findextendedclass-add-extra-tests
BCFile/ObjectDeclarations::findExtendedClassName(): add a few extra tests
2 parents f7eb16f + f20a650 commit 6ae57bd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Tests/BackCompat/BCFile/FindExtendedClassNameTest.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ class testFECNClassThatImplementsAndExtends implements InterfaceA, InterfaceB ex
4747
/* testInterfaceMultiExtends */
4848
interface Multi extends \Package\FooInterface, \BarInterface {};
4949

50+
/* testExtendedReadonlyAnonClass */
51+
$anon = new readonly class() extends \Fully\Qualified\MyClass {};
52+
53+
/* testExtendedAnonClassWithAttributes */
54+
$anon = new #[SomeAttribute] class( $p ) extends Partially\Qualified\MyClass {};
55+
5056
/* testMissingExtendsName */
5157
class testMissingExtendsName extends { /* missing classname */ } // Intentional parse error.
5258

Tests/BackCompat/BCFile/FindExtendedClassNameTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ public static function dataExtendedClass()
161161
'identifier' => '/* testInterfaceMultiExtends */',
162162
'expected' => '\Package\FooInterface',
163163
],
164+
'readonly anon class extends fully qualified class' => [
165+
'identifier' => '/* testExtendedReadonlyAnonClass */',
166+
'expected' => '\Fully\Qualified\MyClass',
167+
],
168+
'anon class with attribute extends partially qualified class' => [
169+
'identifier' => '/* testExtendedAnonClassWithAttributes */',
170+
'expected' => 'Partially\Qualified\MyClass',
171+
],
164172
'parse error - extends keyword, but no class name' => [
165173
'identifier' => '/* testMissingExtendsName */',
166174
'expected' => false,

0 commit comments

Comments
 (0)