Bug #65999 [Fbk->Opn]: autoloading of aliased namespaced classes fails when including twice a file

From: Date: Wed, 30 Oct 2013 16:37:16 +0000
Subject: Bug #65999 [Fbk->Opn]: autoloading of aliased namespaced classes fails when including twice a file
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182501@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65999&edit=1 ID: 65999 User updated by: giunta dot gaetano at gmail dot com Reported by: giunta dot gaetano at gmail dot com Summary: autoloading of aliased namespaced classes fails when including twice a file -Status: Feedback +Status: Open Type: Bug Package: *General Issues Operating System: win7 64bit PHP Version: 5.4.21 Block user comment: N Private report: N New Comment: You are correct, the provided test file has no problems. The error I have is with a slightly more complex setup - a composer-generated autoloader class. I will try to reproduce the error with a minimal setup... Previous Comments: ------------------------------------------------------------------------ [2013-10-30 14:48:28] nikic@php.net Could you please provide a short reproduce script for your issue? I tried the following code, which autoloaded 'A\B\C', not 'D': <?php use A\B\C as D; if (!isset($alreadyIncluded)) { spl_autoload_register('var_dump'); $alreadyIncluded = true; include __FILE__; } else { new D; } ------------------------------------------------------------------------ [2013-10-30 10:50:08] giunta dot gaetano at gmail dot com [edited bug name] ------------------------------------------------------------------------ [2013-10-30 10:49:20] giunta dot gaetano at gmail dot com Description: ------------ Imagine the following situation: - file X.php has a USE statement aliasing a class name A\B\C as D - it includes other files, which set up autoloading, then require X.php again - when X.php is reincluded, it executes some code, using an object: $x = new D() In this case, the functions registered for class autoloading will get passed the string 'D' instead of 'A\B\C' ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65999&edit=1

« previous php.bugs (#182501) next »