Skip to content

PHP 8.4 | File::getMemberProperties(): add support for abstract properties #1184

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -1851,6 +1851,7 @@ public function getMethodProperties($stackPtr)
* 'is_static' => boolean, // TRUE if the static keyword was found.
* 'is_readonly' => boolean, // TRUE if the readonly keyword was found.
* 'is_final' => boolean, // TRUE if the final keyword was found.
* 'is_abstract' => boolean, // TRUE if the abstract keyword was found.
* 'type' => string, // The type of the var (empty if no type specified).
* 'type_token' => integer|false, // The stack pointer to the start of the type
* // or FALSE if there is no type.
Expand Down Expand Up @@ -1921,6 +1922,7 @@ public function getMemberProperties($stackPtr)
T_VAR => T_VAR,
T_READONLY => T_READONLY,
T_FINAL => T_FINAL,
T_ABSTRACT => T_ABSTRACT,
];

$valid += Tokens::$scopeModifiers;
Expand All @@ -1932,6 +1934,7 @@ public function getMemberProperties($stackPtr)
$isStatic = false;
$isReadonly = false;
$isFinal = false;
$isAbstract = false;

$startOfStatement = $this->findPrevious(
[
Expand Down Expand Up @@ -1979,6 +1982,9 @@ public function getMemberProperties($stackPtr)
case T_FINAL:
$isFinal = true;
break;
case T_ABSTRACT:
$isAbstract = true;
break;
}//end switch
}//end for

Expand Down Expand Up @@ -2037,6 +2043,7 @@ public function getMemberProperties($stackPtr)
'is_static' => $isStatic,
'is_readonly' => $isReadonly,
'is_final' => $isFinal,
'is_abstract' => $isAbstract,
'type' => $type,
'type_token' => $typeToken,
'type_end_token' => $typeEndToken,
Expand Down
24 changes: 24 additions & 0 deletions tests/Core/Files/File/GetMemberPropertiesTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,27 @@ class AsymVisibility {
/* testPHP84IllegalAsymPublicProtectedSetStaticProperty */
public protected(set) static mixed $prop10;
}

abstract class WithAbstractProperties {
/* testPHP84AbstractPublicTypedProp */
abstract public string $val1 { get; }
/* testPHP84AbstractProtectedTypedProp */
abstract protected Union|Type $val2 { set; }
/* testPHP84AbstractMiddleTypedProp */
public abstract Intersection&Type $val3 { get; }
/* testPHP84AbstractImplicitVisibilityTypedProp */
abstract int $val4 { set; }
/* testPHP84AbstractImplicitVisibilityProp */
abstract $val5 { get; }
/* testPHP84AbstractNullableTypedProp */
abstract public ?string $val6 { set; }
/* testPHP84AbstractComplexTypedProp */
abstract protected (Foo&\Bar)|false $val7 { get; }

/* testPHP84IllegalAbstractPrivateProp */
private abstract string $val8 { get; }
/* testPHP84IllegalAbstractReadonlyProp */
public readonly abstract string $val9 { get; }
/* testPHP84IllegalAbstractStaticProp */
public abstract static string $val10 { get; }
}
Loading
Loading