php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49979 Magic constants refresh in __autoload()
Submitted: 2009-10-23 23:06 UTC Modified: 2009-10-23 23:53 UTC
From: insideone at rambler dot ru Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.11 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: insideone at rambler dot ru
New email:
PHP Version: OS:

 

 [2009-10-23 23:06 UTC] insideone at rambler dot ru
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"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-23 23:53 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

These constants ave a specific compile-time meaning. what you are looking for is a way to make your functions not-deterministic what we certainly don\'t want to support.

If youreally want to do suchbad stuff: All information needed should be availablevia debug_backtrace()
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 04:01:27 2024 UTC