Re: Unexpected behavior for ::
| From: | Etienne Kneuss | Date: | Mon, 12 Dec 2011 14:12:39 +0000 |
| Subject: | Re: Unexpected behavior for :: | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-56888@lists.php.net to get a copy of this message | ||
Hi,
On Mon, Dec 12, 2011 at 14:35, Bogdan Bezuz <bogdan.bezuz@emag.ro> wrote:
> Hello,
> I'm not sure if this is the desired behavior and i don't want to submit a
> bogus bug report.
>
> class A
> {
> public function f1()
> {
> var_dump($this->_b);
> }
> }
>
> class B
> {
> public $_b = 'stuff';
>
> public function f2()
> {
> A::f1();
> }
> }
>
> $b = new B();
> $b->f2();
>
> At first i would expect an error since A was not instantiated, at most i
> would expect to return NULL but not 'stuff'.
> Is this a bug ?
Not really, it's a BC compatibility that we had to drag since PHP4. If
you enable E_STRICT, it should output a warning saying something like
"importing $this from invalid context". It is/was scheduled for
cleanup in the next major version.
Best,
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
Etienne Kneuss
http://www.colder.ch