php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66252 Problems in AST evaluation invalidating valid parent:: reference
Submitted: 2013-12-10 02:00 UTC Modified: 2013-12-10 08:55 UTC
From: Terry at ellisons dot org dot uk Assigned: dmitry (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: master-Git-2013-12-10 (Git) OS: N/A
Private report: No CVE-ID: None
 [2013-12-10 02:00 UTC] Terry at ellisons dot org dot uk
Description:
------------
zval_update_constant_ex() evaluates a constant within the scope a class when executed within a class scope.  The new code to support ASTs does not pass this context into the AST evaluator so the class context is lost and references to self::SOME_CONSTANT and parent::SOME_CONSTANT error. 

Test script:
---------------
--TEST--
Terry_002   Problems in AST evaluation invalidating valid parent:: reference
--INI--
opcache.enable=0
opcache.enable_cli=0
opcache.optimization_level=0
--SKIPIF--
--FILE--
<?php
class A { const HW = "this is A"; }
class B extends A { const BHW = parent::HW . " extended by B"; }
const C = B::BHW; 
echo C, "\n";
--CLEAN--	
--EXPECT--
this is A extended by B


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-10 08:55 UTC] laruence@php.net
-Assigned To: +Assigned To: dmitry
 [2013-12-10 08:55 UTC] laruence@php.net
thanks for spotting this and explained the reason.
 [2013-12-10 10:21 UTC] dmitry@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5a87b7ff39bbf427807c46d1e51e2654259ad394
Log: Fixed bug #66252 (Problems in AST evaluation invalidating valid parent:: reference. Constant expessions have to be evaluated in context of defining class).
 [2013-12-10 10:21 UTC] dmitry@php.net
-Status: Assigned +Status: Closed
 [2013-12-10 18:47 UTC] ab@php.net
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=5a87b7ff39bbf427807c46d1e51e2654259ad394
Log: Fixed bug #66252 (Problems in AST evaluation invalidating valid parent:: reference. Constant expessions have to be evaluated in context of defining class).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 08:01:29 2024 UTC