3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @template T */ class myInvokable { /** @var T */ private $e; /** @param T $e */ public function __construct($e) { $this->e = $e; } /** * @template B * @param callable(T): B $p * @return B */ public function __invoke($p) { return $p($this->e); } } /** * @template T * @psalm-param T $e * @return myInvokable<T> */ function foo($e): callable { return new myInvokable($e); } $_z = foo('foo')(fn (string $a) => strlen($a)); /** @psalm-trace $_z */; var_dump($_z);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EHf6N
function name:  (null)
number of ops:  12
compiled vars:  !0 = $_z
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'foo'
          1        SEND_VAL                                                 'foo'
          2        DO_FCALL                                      0  $1      
          3        INIT_DYNAMIC_CALL                                        $1
          4        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          5        SEND_VAL_EX                                              ~2
          6        DO_FCALL                                      0  $3      
          7        ASSIGN                                                   !0, $3
   35     8        INIT_FCALL                                               'var_dump'
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                                 
         11      > 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/EHf6N
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1        STRLEN                                           ~1      !0
          2      > RETURN                                                   ~1
          3*     > RETURN                                                   null

End of Dynamic Function 0

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EHf6N
function name:  foo
number of ops:  8
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   30     1        NEW                                              $1      'myInvokable'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        VERIFY_RETURN_TYPE                                       $1
          5      > RETURN                                                   $1
   31     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function foo

Class myInvokable:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EHf6N
function name:  __construct
number of ops:  4
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'e'
          2        OP_DATA                                                  !0
          3      > RETURN                                                   null

End of function __construct

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EHf6N
function name:  __invoke
number of ops:  8
compiled vars:  !0 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        INIT_DYNAMIC_CALL                                        !0
          2        CHECK_FUNC_ARG                                           
          3        FETCH_OBJ_FUNC_ARG                               $1      'e'
          4        SEND_FUNC_ARG                                            $1
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
   20     7*     > RETURN                                                   null

End of function __invoke

End of class myInvokable.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.64 ms | 1444 KiB | 15 Q