php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49640 Feature request: spl_autoload_cs
Submitted: 2009-09-23 10:05 UTC Modified: 2010-11-24 11:15 UTC
Votes:7
Avg. Score:4.6 ± 0.7
Reproduced:7 of 7 (100.0%)
Same Version:3 (42.9%)
Same OS:5 (71.4%)
From: jo at feuersee dot de Assigned:
Status: Open Package: SPL related
PHP Version: 5.3.0 OS: Linux
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: jo at feuersee dot de
New email:
PHP Version: OS:

 

 [2009-09-23 10:05 UTC] jo at feuersee dot de
Description:
------------
This is related to #49625

Ok I agree that spl_autoload() won't be touched because of BC (Seems the convention to lowercase all filenames has been borrowed from Java and ppl are actually using it).

How about a case sensitive function spl_autoload_cs() then? It should behave excactly like spl_autoload() except that it skips the lowercasing stuff. Projects using a case sensitive naming convention (PEAR, Zend Framework, ...) can unregister the default spl_autoload() and register spl_autoload_cs() and it will work.

I am aware that it is possible to write an own callback in PHP. The problem is that you can't write the callback once and then put it in your codebase because the callback is the glue between your script and the codebase.

I do a lot of scripting PHP on the CLI and am tired of duplicating my callback function code over and over again just to make sure the script will work with a case sensitive design paradim.

Reproduce code:
---------------
<?php
/**
 * proposed usage of new feature spl_autoload_cs()
 */

spl_autoload_unregister('spl_autoload');
spl_autoload_register('spl_autoload_cs');

// executing a PEAR class would work now
$phpbin = System::which('php');

?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-24 11:15 UTC] jani@php.net
-Package: Feature/Change Request +Package: SPL related
 [2012-09-07 17:36 UTC] eugeny dot p at gmail dot com
It would make sense to make spl_autoload_cs similar to spl_autoload_extensions
spl_autoload_cs(bool CaseSensitive) - false is default

So usage is going to be:

> # To make it case sensitive
> spl_autoload_cs(true);
> spl_autoload_register();


> # Default
> spl_autoload_cs(false);
> spl_autoload_register();
> # Or just 
> spl_autoload_register();
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC