rfc:consistent_callables

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
rfc:consistent_callables [2019/04/28 03:01]
danack
rfc:consistent_callables [2019/04/28 03:08] (current)
danack
Line 225: Line 225:
  
   - A string that is the name of a function.   - A string that is the name of a function.
-  - An array consisting of two elements; a string at index 0 which is a valid fully qualified class name, and a string at index 1 which must meet the conditionseither be the name of a public static function of the class or the class must have a magic __callStatic method, also the name must not be that of an instance method. +  - An array consisting of two elements; a string at index 0 which is a valid fully qualified class name, and a string at index 1 which must meet the conditions
-  - An array consisting of two elements; an object at index 0, and a string at index 1 where either the string is the name of a public method of the object, or the object has a magic __call method.  ​+    * either be the name of a public static function of the class or the class must have a magic %%__callStatic%% method
 +    * the name must not be that of an instance method. 
 +  - An array consisting of two elements; an object at index 0, and a string at index 1 where either the string is the name of a public method of the object, or the object has a magic %%__call%% method. 
 +  - A string of the form `%CLASS_NAME%::​%STATIC_METHOD_NAME%` where %CLASS_NAME% is fully qualified class name, and %STATIC_METHOD_NAME% which must meet the conditions:​ 
 +    * either be the name of a public static function of the class or the class must have a magic %%__callStatic%% method. 
 +    * the name must not be that of an instance method.
   - An instance of a class (an object) where the class has a public __invoke() method.   - An instance of a class (an object) where the class has a public __invoke() method.
   - Closures, which includes anonymous functions.   - Closures, which includes anonymous functions.
 +
  
 Note - Does not affect calling private/​protected methods in correct scope Note - Does not affect calling private/​protected methods in correct scope
Line 253: Line 259:
 </​code>​ </​code>​
  
-In this example, although `$fn` is not a callable that can be passed around to arbitrary scopes, it is valid to call it in the scope that it's in. call_user_func and $fn() will continue to check whether the variable passed in is callable in the current scope. i.e. with is_callable($fn,​ $syntaxOnly = false, $currentScope = true)+In this example, although `$fn` is not a callable that can be passed around to arbitrary scopes, it is valid to call it inside ​the class scope that it's in. 
  
 ==== The strings '​self',​ '​parent',​ and '​static'​ are no longer usable as part of a string callable ====  ==== The strings '​self',​ '​parent',​ and '​static'​ are no longer usable as part of a string callable ==== 
rfc/consistent_callables.txt · Last modified: 2019/04/28 03:08 by danack