OBJECT_OPERATOR vs. DOUBLE_COLON

From: Date: Wed, 05 Jul 2017 07:08:48 +0000
Subject: OBJECT_OPERATOR vs. DOUBLE_COLON
Groups: php.internals 
Request: Send a blank email to internals+get-99753@lists.php.net to get a copy of this message
Is it intentional that the DOUBLE_COLON operator can be used on a variable that contains a reference to an object? <?php class C {
    public function m()
    {
        print '*';
    }
} $c = new C; $c::m(); Until yesterday I thought that only the OBJECT_OPERATOR (->) can be used on a variable that contains an object. https://3v4l.org/59Xap proved me wrong. As the deprecation / strict standards notices suggest, though, $c::m() does not invoke the method m() on the object referenced by $c. It invokes the method statically on C (the class of the object referenced by $c): https://3v4l.org/19taB I think that using :: on a variable that contains an object should not "fall back" to a static access on the object's class. Instead the runtime should error out. What do you think?

« previous php.internals (#99753) next »