php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41640 get_class_vars produces error on class constants
Submitted: 2007-06-08 20:30 UTC Modified: 2007-06-09 08:40 UTC
From: stas at zend dot com Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5CVS-2007-06-08 (CVS) OS: *
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: stas at zend dot com
New email:
PHP Version: OS:

 

 [2007-06-08 20:30 UTC] stas at zend dot com
Description:
------------
When class variables refers to a constant of the class using self::, get_class_vars produces a fatal error. 

Note that the code works if I access the class previously (uncomment commented lines in reproduction)

Reproduce code:
---------------
<?php
class foo {
        const FOO = 1;
        public $x = self::FOO;
}

//$b = new foo();
//var_dump($b);
var_dump(get_class_vars("foo"));


Expected result:
----------------
array(1) {
  ["x"]=>
  int(1)
}


Actual result:
--------------
Fatal error: Cannot access self:: when no class scope is active in /root/const2.php on line 9



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-09 08:40 UTC] johannes@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 09:01:28 2024 UTC