-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Static properties in traits don't override static properties from parent class #10935
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
Labels
Comments
Simplified example: https://3v4l.org/Dll1m class A {
static $test;
}
class B extends A {
static $test;
}
A::$test = 'A';
B::$test = 'B';
var_dump(A::$test, B::$test);
// string(1) "A"
// string(1) "B" https://3v4l.org/SClLn trait Foo {
static $test;
}
class A {
use Foo;
}
class B extends A {
use Foo;
}
A::$test = 'A';
B::$test = 'B';
var_dump(A::$test, B::$test);
// string(1) "B"
// string(1) "B" The RFC is super old, there's no mention on how this is supposed to behave. The docs aren't telling either. It's reasonable to expect the same behavior as the case without traits. |
iluuu1994
added a commit
to iluuu1994/php-src
that referenced
this issue
Mar 25, 2023
iluuu1994
added a commit
to iluuu1994/php-src
that referenced
this issue
Mar 25, 2023
iluuu1994
added a commit
to iluuu1994/php-src
that referenced
this issue
Mar 26, 2023
iluuu1994
added a commit
to iluuu1994/php-src
that referenced
this issue
Mar 27, 2023
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
The following code:
Resulted in this output:
But I expected this output instead:
PHP Version
PHP 8.2.3
Operating System
mac 13.0.1
The text was updated successfully, but these errors were encountered: