Re: Static functions Vs Nonstatic functions
| From: | Carlos Rodrigues | Date: | Mon, 01 Dec 2014 19:48:15 +0000 |
| Subject: | Re: Static functions Vs Nonstatic functions | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79354@lists.php.net to get a copy of this message | ||
Hi,
Glad to hear it was discussed. I understand you guys are busy and can't
just change things out of nowhere, but i wish it will be dropped in the
future.
It it gets dropped in the future i will come back and ask to make it
possible to call a static method and normal methods with the same name :P.
For now i will just wait.
Thx anyway,
*Carlos Rodrigues*
2014-12-01 15:25 GMT-02:00 Stanislav Malyshev <smalyshev@gmail.com>:
> Hi!
>
> > class Cube {
> > function weird() {
> > echo Duck::foo();
> > }
> >
> > }
> >
> > class Duck {
> > public function foo() {
> > echo 'My class is: ' . get_class($this);
> > }
> > }
> >
> > $rubik = new Cube;
> > $rubik->weird(); // Output: My class is: Cube
>
> This code produces:
>
> Deprecated: Non-static method Duck::foo() should not be called
> statically, assuming $this from incompatible context
>
> which informs you about the fact that what you're doing is wrong. This
> capability is kept for BC reasons. There was a discussion about dropping
> this from PHP 7 but it wasn't yet decided to remove the support. In any
> case, this has little to do with static and non-static functions having
> different namespaces.
>
> --
> Stas Malyshev
> smalyshev@gmail.com
>