-
Notifications
You must be signed in to change notification settings - Fork 3
short method references #2
Comments
Should this work only with static access? It could be problematic with access inside the class because you can have a property and a method with the same name. And with static methods, this is already possible. Strings that reference static methods are callable: >>> class Bar { public static function xyz() { return 'foo'; } }
>>> 'Bar::xyz'();
=> "foo" |
@stancl This should work with non static method also. It should not be used for properties, only methods.
The only "problem" I really see with it is that the same syntax is used for constants. However in that case, I think the constant should have priority. |
In real world constants are usually written in uppercase and methods in camelcase so it's not a real problem. In my opinion Plus should simply throw an error if a class has both a method and a constant with the same name. |
@enumag Yeah, I like the idea of just throwing an error. And the uppercase/camelcase scenario was also why I sad "problem" 👍 |
So in PHP we can make a method reference by using this syntax right now
I propose that we add a short method reference syntax like so
The text was updated successfully, but these errors were encountered: