Skip to content

Commit df03d8a

Browse files
authored
Merge pull request #1184 from PHPCSStandards/php-8.4/file-getmemberproperties-support-abstract-properties
PHP 8.4 | File::getMemberProperties(): add support for `abstract` properties
2 parents 916eb08 + 3bf028e commit df03d8a

File tree

3 files changed

+291
-0
lines changed

3 files changed

+291
-0
lines changed

src/Files/File.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,7 @@ public function getMethodProperties($stackPtr)
18511851
* 'is_static' => boolean, // TRUE if the static keyword was found.
18521852
* 'is_readonly' => boolean, // TRUE if the readonly keyword was found.
18531853
* 'is_final' => boolean, // TRUE if the final keyword was found.
1854+
* 'is_abstract' => boolean, // TRUE if the abstract keyword was found.
18541855
* 'type' => string, // The type of the var (empty if no type specified).
18551856
* 'type_token' => integer|false, // The stack pointer to the start of the type
18561857
* // or FALSE if there is no type.
@@ -1921,6 +1922,7 @@ public function getMemberProperties($stackPtr)
19211922
T_VAR => T_VAR,
19221923
T_READONLY => T_READONLY,
19231924
T_FINAL => T_FINAL,
1925+
T_ABSTRACT => T_ABSTRACT,
19241926
];
19251927

19261928
$valid += Tokens::$scopeModifiers;
@@ -1932,6 +1934,7 @@ public function getMemberProperties($stackPtr)
19321934
$isStatic = false;
19331935
$isReadonly = false;
19341936
$isFinal = false;
1937+
$isAbstract = false;
19351938

19361939
$startOfStatement = $this->findPrevious(
19371940
[
@@ -1979,6 +1982,9 @@ public function getMemberProperties($stackPtr)
19791982
case T_FINAL:
19801983
$isFinal = true;
19811984
break;
1985+
case T_ABSTRACT:
1986+
$isAbstract = true;
1987+
break;
19821988
}//end switch
19831989
}//end for
19841990

@@ -2037,6 +2043,7 @@ public function getMemberProperties($stackPtr)
20372043
'is_static' => $isStatic,
20382044
'is_readonly' => $isReadonly,
20392045
'is_final' => $isFinal,
2046+
'is_abstract' => $isAbstract,
20402047
'type' => $type,
20412048
'type_token' => $typeToken,
20422049
'type_end_token' => $typeEndToken,

tests/Core/Files/File/GetMemberPropertiesTest.inc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,27 @@ class AsymVisibility {
401401
/* testPHP84IllegalAsymPublicProtectedSetStaticProperty */
402402
public protected(set) static mixed $prop10;
403403
}
404+
405+
abstract class WithAbstractProperties {
406+
/* testPHP84AbstractPublicTypedProp */
407+
abstract public string $val1 { get; }
408+
/* testPHP84AbstractProtectedTypedProp */
409+
abstract protected Union|Type $val2 { set; }
410+
/* testPHP84AbstractMiddleTypedProp */
411+
public abstract Intersection&Type $val3 { get; }
412+
/* testPHP84AbstractImplicitVisibilityTypedProp */
413+
abstract int $val4 { set; }
414+
/* testPHP84AbstractImplicitVisibilityProp */
415+
abstract $val5 { get; }
416+
/* testPHP84AbstractNullableTypedProp */
417+
abstract public ?string $val6 { set; }
418+
/* testPHP84AbstractComplexTypedProp */
419+
abstract protected (Foo&\Bar)|false $val7 { get; }
420+
421+
/* testPHP84IllegalAbstractPrivateProp */
422+
private abstract string $val8 { get; }
423+
/* testPHP84IllegalAbstractReadonlyProp */
424+
public readonly abstract string $val9 { get; }
425+
/* testPHP84IllegalAbstractStaticProp */
426+
public abstract static string $val10 { get; }
427+
}

0 commit comments

Comments
 (0)