Edit report at https://bugs.php.net/bug.php?id=43936&edit=1

 ID:                 43936
 Comment by:         thomas at sibben dot nl
 Reported by:        james dot laver at gmail dot com
 Summary:            __empty() magic method
 Status:             Open
 Type:               Feature/Change Request
 Package:            Class/Object related
 Operating System:   GNU/Linux
 PHP Version:        5.2.5
 Block user comment: N
 Private report:     N

 New Comment:

The documentation states:

"empty() only checks variables as anything else will result in a parse error"

if 'everything else' is a __get() returning an array with a value in it, it 
returns TRUE,

Ubuntu 10.04 PHP 5.3.2-1ubuntu4.17


Previous Comments:
------------------------------------------------------------------------
[2011-08-24 00:40:26] chrisstocktonaz at gmail dot com

I made the start of a patch for this, but there is some issues that would need 
to 
be worked out with has_property calls, it seems oddly interfaced with by the 
various callers.

http://pastebin.com/d5gQycDB

------------------------------------------------------------------------
[2010-10-23 16:08:03] ka...@php.net

Fixed the overloading property vs language construct issue in the documentation.

This feature request is still valid, so moving it to be one instead of a 
documentation issue

------------------------------------------------------------------------
[2010-10-23 16:06:52] ka...@php.net

Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&revision=304662
Log: Added a remark about overloaded properties and language constructs (Bug 
#43936)

------------------------------------------------------------------------
[2010-06-30 13:02:14] paj...@php.net

Let document the __isset requirements better, when one relies on empty.

------------------------------------------------------------------------
[2010-06-30 12:00:35] icy at lighttpd dot net

Simple test script to trigger the bug:

<?php

class Foo {
        public $vars;

        function Foo() {
                $this->vars['bar'] = 1;
        }

        function __get($var) {
                return $this->vars[$var];
        }
}

$foo = new Foo;

var_dump(empty($foo->bar));
$baz = $foo->bar;
var_dump(empty($baz));

Expected result:
----------------
bool(false) bool(false) 

Actual result:
--------------
bool(true) bool(false)

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=43936


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=43936&edit=1

Reply via email to