|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patchesself-parent-static-token-case-insensitive (last revision 2012-01-21 20:32 UTC by mario at include-once dot org)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-01-28 02:07 UTC] stas@php.net
-Status: Open
+Status: Closed
[2013-01-28 02:07 UTC] stas@php.net
[2013-11-17 09:31 UTC] laruence@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 10:00:01 2025 UTC |
Description: ------------ "parent" and "self", "static" LSB tokens behave inconsistent when it comes to case-sensitivity. Class names in PHP are case-insensitive, but these three keywords aren't always, as the parser sees them as raw T_STRINGs. That is, you cannot do `SELF::CNST` or `SELF::$VAR` or `SELF::METHOD()` But it's possible to use `constant("SELF::CNST")` or `call_user_func` with uppercase `SELF` keyword. Likewise do you get an error message for `class SELF {}` declarations, even if the other error messages indicate the uppercase class name wasn't reserved. ---- Patch: It's just a matter of exchanging `memcmp` against `strncasecmp` in `zend_get_class_fetch_type`. Not sure if that is a sufficient substition though. It works well, and all comparisons are shadowed by a length check anyway, so little worries about NUL byte length discrepancies. Performance: No idea. This affects the parser, hard to test without memory exhausting script (eval to redeclare classes). But in clang build no measurable difference (again, pointless test with only x10000 runs). ---- Should this be fixed? Well, of course. This might not matter to most people, never run into this myself IIRC, but it does in fact come up as issue occasionally: http://stackoverflow.com/questions/8953208/fatal-error-class-self-not-found Also because it's not mentioned in the manual yet. http://www.php.net/manual/en/language.oop5.late-static-bindings.php (I shall commit a note there myself...) And of course, the whole PHP 5.3 series doesn't support it. But that doesn't mean it shouldn't be normalized in later versions, specifically the upcoming 5.4. ("Never too later to fix a mistake.." bla bla) Test script: --------------- class a { const C = "C"; function __construct() { print SELF::C; } } new a;