php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62655 Request: optional class name case-sensitivity
Submitted: 2012-07-24 23:51 UTC Modified: -
Votes:3
Avg. Score:3.0 ± 1.6
Reproduced:2 of 3 (66.7%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: eric at wepay dot com Assigned:
Status: Open Package: Class/Object related
PHP Version: Irrelevant OS: OS X, CentOS
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-07-24 23:51 UTC] eric at wepay dot com
Description:
------------
It would be beneficial in more complex applications to be able to opt-in to case 
sensitive class names. It's very common to put classes in their own files where 
the filename matches the class name (namespaced classes often residing in 
subdirectories).  

However, the lack of case-sensitivity makes it easy to create very rare and 
subtle bugs in applications: development is often done on case-insensitive 
filesystems, and deployed to a case-sensitive production environment. While the 
obvious answer here is to develop in an environment identical to production, 
it's often impractical if not impossible to use a case-sensitive filesystem on a 
dev machine. Other behavior in autoloaders can have similar harmful effects, 
especially when new code paths cause scripts or classes to be loaded in a 
different order.

I am not proposing that this become the default behavior, as it would obviously 
break countless applications. It should also not modify 
__autoload/spl_autoload_register in any way. It would be nice to be able to 
selectively enable this via php.ini:

; Enable class name case sensitivity
; 0 (default): class names are case-insensitive
; 1: class names are case-insensitive, but using a class name in a way different 
from its declaration will issue an E_STRICT warning including file and line of 
class name misuse
; 2: class names are case-sensitive. "class a {}" and "class A {}" can coexist; 
"A::foo()" and "a:foo()" are two separate calls
class_name_sensitivity = 0

I'm aware this has been discussed before (as early as 2003, 
https://bugs.php.net/bug.php?id=26575&edit=1), however web app development has 
come a long way in nearly a decade and I think it's worth re-examining this, 
especially since it should be possible to do in a non-breaking manner.


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Aug 23 04:01:26 2019 UTC