Re: Re: Suggestion Method Constant
| From: | Andrea Faulds | Date: | Sun, 15 Oct 2017 19:10:42 +0000 |
| Subject: | Re: Re: Suggestion Method Constant | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-100901@lists.php.net to get a copy of this message | ||
Hi Niklas,
Niklas Keller wrote:
I'm not exactly a huge fan of fallbacks myself. If we were to have such a fallback, I'd like to deprecate overlapping method/property/constant names and throw warnings to that effect, with an obvious goal of eventually merging those namespaces. …hey, if we merged properties and constants together, you could do Foo::bar = $baz; instead of having to use the annoyingly inconsistent Foo::$bar syntax. I'd love that. -- Andrea Faulds https://ajf.me/Hi Mathias, Mathias Grimm wrote:Please no fallbacks, thanks. It was already a mistake for namespaced functions.I would like to suggest a method constant that could be used the same way we use the ::class one I don't have a strong personal preference but it could be something like: MyController::myActionMethod::method, no sure about the internals but it would be consistent with the one for the class. Cheers,I've long wanted to make constant lookups fall back to a closure of the correspondingly-named function, where one exists. sostrlenwould resolve to a closure of strlen(). Thing is that classes are weird. We sort of have three different things with sometimes-similar syntax: constants, methods and properties. foo::bar is a constant, foo::bar() is a function, $foo->bar() is a function, but $foo->bar is not a constant. So, if I want $foo->bar to resolve to a method, then $foo::$bar should too, even though that makes no sense. The PHP static property syntax is the bane of my existence.