|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-10-02 15:26 UTC] brainreflex at gmail dot com
Description: ------------ 5.4 doesn't allow to redefine function if bult-in function had been called before. It's a bug or omission of documentation For more details look at http://vatson.com.ua/blog/2012/10/01/php-5-dot-4-and- function-overloading/ Test script: --------------- https://github.com/vatson/php-experiments Expected result: ---------------- The same behavior for both versions PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 22:00:01 2025 UTC |
Looks like it's an introduced bug since redefining functions still works well when functions had been called in the same file like the following : <?php namespace custom; var_export('hello'); //hello eval("namespace custom; function var_export(){echo 'foobar';}"); var_export('hello'); //foobar ?>It's pretty annoying since this feature allowed a king of monkey patching in PHP 5.3 for writing tests cases. With PHP 5.4 & 5.5, redefining functions only work in the same file like in the follwing example: <?php namespace custom; var_export('hello'); //hello eval("namespace custom; function var_export(){echo 'foobar';}"); var_export('hello'); //foobar ?>