> > ---------- Forwarded message ---------- > From: Carlos Rodrigues <car...@jp7.com.br> > To: internals@lists.php.net > Cc: > Date: Fri, 28 Nov 2014 17:29:37 -0200 > Subject: Static functions Vs Nonstatic functions > 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 > > Why should static and non-static functions exist in separate namespaces? Are there any good reasons why a static function and an instance method of the same class need to have the same name? It sounds like someone is trying to a partial idea from another language to PHP without considering all of the ramifications.
Walter -- The greatest dangers to liberty lurk in insidious encroachment by men of zeal, well-meaning but without understanding. -- Justice Louis D. Brandeis -- The greatest dangers to liberty lurk in insidious encroachment by men of zeal, well-meaning but without understanding. -- Justice Louis D. Brandeis