jclaveau /
php-deferred-callchain
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * File gathering functions |
||
| 4 | */ |
||
| 5 | |||
| 6 | if (! function_exists('type_exists')) { |
||
| 7 | /** |
||
| 8 | * Checks if a type is a valid PHP one. |
||
| 9 | * |
||
| 10 | * @param string $type_name The type name to check |
||
| 11 | * @return bool The result |
||
| 12 | */ |
||
| 13 | function type_exists($type_name) |
||
| 14 | { |
||
| 15 | return in_array($type_name, [ |
||
| 16 | "boolean", |
||
| 17 | "integer", |
||
| 18 | "double", |
||
| 19 | "string", |
||
| 20 | "array", |
||
| 21 | "object", |
||
| 22 | "resource", |
||
| 23 | "resource (closed)", |
||
| 24 | "NULL", |
||
| 25 | "unknown type" |
||
| 26 | ]); |
||
| 27 | } |
||
| 28 | } |
||
| 29 | |||
| 30 | if (! function_exists('later')) { |
||
| 31 | /** |
||
| 32 | * Create a deferred call chain in a functionnal way. |
||
| 33 | * |
||
| 34 | * @param string $class_type_interface_or_instance The expected target class/type/interface/instance |
||
| 35 | * @return \JClaveau\Async\DeferredCallChain |
||
| 36 | */ |
||
| 37 | function later($class_type_interface_or_instance=null) |
||
| 38 | { |
||
| 39 | return new \JClaveau\Async\DeferredCallChain(...func_get_args()); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 40 | } |
||
| 41 | } |
||
| 42 |