Doc->Bug #73303 [Ver]: Scope not inherited by eval in assert()

From: Date: Fri, 18 Nov 2016 20:37:07 +0000
Subject: Doc->Bug #73303 [Ver]: Scope not inherited by eval in assert()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-205465@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73303&edit=1 ID: 73303 Updated by: nikic@php.net Reported by: ildar dot aim at gmail dot com -Summary: Not documented Backward incompatible change related to assert +Summary: Scope not inherited by eval in assert() Status: Verified -Type: Documentation Problem +Type: Bug Package: *General Issues Operating System: Linux PHP Version: 7.1.0RC3 Assigned To: dmitry Block user comment: N Private report: N New Comment: Regression due to EG(scope) removal. We should assign op_array->scope in zend_eval_stringl, like we do for ZEND_INCLUDE_OR_EVAL. Previous Comments: ------------------------------------------------------------------------ [2016-11-17 20:56:12] jmaguire at duo dot com Still experiencing this in PHP7.1.0RC5. ------------------------------------------------------------------------ [2016-10-12 21:29:54] cmb@php.net It seems the behavior has changed as of commit 6499162f[1]. Is the reported behavior intentional, Dmitry? [1] <http://git.php.net/?p=php-src.git;a=commit;h=6499162ff0d8aa6e862d3e3cdd2288b87636b8a1> ------------------------------------------------------------------------ [2016-10-12 15:16:51] ildar dot aim at gmail dot com Description: ------------ aim-server[~/tmp]$ /usr/bin/php --version PHP 7.0.11 (cli) (built: Sep 16 2016 18:52:44) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans aim-server[~/tmp]$ /usr/bin/php test_class.php Success% aim-server[~/tmp]$ /opt/phpfarm/inst/php-7.1.0RC3/bin/php --version PHP 7.1.0RC3 (cli) (built: Oct 12 2016 16:13:20) ( NTS DEBUG ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies aim-server[~/tmp]$ /opt/phpfarm/inst/php-7.1.0RC3/bin/php test_class.php PHP Warning: assert(): Assertion "self::checkCacheKey(get_object_vars($this))" failed in /home/aim/tmp/test_class.php on line 7 Warning: assert(): Assertion "self::checkCacheKey(get_object_vars($this))" failed in /home/aim/tmp/test_class.php on line 7 PHP Fatal error: Uncaught Error: Cannot access self:: when no class scope is active in /home/aim/tmp/test_class.php(7) : assert code:1 Stack trace: #0 [internal function]: unknown() #1 /home/aim/tmp/test_class.php(7): assert('self::checkCach...') #2 /home/aim/tmp/test_class.php(17): Test->main() #3 {main} thrown in /home/aim/tmp/test_class.php(7) : assert code on line 1 Fatal error: Uncaught Error: Cannot access self:: when no class scope is active in /home/aim/tmp/test_class.php(7) : assert code:1 Stack trace: #0 [internal function]: unknown() #1 /home/aim/tmp/test_class.php(7): assert('self::checkCach...') #2 /home/aim/tmp/test_class.php(17): Test->main() #3 {main} thrown in /home/aim/tmp/test_class.php(7) : assert code on line 1 aim-server[~/tmp]$ http://i.imgur.com/aG7kYps.png I cannot find a description of this behavior in http://php.net/manual/en/migration71.incompatible.php Test script: --------------- aim-server[~/tmp]$ cat test_class.php <?php class Test { public $prop; public function main(){ assert('self::checkCacheKey(get_object_vars($this))'); echo 'Success'; } private static function checkCacheKey($obj_properties){ return count($obj_properties) == 1; } } $obj = new Test(); $obj->main(); Expected result: ---------------- Success output or description in http://php.net/manual/en/migration71.incompatible.php Actual result: -------------- Fatal error: Uncaught Error: Cannot access self:: when no class scope is active in /home/aim/tmp/test_class.php(7) : assert code:1 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73303&edit=1

« previous php.bugs (#205465) next »