Skip to content

Commit

Permalink
File::getMemberProperties(): minor tweaks after readonly merge
Browse files Browse the repository at this point in the history
Follow up on 3480

I realized after the merge that I had not published a few follow up comments. Addressing those here.

* The new `is_readonly` key still needed to be added to the documentation for the `File::getMemberProperties()` method.
* For consistency in how the method is tested, adding the `is_readonly` property to all other test expectations, which makes the `testPHP81NotReadonly` test case redundant.
* Adding two additional test cases. In particular I wanted to verify (and safeguard) that the retokenization of the `?` to `T_NULLABLE` after a `readonly` keyword would not be broken (which it partially was, but that has now been fixed in 3513).
  • Loading branch information
jrfnl committed Apr 23, 2022
1 parent b314140 commit 9d4c6d1
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -1759,6 +1759,7 @@ public function getMethodProperties($stackPtr)
* 'scope' => string, // Public, private, or protected.
* '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.
* 'type' => string, // The type of the var (empty if no type specified).
* 'type_token' => integer, // The stack pointer to the start of the type
* // or FALSE if there is no type.
Expand Down
8 changes: 6 additions & 2 deletions tests/Core/File/GetMemberPropertiesTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,14 @@ $anon = class() {
// Intentional fatal error - duplicate types are not allowed in union types, but that's not the concern of the method.
public int |string| /*comment*/ INT $duplicateTypeInUnion;

/* testPHP81NotReadonly */
private string $notReadonly;
/* testPHP81Readonly */
public readonly int $readonly;

/* testPHP81ReadonlyWithNullableType */
public readonly ?array $array;

/* testPHP81ReadonlyWithUnionType */
protected ReadOnly string|null $array;
};

$anon = class {
Expand Down
Loading

0 comments on commit 9d4c6d1

Please sign in to comment.