Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:40860 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 5690 invoked from network); 4 Oct 2008 21:15:28 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Oct 2008 21:15:28 -0000 Received: from [127.0.0.1] ([127.0.0.1:19729]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 0F/48-48736-FECD7E84 for ; Sat, 04 Oct 2008 17:15:27 -0400 X-Host-Fingerprint: 89.76.8.74 chello089076008074.chello.pl Received: from [89.76.8.74] ([89.76.8.74:22156] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B0/28-48736-339D7E84 for ; Sat, 04 Oct 2008 16:59:32 -0400 Message-ID: To: internals@lists.php.net Date: Sat, 04 Oct 2008 22:59:29 +0200 User-Agent: Thunderbird 2.0.0.17 (X11/20080925) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 89.76.8.74 Subject: __get() magic method and its use with empty() function. From: faw217@gmail.com (Kuba Wieczorek) Hello, I'd like to talk about one thing I experienced using __get() magic method. It is a problem reported for the first time in a bug report (http://bugs.php.net/bug.php?id=24915) about five years ago but it has been closed and marked as 'Won't fix'. Well, this is a sample code for this: $var; } } $test = new test; print 'a: ' . var_export($test->a, true) . ' ' . var_export(empty($test->a), true) . "\n"; print 'b: ' . var_export($test->b, true) . ' ' . var_export(empty($test->b), true) . "\n"; ?> This is the current result: a: NULL true b: 'test' true The expected one should be: a: NULL true b: 'test' false There is a work-around for this, the vars have just to be assigned to another ones and then those ones checked with empty(), but of course it does not satisfy me. The problem is really annoying. I am sure that there are many other developers here, who experienced it so I want to know your opinions about it. Kuba Wieczorek