Pending

User tests: Successful: Unsuccessful:

avatar Denitz
Denitz
8 Sep 2023

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

8f1d4ca 8 Sep 2023 avatar fix
avatar joomla-cms-bot joomla-cms-bot - change - 8 Sep 2023
Category Administration com_banners Libraries
avatar Denitz Denitz - open - 8 Sep 2023
avatar Denitz Denitz - change - 8 Sep 2023
Status New Pending
avatar HLeithner HLeithner - change - 12 Sep 2023
Title
5.0 Non-static methods called as static from object context
[5.0] Non-static methods called as static from object context
avatar HLeithner HLeithner - edited - 12 Sep 2023
avatar HLeithner
HLeithner - comment - 24 Sep 2023

This Pull request changes the behavior. self calls the function defined by it "self" or "parent" class but not if defined in child class.
Example: https://3v4l.org/TtuJ3

<?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:

z
y
x
x2

if someone has time to evaluate what we really want it would be great.

avatar HLeithner
HLeithner - comment - 30 Sep 2023

This pull request has been automatically rebased to 5.1-dev.

avatar Denitz Denitz - change - 3 Oct 2023
Title
[5.0] Non-static methods called as static from object context
[5.1] Non-static methods called as static from object context
avatar Denitz Denitz - edited - 3 Oct 2023
avatar Hackwar
Hackwar - comment - 21 Feb 2024

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.

avatar Hackwar
Hackwar - comment - 21 Feb 2024

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

Add a Comment

Login with GitHub to post a comment