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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
33 - 15 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 13:01:29 2024 UTC