php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55746 issue with __get on unset property
Submitted: 2011-09-21 02:37 UTC Modified: 2011-09-21 02:39 UTC
From: hytest at gmail dot com Assigned:
Status: Duplicate Package: *General Issues
PHP Version: 5.3.8 OS: Fedora 15
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: hytest at gmail dot com
New email:
PHP Version: OS:

 

 [2011-09-21 02:37 UTC] hytest at gmail dot com
Description:
------------
Test following script please. 
It enters __get twice on unset property (class Ex1) but only once on Ex2. 

It doesn't really make sense and can't find any word in document so I assume it's 
a bug. 

Test script:
---------------
class Ex1{
  private $var;

  function __construct(){
        unset($this->var);
  }

  function __get($elmname){
        echo "call __get\n";
        return $this->$elmname;
  }

}

class Ex2{

        function __construct(){
        }

        function __get($elmname){
                echo "call __get\n";
                return $this->$elmname;
        }

}

$ex1=new Ex1();
echo $ex1->var;

$ex2=new Ex2();
echo $ex2->var;


Expected result:
----------------
call __get
PHP Notice:  Undefined property: Ex1::$var in /web/sites/test/test1/t5.php on line 
12
call __get
PHP Notice:  Undefined property: Ex2::$var in /web/sites/test/test1/t5.php on line 
24


Actual result:
--------------
call __get
call __get
PHP Notice:  Undefined property: Ex1::$var in /web/sites/test/test1/t5.php on line 
12
call __get
PHP Notice:  Undefined property: Ex2::$var in /web/sites/test/test1/t5.php on line 
24


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-09-21 02:39 UTC] laruence@php.net
-Status: Open +Status: Duplicate
 [2011-09-21 02:39 UTC] laruence@php.net
this is a dup to #55731, plz see it
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 14:01:36 2025 UTC