Edit report at https://bugs.php.net/bug.php?id=51144&edit=1

 ID:                 51144
 Comment by:         dVaffection at gmail dot com
 Reported by:        davi dot fol at gmail dot com
 Summary:            spl_autoload is broken
 Status:             Open
 Type:               Feature/Change Request
 Package:            SPL related
 Operating System:   Mac OSX 10.6
 PHP Version:        5.3.1
 Block user comment: N
 Private report:     N

 New Comment:

I use PHP version 5.3.6 on Ubuntu 11.10 and confirm this bug!


Previous Comments:
------------------------------------------------------------------------
[2010-07-11 01:51:31] jinmoku at hotmail dot com

see http://bugs.php.net/bug.php?id=51991

------------------------------------------------------------------------
[2010-02-25 14:00:40] davi dot fol at gmail dot com

Description:
------------
I am aware of spl_autoload_* issues that the development team do not 
consider bugs, namely the requirement for class files to have 
lowercase names in order for spl_autoload to function. (I would like 
to think that moving forwards, we could supply a constant to 
spl_register_autoload as a best compromise BC step to change this 
behaviour to support PascalCase class names).

Anyhow, I've disabled all extensions, I believe I've exhausted all 
configuration possibilities affecting spl_autoloads behaviour, and 
it still does not work. Defining my own handler, does. It seems that 
no matter how I define the include path, spl_autoload throws 
LogicExceptions as it cannot find classes. I am hoping that its not 
the case that as Mac OSX paths contain upper case folder names, 
that the auto lowercasing behaviour of spl_autoload is affecting 
absolute paths.

As a concrete case, this IS an include path that I use- it works with 
include_once et al, supplying or omitting the trailing slash:

"/Users/davidfoley/Documents/Aptana Studio 
Workspace/www.thorium.site/Private/Library/"

The above path is a perfectly valid file path- its somewhat different 
in the sense that 'www.thorium.site' is plonked in the middle- 
thats simply the name of a virtual hosts symlinked folder. I am only 
guessing that this could be a possible reason why spl_autoload is 
not working.

Reproduce code:
---------------
Assume a class file: 
location:
www/Private/library/target.php
contents:
namespace library
{
    class target
    {

    }
}

Assume a bootloader script
location:
www/Public/boot.php
contents:
define('BREAK', '<br/>');
set_include_path('absolute/path/to/www/Private/library);
spl_autoload_extensions('.php');
spl_autoload_register();

$classFile= new SplFileObject('library/target.php', true);
echo 'The class file exists: ' . ($classFile->isFile() ? 'true' : 'false') . 
BREAK;

use library\target;

$instance= new target;
echo 'The class was loaded: ' . (isset($instance) ? 'true' : 'false') . BREAK;

Expected result:
----------------
The following output:

The class file exists: true
The class was loaded: true

Actual result:
--------------
LogicException 'could not load class library\target'


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=51144&edit=1

Reply via email to