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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 11:01:31 2025 UTC