php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34182 empty function with SPL
Submitted: 2005-08-18 10:21 UTC Modified: 2005-08-26 01:00 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: luke at qcm dot cz Assigned:
Status: No Feedback Package: SPL related
PHP Version: 5.0.4 OS: irelevant (tested on linux)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: luke at qcm dot cz
New email:
PHP Version: OS:

 

 [2005-08-18 10:21 UTC] luke at qcm dot cz
Description:
------------
caling empty function with SPL object attribute (arrayaccess) as parameter return always false (is not empty).

Reproduce code:
---------------
class a implements ArrayAccess {

  private $vars;

  public function offsetExists($offset) {
      return (isset($this->vars[$offset]));
  } // offsetExists

  public function offsetGet($offset) {
        return $this->vars[$offset];
    } // offsetGet

  public function offsetSet($offset, $value) {
        $this->vars[$offset] = $value;
    } // offsetSet

  public function offsetUnset($offset) {
        if ($this->offsetExists($offset)) {
            unset($this->vars[$offset]);
        } // if
    } // offsetUnset
}

$x = new a();
$x['key'] = '';
var_dump($x['key']);
var_dump(empty($x['key']));

$y = $x['key'];
var_dump($y);
var_dump(empty($y));


Expected result:
----------------
string(0) "" bool(true) string(0) "" bool(true)

Actual result:
--------------
string(0) "" bool(false) string(0) "" bool(true)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-18 10:41 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-08-26 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-04-30 16:20 UTC] robert_hennig at web dot de
The bug is still there ... PHP 5.2.6 on Linux.
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC