#49979 [NEW]: Magic constants refresh in __autoload()

From: Date: Fri, 23 Oct 2009 23:06:47 +0000
Subject: #49979 [NEW]: Magic constants refresh in __autoload()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-143875@lists.php.net to get a copy of this message
From: insideone at rambler dot ru Operating system: Windows XP PHP version: 5.2.11 PHP Bug Type: Feature/Change Request Bug description: Magic constants refresh in __autoload() Description: ------------ I wrote CMS and have faced problem. The system is grounded on modular connection of classes. It is possible with __ autoload () - many thanks! But it would be healthy not to refresh value Magic constants inside __ autoload (). Namely __ FUNCTION __ and __ METHOD __. They lose meaning inside __ autoload () though could benefit. Advantage example I result in code. Reproduce code: --------------- // file: "index.php" // Example of desirable call function __autoload($Class){ require('engine/' . __CLASS__ . '/' . $Class . '.php'); } $Data = new _Data; $Data->RuleAdd("_NOT_NULL"); // file: "engine/_Data.php" class _Data{ $Rules; public function RuleAdd($RULE_NAME){ // add new callback function from class $RULE_NAME (directory "engine/_Data/_$RULE_NAME.php") $Rules[$RULE_NAME] = call_user_func(Array($RULE_NAME, 'main')); }} // file: "engine/_Data/_NOT_NULL.php" class _NOT_NULL{ public function main(&$DATA){ return ($DATA)?:true:false; }} Expected result: ---------------- In the given example at inquiry of an unknown class $RULE_NAME ("$this-> Rules [$RULE_NAME] = call_user_func (Array ($RULE_NAME, RULE_CALLBACK));") it is necessary to load automatically it from a folder "engine / _ Data / _ NON_NULL.php" under the class name and demanded $RULE_NAME, but function __ autoload () it does not allow. Complicating __ autoload () but this distortion is probably finite. Magic constants are illogically refreshed in __ autoload () because they are necessary when do not know where the code is now fulfilled. And when you write Magic constants in function __ autoload () you already known that they are equal. Therefore they there are useless. Actual result: -------------- __autoload($Class) load this file: "engine//NOT_NULL.php" -- Edit bug report at http://bugs.php.net/?id=49979&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49979&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49979&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49979&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=49979&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49979&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=49979&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=49979&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=49979&r=needscript Try newer version: http://bugs.php.net/fix.php?id=49979&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=49979&r=support Expected behavior: http://bugs.php.net/fix.php?id=49979&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=49979&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=49979&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=49979&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49979&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=49979&r=dst IIS Stability: http://bugs.php.net/fix.php?id=49979&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=49979&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=49979&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=49979&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=49979&r=mysqlcfg

« previous php.bugs (#143875) next »