Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56890 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 13952 invoked from network); 12 Dec 2011 14:46:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Dec 2011 14:46:00 -0000 Received: from [127.0.0.1] ([127.0.0.1:18422]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 25/D5-17834-7A316EE4 for ; Mon, 12 Dec 2011 09:46:00 -0500 Authentication-Results: pb1.pair.com smtp.mail=prvs=5327BEAD7B=bogdan.bezuz@emag.ro; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=bogdan.bezuz@emag.ro; sender-id=pass Received-SPF: pass (pb1.pair.com: domain emag.ro designates 91.206.36.74 as permitted sender) X-PHP-List-Original-Sender: prvs=5327BEAD7B=bogdan.bezuz@emag.ro X-Host-Fingerprint: 91.206.36.74 mail.emag.ro Received: from [91.206.36.74] ([91.206.36.74:55021] helo=webmail.emag.ro) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BF/C5-17834-07216EE4 for ; Mon, 12 Dec 2011 09:40:50 -0500 Received: from [192.168.12.79] (192.168.12.79) by srv-exch.emag.local (192.168.1.74) with Microsoft SMTP Server id 14.1.355.2; Mon, 12 Dec 2011 16:40:38 +0200 Message-ID: <4EE6121B.7030501@emag.ro> Date: Mon, 12 Dec 2011 16:39:23 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: Etienne Kneuss CC: PHP Developers Mailing List References: <4EE60332.7000809@emag.ro> In-Reply-To: Content-Type: multipart/alternative; boundary="------------020504050704070705050005" X-Originating-IP: [192.168.12.79] Subject: Re: [PHP-DEV] Unexpected behavior for :: From: bogdan.bezuz@emag.ro (Bogdan Bezuz) --------------020504050704070705050005 Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit Hello, Thanks for the info, as pointed out by Sean Coates this is sort of documented, I've submited a documentation (problem/)bug report. https://bugs.php.net/bug.php?id=60499 E_STRICT was disabled since a large part of the application was moved to php 5 only last year and, even if i was aware that it is possible to call non-static methods in a static way, i didn't expect this to work. On 12/12/2011 16:12, Etienne Kneuss wrote: > Hi, > > On Mon, Dec 12, 2011 at 14:35, Bogdan Bezuz 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 >> > > -- *Bezuz Bogdan* *Programare Site* +40 721 269 934 bogdan.bezuz@emag.ro logo_emag Dante International SA Tel/Fax: +40 21 200 52 00/25 Swan Office Park, Windsor Building Şos. Bucureşti Nord nr. 15-23 Bucureşti --------------020504050704070705050005 Content-Type: multipart/related; boundary="------------080506020705040500000107" --------------080506020705040500000107 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 8bit Hello,
Thanks for the info, as pointed out by Sean Coates this is sort of documented, I've submited a documentation (problem/)bug report.
https://bugs.php.net/bug.php?id=60499

E_STRICT was disabled since a large part of the application was moved to php 5 only last year and, even if i was aware that it is possible to call non-static methods in a static way, i didn't expect this to work.

On 12/12/2011 16:12, Etienne Kneuss wrote:
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





--
Bezuz Bogdan
Programare Site
+40 721 269 934
bogdan.bezuz@emag.ro


logo_emag
Dante International SA
Tel/Fax: +40 21 200 52 00/25
Swan Office Park, Windsor Building
Şos. Bucureşti Nord nr. 15-23
Bucureşti
--------------080506020705040500000107 Content-Type: image/png; name="image001.png" Content-Transfer-Encoding: base64 Content-ID: Content-Disposition: inline; filename="image001.png" iVBORw0KGgoAAAANSUhEUgAAAIUAAAAlCAIAAADjpL2FAAAIv0lEQVRoBe2bfWiXVRTH3XTO ptus1EhNNxDUxF5EiTBwE8IS2kpSCA1nQphWNigEJd8gQQpULPOfcpoiaG/bH1YYbkYqMjFz aEnRps5FunzZdGxTtz4/7zq73vs893l+z+83naX8GOeee865L997zj333seU9vb2Hnf/dZsZ 6BW+J211Z9rqausPH8m+3iJavUaOTsnK6jX+CeH8z4mK43UXr7QcqamXeejfN/2xnAE5AzP5 CdOPSAn0j+snfmneVnKt8iB4+FmB33Pk6PSCaWmTn04dPMQQO//bH8s37alKH2jw9SI9XjN7 os7xo+d8XF5ztsGvVvExhUFPmdzXt9aca/SsUsznJ+R+9fYzDgG7CoNfV1aXVlYDhl0rHIDJ e3hw4fgcmoAWvk648MD6iLXv9j34g64QSPcunHbPvDd1VK4dOlj76tyCYTPckJQvK6S7bvtr dx0t3rzPLUOtn6mSil+BM1C9+sNZYdYydkBixeeHMBtoUxcAjIXPjn1r6iM2Kqm6nNB43Asf fHtgQXG8YGChtfTLhhk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YUAtlM54JeaYBfWsKJxoRGwbuPljlmh2kqil35H4mWVePLN/Q56FG9n1dVM0p7/y euCBNC0hxGyG6ZluXWi6W71+pv1KIwK3hSgKeupQvQoDG6e/BKcIJHBWfjquZrzSpwlH4UfD 6gUtzIkG/DjtoxUZSL0DyaXpFS4bxiawOTZRZYE9hsimpojMhQf2wOt9pcjMqEcwHQbplev/ f4iQImienBpUjO8fcgZlDR/QD+v8uiEMxii6tMgUVRw7c7L+svE/hlgH5CZMjnqUdfQhDjwc Vu5WJWsG/gEIlvmHWRYT/gAAAABJRU5ErkJggg== --------------080506020705040500000107-- --------------020504050704070705050005--