3v4l.org

run code in 500+ PHP versions simultaneously
<?php namespace Potherca\Example\TypeHints; class Example { public static function typeHintMissing($subject) { return $subject; } public static function typeHintCallable(callable $subject) { return $subject; } public static function typeHintClosure(\Closure $subject) { return $subject; } public function __invoke($subject) { return $subject; } } $output = <<<'TXT' ================================================================================ (%d) %s : %s callable : %s __invoke : %s closure : %s TXT; $example = new Example(); $callables = array( 1 => 'foo', 2 => 'trim', 3 => '\Potherca\Example\TypeHints\Example::typeHintMissing', 4 => array('\Potherca\Example\TypeHints\Example', 'typeHintMissing'), 5 => array($example, 'typeHintMissing'), 6 => $example, 7 => function ($subject) {return $subject;}, ); array_walk($callables, function ($callable, $key) use ($output) { $is_callable = is_callable($callable); $is_invoke = method_exists($callable, '__invoke'); $is_closure = $callable instanceof \Closure; if ($is_callable === true) { /** @noinspection VariableFunctionsUsageInspection */ call_user_func($callable, 'foo'); Example::typeHintCallable($callable); } if ($is_closure === true) { Example::typeHintClosure($callable); } if ($is_invoke === true) { $callable('foo'); } vprintf($output, array( 'key' => $key, 'type' => gettype($callable), 'value' => str_replace(array("\n", ' '), '', var_export($callable, true)), 'is_callable' => var_export($is_callable, true), 'is_invoke' => var_export($is_invoke, true), 'is_closure' => var_export($is_closure, true), )); });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jqMtg
function name:  (null)
number of ops:  22
compiled vars:  !0 = $output, !1 = $example, !2 = $callables
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   28     0  E >   ASSIGN                                                       !0, '%0A%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A%28%25d%29+%25s+%3A++%25s%0A%0A++++callable+%3A+%25s%0A++++__invoke+%3A+%25s%0A++++closure++%3A+%25s+%0A'
   39     1        NEW                                                  $4      'Potherca%5CExample%5CTypeHints%5CExample'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !1, $4
   42     4        INIT_ARRAY                                           ~7      'foo', 1
   43     5        ADD_ARRAY_ELEMENT                                    ~7      'trim', 2
   44     6        ADD_ARRAY_ELEMENT                                    ~7      '%5CPotherca%5CExample%5CTypeHints%5CExample%3A%3AtypeHintMissing', 3
   42     7        ADD_ARRAY_ELEMENT                                    ~7      <array>, 4
   46     8        INIT_ARRAY                                           ~8      !1
          9        ADD_ARRAY_ELEMENT                                    ~8      'typeHintMissing'
         10        ADD_ARRAY_ELEMENT                                    ~7      ~8, 5
   47    11        ADD_ARRAY_ELEMENT                                    ~7      !1, 6
   48    12        DECLARE_LAMBDA_FUNCTION                              ~9      [0]
         13        ADD_ARRAY_ELEMENT                                    ~7      ~9, 7
   41    14        ASSIGN                                                       !2, ~7
   51    15        INIT_NS_FCALL_BY_NAME                                        'Potherca%5CExample%5CTypeHints%5Carray_walk'
         16        SEND_VAR_EX                                                  !2
         17        DECLARE_LAMBDA_FUNCTION                              ~11     [1]
         18        BIND_LEXICAL                                                 ~11, !0
   79    19        SEND_VAL_EX                                                  ~11
   51    20        DO_FCALL                                          0          
   79    21      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jqMtg
function name:  {closure:/in/jqMtg:48}
number of ops:  3
compiled vars:  !0 = $subject
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   48     0  E >   RECV                                                 !0      
          1      > RETURN                                                       !0
          2*     > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 33
Branch analysis from position: 30
2 jumps found. (Code = 208) Position 1 = 41, Position 2 = 51
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 28
Branch analysis from position: 23
filename:       /in/jqMtg
function name:  {closure:/in/jqMtg:51}
number of ops:  76
compiled vars:  !0 = $callable, !1 = $key, !2 = $output, !3 = $is_callable, !4 = $is_invoke, !5 = $is_closure
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   51     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
   53     3        INIT_NS_FCALL_BY_NAME                                        'Potherca%5CExample%5CTypeHints%5Cis_callable'
          4        SEND_VAR_EX                                                  !0
          5        DO_FCALL                                          0  $6      
          6        ASSIGN                                                       !3, $6
   54     7        INIT_NS_FCALL_BY_NAME                                        'Potherca%5CExample%5CTypeHints%5Cmethod_exists'
          8        SEND_VAR_EX                                                  !0
          9        SEND_VAL_EX                                                  '__invoke'
         10        DO_FCALL                                          0  $8      
         11        ASSIGN                                                       !4, $8
   55    12        INSTANCEOF                                           ~10     !0, 'Closure'
         13        ASSIGN                                                       !5, ~10
   57    14        TYPE_CHECK                                        8          !3
         15      > JMPZ                                                         ~12, ->23
   59    16    >   INIT_NS_FCALL_BY_NAME                                        'Potherca%5CExample%5CTypeHints%5Ccall_user_func'
         17        SEND_VAR_EX                                                  !0
         18        SEND_VAL_EX                                                  'foo'
         19        DO_FCALL                                          0          
   60    20        INIT_STATIC_METHOD_CALL                                      'Potherca%5CExample%5CTypeHints%5CExample', 'typeHintCallable'
         21        SEND_VAR                                                     !0
         22        DO_FCALL                                          0          
   63    23    >   TYPE_CHECK                                        8          !5
         24      > JMPZ                                                         ~15, ->28
   64    25    >   INIT_STATIC_METHOD_CALL                                      'Potherca%5CExample%5CTypeHints%5CExample', 'typeHintClosure'
         26        SEND_VAR                                                     !0
         27        DO_FCALL                                          0          
   67    28    >   TYPE_CHECK                                        8          !4
         29      > JMPZ                                                         ~17, ->33
   68    30    >   INIT_DYNAMIC_CALL                                            !0
         31        SEND_VAL_EX                                                  'foo'
         32        DO_FCALL                                          0          
   71    33    >   INIT_NS_FCALL_BY_NAME                                        'Potherca%5CExample%5CTypeHints%5Cvprintf'
         34        SEND_VAR_EX                                                  !2
   72    35        INIT_ARRAY                                           ~19     !1, 'key'
   73    36        INIT_NS_FCALL_BY_NAME                                        'Potherca%5CExample%5CTypeHints%5Cgettype'
         37        SEND_VAR_EX                                                  !0
         38        DO_FCALL                                          0  $20     
         39        ADD_ARRAY_ELEMENT                                    ~19     $20, 'type'
   74    40      > JMP_FRAMELESS                                   s104         'potherca%5Cexample%5Ctypehints%5Cstr_replace', ->51
         41    >   INIT_NS_FCALL_BY_NAME                                        'Potherca%5CExample%5CTypeHints%5Cstr_replace'
         42        SEND_VAL_EX                                                  <array>
         43        SEND_VAL_EX                                                  ''
         44        INIT_NS_FCALL_BY_NAME                                        'Potherca%5CExample%5CTypeHints%5Cvar_export'
         45        SEND_VAR_EX                                                  !0
         46        SEND_VAL_EX                                                  <true>
         47        DO_FCALL                                          0  $21     
         48        SEND_VAR_NO_REF_EX                                           $21
         49        DO_FCALL                                          0  $22     
         50      > JMP                                                          ->57
         51    >   INIT_NS_FCALL_BY_NAME                                        'Potherca%5CExample%5CTypeHints%5Cvar_export'
         52        SEND_VAR_EX                                                  !0
         53        SEND_VAL_EX                                                  <true>
         54        DO_FCALL                                          0  $23     
         55        FRAMELESS_ICALL_3                str_replace         $22     <array>, ''
         56        OP_DATA                                                      $23
         57    >   ADD_ARRAY_ELEMENT                                    ~19     $22, 'value'
   75    58        INIT_NS_FCALL_BY_NAME                                        'Potherca%5CExample%5CTypeHints%5Cvar_export'
         59        SEND_VAR_EX                                                  !3
         60        SEND_VAL_EX                                                  <true>
         61        DO_FCALL                                          0  $24     
         62        ADD_ARRAY_ELEMENT                                    ~19     $24, 'is_callable'
   76    63        INIT_NS_FCALL_BY_NAME                                        'Potherca%5CExample%5CTypeHints%5Cvar_export'
         64        SEND_VAR_EX                                                  !4
         65        SEND_VAL_EX                                                  <true>
         66        DO_FCALL                                          0  $25     
         67        ADD_ARRAY_ELEMENT                                    ~19     $25, 'is_invoke'
   77    68        INIT_NS_FCALL_BY_NAME                                        'Potherca%5CExample%5CTypeHints%5Cvar_export'
         69        SEND_VAR_EX                                                  !5
         70        SEND_VAL_EX                                                  <true>
         71        DO_FCALL                                          0  $26     
         72        ADD_ARRAY_ELEMENT                                    ~19     $26, 'is_closure'
         73        SEND_VAL_EX                                                  ~19
   71    74        DO_FCALL                                          0          
   79    75      > RETURN                                                       null

End of Dynamic Function 1

Class Potherca\Example\TypeHints\Example:
Function typehintmissing:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jqMtg
function name:  typeHintMissing
number of ops:  3
compiled vars:  !0 = $subject
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
    9     1      > RETURN                                                       !0
   10     2*     > RETURN                                                       null

End of function typehintmissing

Function typehintcallable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jqMtg
function name:  typeHintCallable
number of ops:  3
compiled vars:  !0 = $subject
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   RECV                                                 !0      
   14     1      > RETURN                                                       !0
   15     2*     > RETURN                                                       null

End of function typehintcallable

Function typehintclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jqMtg
function name:  typeHintClosure
number of ops:  3
compiled vars:  !0 = $subject
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   RECV                                                 !0      
   19     1      > RETURN                                                       !0
   20     2*     > RETURN                                                       null

End of function typehintclosure

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jqMtg
function name:  __invoke
number of ops:  3
compiled vars:  !0 = $subject
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   RECV                                                 !0      
   24     1      > RETURN                                                       !0
   25     2*     > RETURN                                                       null

End of function __invoke

End of class Potherca\Example\TypeHints\Example.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.25 ms | 3419 KiB | 21 Q