php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34396 Using unset on member variable results in __get and __set being used
Submitted: 2005-09-06 19:33 UTC Modified: 2005-09-07 11:44 UTC
From: zeldorblat at gmail dot com Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5.0.5 OS: 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: zeldorblat at gmail dot com
New email:
PHP Version: OS:

 

 [2005-09-06 19:33 UTC] zeldorblat at gmail dot com
Description:
------------
If unset() is used on a member variable, subsequent calls to __get and __set take effect as if the variable was not defined as a property.  This may be a feature, but the behavior was different in 5.0.4.

Reproduce code:
---------------
Class A {
        private $foo = 5;
        private $x = array();

        public function __get($name) {
                if(!isset($this->x[$name]))
                        echo "Property $name is not set!";
                else
                        return $this->x[$name];
        }

        public function bar() {
                unset($this->foo);
                return $this->foo;
        }

}

$a = new A();
echo $a->bar();


Expected result:
----------------
In PHP 5.0.4:

PHP Notice:  Undefined variable: foo

Actual result:
--------------
In PHP 5.0.5:

Property foo is not set!

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-07 11:44 UTC] sniper@php.net
See bug #33512
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 16:01:30 2025 UTC