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: 2020-04-07 10:15 UTC
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: Suspended Package: Class/Object related
PHP Version: Irrelevant OS: OS X, CentOS
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: eric at wepay dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-04-07 10:15 UTC] cmb@php.net
-Status: Open +Status: Suspended
 [2020-04-07 10:15 UTC] cmb@php.net
This feature appears to be controversial (because INI settings
affecting language behavior are), so would require discussion on
the internals mailing list[1].  Feel free to start the discussion
there; for the time being, I'm suspending this ticket.

[1] <https://www.php.net/mailing-lists.php#internals>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 01 23:01:29 2024 UTC