Please read : http://grokbase.com/t/php/php-internals/14acs23cpe/disallow-non-static-method-calls-with-self-static-in-php-7#20141026ct1np9k82bte2m9k9rtmq1c2jr

Am 28.11.2014 um 20:29 schrieb Carlos Rodrigues:
PHP has evolved a lot in recent years but we still can't have a static and
a nonstatic function with the same name:

class A {
     function bla() { echo 'normal';  }
     static function bla() { echo 'static';  }
}

A::bla();

## ERROR: Cannot redeclare A::bla()

And also PHP supports calling static functions as if they were not static:

class B {
static function bla() { echo 'how come it works';  }
}

$object = new B;
$object->bla();


It confuses programmers that came from other languages, prevent APIs from
having meaningful names on static methods and have no other benefit than
supporting PHP 4 code.

I'd appreciate if anyone with sufficient knowledge/influence helped me
suggest this change to the maintainers.

IMHO, static and nonstatic functions should be "stored" in different
places. And if someone relies on this, one should use magic methods __call
and __callStatic instead.


Thanks for your time and patience,


Carlos Rodrigues
car...@jp7.com.br



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to