# Proposal for PHP 7 : case-sensitive symbols

- Thread: https://externals.io/message/79824
- Original archive: https://news-web.php.net/php.internals/79824
- Started by F & N Laupretre on 2014-12-20T22:01:23+00:00
- Messages: 46
- RFC: Case sensitive PHP (Withdrawn) — https://externals.io/rfc/case_sensitive_php.md
- Page 1 of 2: messages 1 to 25 (25 per page, add `?page=N` to the URL)
- Next page: https://externals.io/message/79824.md?page=2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #79824 — F & N Laupretre — 2014-12-20T22:01:23+00:00

URL: https://externals.io/message/79824#79824

Hi,

 

I don't know if this was discussed before. So, tell me what you think before
I write an RFC.

 

I would like to propose that namespaces, functions, and classes become
case-sensitive (constants are already case-sensitive). Actually, I never
understood why they are case-insensitive. Even if the performance gain is
negligible, I think it could be the right time to question this.

 

Regards

 

Francois

---

## #79825 — Paul Dragoonis — 2014-12-20T22:16:58+00:00

URL: https://externals.io/message/79824#79825 · In reply to: #79824

Hi Francois,

It's too big of a BC change firstly.

Secondly it has no language benefit or developer benefit.

The only benefit is case correctness which is a nice to have. Making sure
existing code works is a must have.

Cheers,
Paul
 

> Hi,
>
>
>
> I don't know if this was discussed before. So, tell me what you think
> before
> I write an RFC.
>
>
>
> I would like to propose that namespaces, functions, and classes become
> case-sensitive (constants are already case-sensitive). Actually, I never
> understood why they are case-insensitive. Even if the performance gain is
> negligible, I think it could be the right time to question this.
>
>
>
> Regards
>
>
>
> Francois

---

## #79826 — Alain Williams — 2014-12-20T22:44:24+00:00

URL: https://externals.io/message/79824#79826 · In reply to: #79824

> Hi,
> 
>  
> 
> I don't know if this was discussed before. So, tell me what you think before
> I write an RFC.
> 
>  
> 
> I would like to propose that namespaces, functions, and classes become
> case-sensitive (constants are already case-sensitive). Actually, I never
> understood why they are case-insensitive. Even if the performance gain is
> negligible, I think it could be the right time to question this.

Variables are also case sensitive.

Identifiers can contain a-zA-Z0-9_ + where top bit is set.

Where an identifier is a function name or class name comparison is in a case
insensitive manner ... but only for ASCII ... using tolower_map in zend_operators.c

This means that those who write function (etc) names in some encoding that is
more than US ASCII find that case comparison is done in a case sensitive manner
- at least for those parts of identifiers that are written in characters that
have the top bit set.

Fixing this would require a lot of work as well as some way of determining what
character encoding the source file was written in ... different includes might
have different encodings.

We recently talked about a way of specifying source file encoding and decided
that it was not something to look at now (IIRC).

Making namespaces, function & classes case sensitive makes PHP consistent to
everyone - not just us 'US ASCII chauvinists' -- it is also the simplest approach.

It is a BC break; one which, unfortunately, cannot be found at compile time.
However: code, when fixed (ie consistent case spelling), will continue to work
with current PHP implementations.

Although many do try to write these identifiers in a case consistent manner it
will cause problems, however I would suggest that it would be worth doing.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h

---

## #79827 — Andrea Faulds — 2014-12-20T22:45:39+00:00

URL: https://externals.io/message/79824#79827 · In reply to: #79824

Hey François, (I assume there’s a ç, I apologise if not)

> 
> 
> I don't know if this was discussed before. So, tell me what you think before
> I write an RFC.

Ah, this subject has come up before, I think. :)

> I would like to propose that namespaces, functions, and classes become
> case-sensitive (constants are already case-sensitive). Actually, I never
> understood why they are case-insensitive. Even if the performance gain is
> negligible, I think it could be the right time to question this.

I’d thought of doing this before, but the backwards-compatibility cost is too high.

I would like to see more case uniformity, but I think this is the less practical direction. Instead of making everything case-sensitive, we should make everything case-insensitive, which would break far less stuff, and is a smaller change. That’d mean constants, variable names and properties would need changing, everything else is already case-insensitive. 

I don’t think making constants and variable names case-insensitive would cause a problem. I reckon it’s unlikely that someone has two constants differing only by case, ditto for variable names, and both live in their own namespaces so this wouldn’t create conflicts. Even if someone does, this is probably quite a rare occurrence and could be easily fixed.

The problematic case is properties, because although PHP code probably doesn’t rely on them being case-sensitive most of the time, lacking preservation of case for serialised properties would be quite a problem. For example, an object serialised to JSON and then decoded might, with the right flags passed, be unserialised as an array. Array keys are case-sensitive in PHP (as they should be, I don’t want to change that), so now a lookup that worked before might not now because the case wasn’t preserved. Even if we took care to preserve case, there’s also the problem of objects used as associative arrays, which we explicitly encourage with ArrayObject. Plus, JSON objects decode to PHP objects by default, so objects used as case-sensitive dictionaries in incoming JSON would break. For these reasons, I don’t think we should touch properties.

In summary, case-sensitivity everywhere would be a massive BC break, but case-insensitivity for everything except properties might be doable.

Thanks for writing! :)
--
Andrea Faulds
http://ajf.me/

---

## #79828 — Alain Williams — 2014-12-20T22:52:19+00:00

URL: https://externals.io/message/79824#79828 · In reply to: #79827

> I would like to see more case uniformity, but I think this is the less practical direction. Instead of making everything case-sensitive, we should make everything case-insensitive, which would break far less stuff, and is a smaller change. That’d mean constants, variable names and properties would need changing, everything else is already case-insensitive. 

As I said: this is only partly true; true if you are a Brit or a Yank ...
everyone else who has alphabetics that are represented by bytes with the top bit
set sees them as case sensitive in those parts.

It is a BC break, but a very unusual one in that once code is fixed in, say PHP
7, it would continue to work when copies back to a PHP 5 environment.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h

---

## #79829 — Andrea Faulds — 2014-12-20T22:55:02+00:00

URL: https://externals.io/message/79824#79829 · In reply to: #79828

Hey Alain,

> 
> 
> 
> 
> > […]
> 
> As I said: this is only partly true; true if you are a Brit or a Yank ...
> everyone else who has alphabetics that are represented by bytes with the top bit
> set sees them as case sensitive in those parts.

That’s true. Although mixing English and another language in source code isn’t a terribly good idea anyway.

> It is a BC break, but a very unusual one in that once code is fixed in, say PHP
> 7, it would continue to work when copies back to a PHP 5 environment.

This isn’t that unusual among BC breaks, honestly.

Thanks.
--
Andrea Faulds
http://ajf.me/

---

## #79830 — Kevin Israel — 2014-12-20T23:32:17+00:00

URL: https://externals.io/message/79824#79830 · In reply to: #79825

> It's too big of a BC change firstly.
> 
> Secondly it has no language benefit or developer benefit.

Are you sure? Autoloading schemes such as PSR-4 derive pathnames from
class names without converting them to lowercase. If case mismatches go
undetected and unreported, a project might work on a developer's Windows
desktop (case-insensitive) yet not when uploaded to a Linux web server
(case-sensitive). Or when an object instantiation or a static method
call using the correct case is removed from the code, a later call using
the incorrect case might break.

Backward compatibility is perhaps a good reason to not make this change.
However, I would like to see at least an option to report case
mismatches in class names as `E_STRICT` errors and possibly a way to
disable that for specific files or classes when necessary.

>  

> > […]

---

## #79831 — Yasuo Ohgaki — 2014-12-21T00:19:55+00:00

URL: https://externals.io/message/79824#79831 · In reply to: #79824

Hi all,

On Sun, Dec 21, 2014 at 7:01 AM, F & N Laupretre <nf.laupretre@yahoo.fr>
wrote:

> I would like to propose that namespaces, functions, and classes become
> case-sensitive (constants are already case-sensitive). Actually, I never
> understood why they are case-insensitive. Even if the performance gain is
> negligible, I think it could be the right time to question this.
>

Defining

thisismyfunction() {}

then call it

THISisMYFunction()

is not recommended at all. Keeping not recommended spec forever is not
a good idea. IMHO. Using `strtolower()` all over place in the Engine to keep
running not recommended code does not make much sense.

It's BC, but it would be easy spot it by an compatibility check script. Once
case is used properly, scripts run both new and old PHP. Therefore,
BC issue is not critical.

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #79832 — francois@tekwire.net — 2014-12-21T00:31:09+00:00

URL: https://externals.io/message/79824#79832 · In reply to: #79827

> De : Andrea Faulds [mailto:ajf@ajf.me]
> I’d thought of doing this before, but the backwards-compatibility cost is too
> high.

It is a BC break, I agree, but would the impact on PHP community be so high ? I have never seen any PHP code which would rely on function/class names case-insensitivity. I tested this with Automap, a map-based autoloader, modified to work in a case-sensitive manner. I tested most PHP frameworks and libraries and none of them had case mismatches. There are some, probably, but I guess that most, if not all, are undetected typos. Can't we consider such a mismatch as a bug ? That's what any normal programmer would think, IMHO. So, I think that such a BC break on a problematic syntax is acceptable, and would even help clean some PHP code.

What we can do to minimize the BC break, in the spirit of the migration path discussed these last days, is to introduce an `E_STRICT` warning in version 5.7, which would help programmers prepare their code for PHP 7.

Regards

François

---

## #79833 — francois@tekwire.net — 2014-12-21T00:50:48+00:00

URL: https://externals.io/message/79824#79833

I just read Nikita's RFC on deprecated features for PHP 7.
 
Couldn't we go this way and use his process ? add to his list the fact that
functions, classes, and namespaces can be declared and used/called with
case-sensitivity mismatches ? This would become clearly known by
everyone. Then, as any other deprecated feature, raise an `E_STRICT` warning
in 5.7, and deprecate it in 7.

---

## #79839 — Stanislav Malyshev — 2014-12-21T05:14:06+00:00

URL: https://externals.io/message/79824#79839 · In reply to: #79831

Hi!

> is not recommended at all. Keeping not recommended spec forever is not
> a good idea. IMHO. Using `strtolower()` all over place in the Engine to keep

There's a huge difference between "not recommended" and breaking the
code. Using if() without braces, or inconsistent indentation - is not
recommended. Making such code not work would be a huge mistake.

> It's BC, but it would be easy spot it by an compatibility check script. Once
> case is used properly, scripts run both new and old PHP. Therefore,
> BC issue is not critical.

There's no "therefore" - you'll still have to fix all that code, and if
you think it all will be findable by a simple script, you severely
underestimate the dynamic nature of things people do with PHP. This is a
very big change and should not be dismissed lightly.

-- 
Stas Malyshev
smalyshev@gmail.com

---

## #79840 — Pierre Joye — 2014-12-21T05:20:13+00:00

URL: https://externals.io/message/79824#79840 · In reply to: #79824

> Hi,
>
>
>
> I don't know if this was discussed before. So, tell me what you think before
> I write an RFC.
>
>
>
> I would like to propose that namespaces, functions, and classes become
> case-sensitive (constants are already case-sensitive). Actually, I never
> understood why they are case-insensitive. Even if the performance gain is
> negligible, I think it could be the right time to question this.

I have hard time to see the benefits of breaking so many codes for that.

Userland codes use to rely on case sensitivity naming, based on coding
standard. But for internals names, it is going to be a major pain.

Cheers,
Pierre

---

## #79843 — Alain Williams — 2014-12-21T10:12:19+00:00

URL: https://externals.io/message/79824#79843 · In reply to: #79840

> I have hard time to see the benefits of breaking so many codes for that.

Has anyone done any benchmarking on the overhead of the internal/hidden convert
to lower case of function/... names ?

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php
#include <std_disclaimer.h

---

## #79847 — Rowan Collins — 2014-12-21T12:55:38+00:00

URL: https://externals.io/message/79824#79847 · In reply to: #79826

>Fixing this would require a lot of work as well as some way of
>determining what
>character encoding the source file was written in ... different
>includes might
>have different encodings.
>
>We recently talked about a way of specifying source file encoding and
>decided
>that it was not something to look at now (IIRC).

I haven't read the whole thread yet, so apologies if someone's mentioned this already, but far from being a rejected feature, specifying source file encoding is already possible, using declare(encoding=...)

The problem is what to do with that information: presumably, identifiers would need to be converted to an internal encoding (prob utf8), case folded, and normalised (in the Unicode sense of that term). Ideally, this would happen during compilation and stored appropriately in the OpCache, but a run-time path for userland strings would also be necessary.

---

## #79854 — David Muir — 2014-12-21T23:33:03+00:00

URL: https://externals.io/message/79824#79854 · In reply to: #79830

> 
> 
> > […]
> 
> Are you sure? Autoloading schemes such as PSR-4 derive pathnames from
> class names without converting them to lowercase. If case mismatches go
> undetected and unreported, a project might work on a developer's Windows
> desktop (case-insensitive) yet not when uploaded to a Linux web server
> (case-sensitive). Or when an object instantiation or a static method
> call using the correct case is removed from the code, a later call using
> the incorrect case might break.
> 
> Backward compatibility is perhaps a good reason to not make this change.
> However, I would like to see at least an option to report case
> mismatches in class names as `E_STRICT` errors and possibly a way to
> disable that for specific files or classes when necessary.
> 
> > […]
> 
> > […]
> 
> -- 
> 
> 
> 


+1 on `E_STRICT` warning for case mismatch on class names. Also +1 on eventual case sensitivity for userland class names. Not convinced the rest is worth it.

The insensitivity makes code brittle. Sometimes the same code will run fine, and other times it breaks depending on what lines triggered the auto loader. If you instantiate a Foo instance first, then instantiate a new foo, the code runs fine, but if you try to instantiate a new foo first, we get a fatal error.

Cheers,
David

---

## #79855 — Andrea Faulds — 2014-12-22T00:43:20+00:00

URL: https://externals.io/message/79824#79855 · In reply to: #79854

Hey,

> 
> 
> The insensitivity makes code brittle. Sometimes the same code will run fine, and other times it breaks depending on what lines triggered the auto loader. If you instantiate a Foo instance first, then instantiate a new foo, the code runs fine, but if you try to instantiate a new foo first, we get a fatal error.

I’d say that’s not the fault of insensitivity, but the fault of poorly-written autoloaders.

Thanks.
--
Andrea Faulds
http://ajf.me/

---

## #79856 — Marco Pivetta — 2014-12-22T00:50:41+00:00

URL: https://externals.io/message/79824#79856 · In reply to: #79855

> Hey,
>
> > […]
> fine, and other times it breaks depending on what lines triggered the auto
> loader. If you instantiate a Foo instance first, then instantiate a new
> foo, the code runs fine, but if you try to instantiate a new foo first, we
> get a fatal error.
>
> I’d say that’s not the fault of insensitivity, but the fault of
> poorly-written autoloaders.


I'd like to know if there's an autoloader that handles case sensitivity
without O(2^n) stat calls worst-case scenario (N being namespace/class name
parts chars).
A stricts standards warning in case of type sensitivity issues after a
class with the same was already loaded would make a lot of sense:

class Foo {}

$foo = new Foo;

$bar = ($foo instanceof foo); // stricts standards

Same goes for type-hints in methods, as those may break reflection (which
triggers autoloading).

Greets,

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

---

## #79857 — Andrea Faulds — 2014-12-22T00:52:53+00:00

URL: https://externals.io/message/79824#79857 · In reply to: #79856

> 
> 
> 
> 
> > […]
> 
> 
> I'd like to know if there's an autoloader that handles case sensitivity
> without O(2^n) stat calls worst-case scenario (N being namespace/class name
> parts chars).

Yes. Those running on Windows or OS X (both use case-insensitive filesystems by default), those that convert the class name to lowercase, those that error on non-lowercase class names, etc.

--
Andrea Faulds
http://ajf.me/

---

## #79858 — Marco Pivetta — 2014-12-22T01:02:45+00:00

URL: https://externals.io/message/79824#79858 · In reply to: #79857

>
> > […]
> auto
> > […]
> we
> > […]
> name
> > […]
>
> Yes. Those running on Windows or OS X (both use case-insensitive
> filesystems by default),
>

 Except that nobody I know of runs production on a case-insensitive
filesystem.

those that convert the class name to lowercase, those that error on
> non-lowercase class names, etc.
>

That's an interesting idea to be honest: could be brought up in the
composer mailing list, I'd say.


Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

---

## #79859 — Pierre Joye — 2014-12-22T03:58:17+00:00

URL: https://externals.io/message/79824#79859 · In reply to: #79858

>
> 
>
> > […]

>  Except that nobody I know of runs production on a case-insensitive
> filesystem.

I know a lot, really a lot.

---

## #79860 — Andrea Faulds — 2014-12-22T04:00:26+00:00

URL: https://externals.io/message/79824#79860 · In reply to: #79859

> 
> 
> 
> 
> > […]
> 
> > […]
> 
> I know a lot, really a lot.

Yeah, I think it’s too easy to forget that not everyone’s using something Unix-like… a lot of people use Windows Server!

--
Andrea Faulds
http://ajf.me/

---

## #79861 — Mike Dugan — 2014-12-22T04:05:38+00:00

URL: https://externals.io/message/79824#79861 · In reply to: #79860

Development should also be a consideration, I see a lot of developers using Windows for local development (even on the irc channels). These are the same ones who are, in my experience, less likely to be aware of solutions like Vagrant just as much as the subtleties of case sensitivity across operating systems.

Mike Dugan

Sent from my iPhone

> 
> 
> 
> > […]
> 
> Yeah, I think it’s too easy to forget that not everyone’s using something Unix-like… a lot of people use Windows Server!
> 
> --
> Andrea Faulds
> http://ajf.me/

---

## #79862 — Pierre Joye — 2014-12-22T04:35:46+00:00

URL: https://externals.io/message/79824#79862 · In reply to: #79861

> Development should also be a consideration, I see a lot of developers using Windows for local development (even on the irc channels). These are the same ones who are, in my experience, less likely to be aware of solutions like Vagrant just as much as the subtleties of case sensitivity across operating systems.

I think we coul  be more realistic here.

In my opinion the pains introduced by such a change does not match
with any possible gains. Many areas affect the request time badly
(IOs, mem, etc), I do not see case insensitivity as one, even if it
may look very bad if a simple small script is taken as example of the
slowdown (obviously worst case).

I am not saying discussing that is bad, but it may not be the most
important thing to spend time on :)

---

## #79863 — Xinchen Hui — 2014-12-22T05:24:53+00:00

URL: https://externals.io/message/79824#79863 · In reply to: #79862

> 
> > […]
>
> I think we coul  be more realistic here.
>
> In my opinion the pains introduced by such a change does not match
> with any possible gains. Many areas affect the request time badly
> (IOs, mem, etc), I do not see case insensitivity as one, even if it
> may look very bad if a simple small script is taken as example of the
> slowdown (obviously worst case).
>
> I am not saying discussing that is bad, but it may not be the most
> important thing to spend time on :)
Agree..

I am afraid that will never happen(case-sesentive class/function name)
in the whole php life

thanks
>
> --
> 
> 
>



-- 
Xinchen Hui
@Laruence
http://www.laruence.com/

---

## #79867 — Lester Caine — 2014-12-22T09:18:29+00:00

URL: https://externals.io/message/79824#79867 · In reply to: #79863

If the core functionality remains ASCII based then there is no need to drop case insensitivity, but if there is a move to better multi-lingual support, then it may be necessary for compatibility with Unicode?

Sent from my android device so the quoting is crap!

-----Original Message-----
From: Xinchen Hui <laruence@php.net>
To: Pierre Joye <pierre.php@gmail.com>
Cc: Mike Dugan <mike@mjdugan.com>, Andrea Faulds <ajf@ajf.me>, Marco Pivetta <ocramius@gmail.com>, PHP internals <internals@lists.php.net>, David Muir <davidkmuir@gmail.com>, Paul Dragoonis <dragoonis@gmail.com>, "nf.laupretre@yahoo.fr" <nf.laupretre@yahoo.fr>, Kevin Israel <pleasestand@live.com>
Sent: Mon, 22 Dec 2014 6:25 AM
Subject: Re: [PHP-DEV] Proposal for PHP 7 : case-sensitive symbols


> 
> > […]
>
> I think we coul  be more realistic here.
>
> In my opinion the pains introduced by such a change does not match
> with any possible gains. Many areas affect the request time badly
> (IOs, mem, etc), I do not see case insensitivity as one, even if it
> may look very bad if a simple small script is taken as example of the
> slowdown (obviously worst case).
>
> I am not saying discussing that is bad, but it may not be the most
> important thing to spend time on :)
Agree..

I am afraid that will never happen(case-sesentive class/function name)
in the whole php life

thanks
>
> --
> 
> 
>



-- 
Xinchen Hui
@Laruence
http://www.laruence.com/

---

Next page: https://externals.io/message/79824.md?page=2
