|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-02-17 21:47 UTC] requinix@php.net
[2016-07-14 10:22 UTC] dmitry@php.net
[2019-01-25 16:36 UTC] nikic@php.net
-Status: Open
+Status: Not a bug
[2019-01-25 16:36 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 17:00:01 2025 UTC |
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)