-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[5.2] Non-static methods called as static from object context #41661
[5.2] Non-static methods called as static from object context #41661
Conversation
This Pull request changes the behavior. self calls the function defined by it "self" or "parent" class but not if defined in child class. <?php
class a {
function x() {
echo 'x' . chr(10);
}
}
class b extends a {
function y() {
echo 'y' . chr(10);
self::x();
$this->x();
}
}
class c extends b {
function z() {
echo 'z' . chr(10);
self::y();
}
function x() {
echo 'x2' . chr(10);
}
}
echo (new c)->z(); Output:
if someone has time to evaluate what we really want it would be great. |
This pull request has been automatically rebased to 5.1-dev. |
I disagree that this is a b/c break. Yes, in theory the behavior can be different, but in reality this is simply super old code (The line in the banner table for example is at least 14 years old.) and at that time the code quality wasn't the best... With a codereview this could simply be merged. |
Ok, I finally found it. The line in the banner table was introduced close to 15 years ago in one of those major rewrites: 81e0102#diff-220ad14bb0e7e21591b2575dfb72a5edb7bfbffff4d8069de75e7bcaf8874acdR118 |
In what situation(s) should we see the warnings? This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/41661. |
This pull request has been automatically rebased to 5.2-dev. |
…rom_object_context
…rom_object_context
Thank you for your contribution @Denitz! |
Summary of Changes
Non-static methods called as static from object context
Testing Instructions
Apply patch
Actual result BEFORE applying this Pull Request
See IDE warnings
Expected result AFTER applying this Pull Request
No IDE warnings.
Link to documentations
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed