<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">&lt;?php
/**
 * https://github.com/php/php-src/pull/1026
 * https://wiki.php.net/rfc/incompat_ctx
 */
class A
{
    function bNon()
    {
        //i'm not interested in this
        echo "A::bNon\n";
    }

    static function cStat()
    {
        if (isset($this)) {
            //static method has been called non-statically
            //$this is instance of A
            echo '$a-&gt;cStat' . "\n";
        } else {
            //static method has been called statically
            echo "A::cStat\n";
        }
    }

    static function dStaticVarHack()
    {
        $his = 'this';
        if (isset($$his)) {
            //static method has been called non-statically
            //$this is instance of A
            echo '$a-&gt;dStaticVarHack' . "\n";
        } else {
            //static method has been called statically
            echo "A::dStaticVarHack\n";
        }
    }

    function eVarHack()
    {
        $his = 'this';
        if (isset($$his)) {
            //method has been called non-statically
            //$this is instance of A
            echo '$a-&gt;eVarHack' . "\n";
        } else {
            //method has been called statically
            echo "A::eVarHack\n";
        }
    }
}

//this should fail, that's fine
A::bNon();

//but this should work both:
A::cStat();
$a = new A();
$a-&gt;cStat();

//but this should work both:
A::dStaticVarHack();
$a = new A();
$a-&gt;dStaticVarHack();

A::eVarHack();
$a = new A();
$a-&gt;eVarHack();

?&gt;
</pre></body></html>