You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Phan 5.4.3
php-ast version 1.1.1
PHP version used to run Phan: 8.3.1
Given this code:
<?php
class Foo {
private readonly array $bar;
public function __construct() {
$this->bar = [ 'baz' => 'qux' ];
}
public function check( string $key ) : ?string {
if ( ! is_array( $this->bar ) ) return null;
if ( ! array_key_exists( $key, $this->bar ) ) return null;
if ( isset( $this->bar[ $key ] ) ) {
return $this->bar[ $key ];
}
}
}
$foo = new Foo();
echo $foo->check( 'baz' ) ?? "quux", "\n";
Phan produces the following output:
readonly.php:13 PhanAccessReadOnlyProperty Cannot modify read-only property \Foo->bar defined at readonly.php:4
Where line 13 is the isset. To the best of my knowledge, there are no circumstances where this will attempt to modify the readonly property. (And when run, the code produces the correct "qux" output.)
This happens on a variety of uses of the readonly array, but isset() seems like the clearest example of potential misbehavior.
Thanks!
The text was updated successfully, but these errors were encountered:
Phan 5.4.3
php-ast version 1.1.1
PHP version used to run Phan: 8.3.1
Given this code:
Phan produces the following output:
readonly.php:13 PhanAccessReadOnlyProperty Cannot modify read-only property \Foo->bar defined at readonly.php:4
Where line 13 is the isset. To the best of my knowledge, there are no circumstances where this will attempt to modify the readonly property. (And when run, the code produces the correct "qux" output.)
This happens on a variety of uses of the readonly array, but isset() seems like the clearest example of potential misbehavior.
Thanks!
The text was updated successfully, but these errors were encountered: