Bug #71620 [NEW]: strange behavour of parser and exception's handler

From: Date: Wed, 17 Feb 2016 21:11:56 +0000
Subject: Bug #71620 [NEW]: strange behavour of parser and exception's handler
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-199308@lists.php.net to get a copy of this message
From: miracle at rpz dot name Operating system: Linux PHP version: 7.0.3 Package: Scripting Engine problem Bug Type: Bug Bug description:strange behavour of parser and exception's handler Description: ------------ Legacy code use PEAR's classes with php4-style constructor. Usualy In same file defined several global constants used in class. When this file included, then engine throw warning about deprecated constructor. After catch this "exception" we have new class (hooray!) and undefined constants from same file... Test script: --------------- foo.php: <?php define('LOST_CONSTANT', 42); class Foo { public function foo() { // throw notice about deprecated constructor } } ?> main.php: <?php set_error_handler(function($errno, $errstr) { throw new Exception($errstr, $errno); // convert error to exception }); try { include 'foo.php'; } catch (Exception $e) { printf("error %d with message: %s\n", $e->getCode(), $e->getMessage()); } var_dump( class_exists('foo'), // exists! defined('LOST_CONSTANT') // where is my constant ); Expected result: ---------------- error 8192 with message: Methods with the same name as their class will not be constructors in a future version of PHP; Foo has a deprecated constructor main.php:14: bool(true) main.php:14: bool(true) Actual result: -------------- error 8192 with message: Methods with the same name as their class will not be constructors in a future version of PHP; Foo has a deprecated constructor main.php:14: bool(true) main.php:14: bool(false) -- Edit bug report at https://bugs.php.net/bug.php?id=71620&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71620&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71620&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71620&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=71620&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=71620&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=71620&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=71620&r=needscript Try newer version: https://bugs.php.net/fix.php?id=71620&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=71620&r=support Expected behavior: https://bugs.php.net/fix.php?id=71620&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=71620&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=71620&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=71620&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71620&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=71620&r=dst IIS Stability: https://bugs.php.net/fix.php?id=71620&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=71620&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=71620&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=71620&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=71620&r=mysqlcfg

« previous php.bugs (#199308) next »