Re: Static method call syntax on objects

From: Date: Wed, 10 Aug 2011 20:20:43 +0000
Subject: Re: Static method call syntax on objects
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-54499@lists.php.net to get a copy of this message
Hi! On 8/10/11 1:12 PM, Sebastian Bergmann wrote:
Is this exepcted behaviour?
     ➜  ~  cat test.php
     <?php
     class Foo {
         public static function bar() {
             print __METHOD__ . "\n";
         }
     }
     $foo = new Foo;
     $foo::bar();
     ➜  ~  php test.php
     Foo::bar
I, for one, was surprised that this does what it does with PHP 5.3 and PHP 5.4 (do not have older version of PHP hand).
This is how FETCH_CLASS works now - when it has an object in where it expects class name, it uses object's class. We could call toString() instead but that might be even more surprising. -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227

« previous php.internals (#54499) next »