Skip to content

PHP 8.4 | Report final properties in File::getMemberProperties() #834

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

Merged
merged 7 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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
9 changes: 8 additions & 1 deletion src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -1845,6 +1845,7 @@ public function getMethodProperties($stackPtr)
* 'scope_specified' => boolean, // TRUE if the scope was explicitly specified.
* '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.
* '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 @@ -1917,6 +1918,7 @@ public function getMemberProperties($stackPtr)
T_STATIC => T_STATIC,
T_VAR => T_VAR,
T_READONLY => T_READONLY,
T_FINAL => T_FINAL,
];

$valid += Tokens::$emptyTokens;
Expand All @@ -1925,6 +1927,7 @@ public function getMemberProperties($stackPtr)
$scopeSpecified = false;
$isStatic = false;
$isReadonly = false;
$isFinal = false;

$startOfStatement = $this->findPrevious(
[
Expand Down Expand Up @@ -1960,7 +1963,10 @@ public function getMemberProperties($stackPtr)
case T_READONLY:
$isReadonly = true;
break;
}
case T_FINAL:
$isFinal = true;
break;
}//end switch
}//end for

$type = '';
Expand Down Expand Up @@ -2016,6 +2022,7 @@ public function getMemberProperties($stackPtr)
'scope_specified' => $scopeSpecified,
'is_static' => $isStatic,
'is_readonly' => $isReadonly,
'is_final' => $isFinal,
'type' => $type,
'type_token' => $typeToken,
'type_end_token' => $typeEndToken,
Expand Down
21 changes: 21 additions & 0 deletions tests/Core/File/GetMemberPropertiesTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,24 @@ trait DNFTypes {
// Intentional fatal error - nullable operator cannot be combined with DNF.
var ?(A&\Pck\B)|bool $propD;
}

class WithFinalProperties {
/* testPHP84FinalPublicTypedProp */
final public string $val1;
/* testPHP84FinalProtectedTypedProp */
final protected string $val2;
/* testPHP84FinalMiddleTypedProp */
public final string $val3;
/* testPHP84FinalMiddleStaticTypedProp */
public final static string $val4;
/* testPHP84FinalLastTypedProp */
public readonly final string $val5;
/* testPHP84FinalImplicitVisibilityTypedProp */
final string $val6;
/* testPHP84FinalImplicitVisibilityProp */
final $val7;
/* testPHP84FinalNullableTypedProp */
final public ?string $val8;
/* testPHP84FinalComplexTypedProp */
final public (Foo&\Bar)|bool $val9;
}
Loading
Loading