php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25187 Call of __get in a construtor does not work
Submitted: 2003-08-21 06:37 UTC Modified: 2003-11-28 20:50 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: thomas dot hebinck at digionline dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.0b1 (beta1) 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: thomas dot hebinck at digionline dot de
New email:
PHP Version: OS:

 

 [2003-08-21 06:37 UTC] thomas dot hebinck at digionline dot de
Description:
------------
The call of a property via __get from a constructor called the same way does not work.

- $m is created
- $m->s creates new class s (via m::__get)
- the constructor of s calls $m->d->d_test
- m::_get (for $m->d) is NOT called:
  Notice: Undefined property

See the source - it should make it clear ;-)


Reproduce code:
---------------
class d {
  public function d_test() {
    return true;
  }
}
class s {
  function __construct() {
    global $m;
    $m->d->d_test();
  }
  function s_test() {
  }
}
class m {
  function __get($property) {
    switch ($property) {
      case 'd':
        return new d;
        break;
      case 's':
        return new s;
        break;
    }
  }
}
$m=new m;
$m->s->s_test();

Expected result:
----------------
just nothing - there is no output to reduce the lines of source code.

Actual result:
--------------
Notice: Undefined property: m::$d in /www/w23_bug/test_bug.php on line 10

Fatal error: Call to a member function d_test() on a non-object in /www/w23_bug/test_bug.php on line 10

This is the line: $m->d->d_test();



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-28 20:50 UTC] sniper@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

..
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 11 18:01:28 2024 UTC