3v4l.org

run code in 300+ PHP versions simultaneously
<?php class struct { private $args; function __construct(array $args) { $this->args = $args; } function __invoke(callable $signature) : array { return $signature(...array_values($this->args)); } } final class Dinosaur extends struct { function signature(int $legs) : array { return get_defined_vars(); } } $two_legs = function(Dinosaur $dino) : Dinosaur { $trex = $dino([$dino, 'signature']); $trex['legs'] = 2; return new Dinosaur($trex); }; var_dump($two_legs(new Dinosaur([0])));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YOWWT
function name:  (null)
number of ops:  12
compiled vars:  !0 = $two_legs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FYOWWT%3A19%240'
          1        ASSIGN                                                   !0, ~1
   25     2        INIT_FCALL                                               'var_dump'
          3        INIT_DYNAMIC_CALL                                        !0
          4        NEW                                              $3      'Dinosaur'
          5        SEND_VAL_EX                                              <array>
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $3
          8        DO_FCALL                                      0  $5      
          9        SEND_VAR                                                 $5
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FYOWWT%3A19%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YOWWT
function name:  {closure}
number of ops:  16
compiled vars:  !0 = $dino, !1 = $trex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        INIT_DYNAMIC_CALL                                        !0
          2        INIT_ARRAY                                       ~2      !0
          3        ADD_ARRAY_ELEMENT                                ~2      'signature'
          4        SEND_VAL_EX                                              ~2
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !1, $3
   21     7        ASSIGN_DIM                                               !1, 'legs'
          8        OP_DATA                                                  2
   22     9        NEW                                              $6      'Dinosaur'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0          
         12        VERIFY_RETURN_TYPE                                       $6
         13      > RETURN                                                   $6
   23    14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FYOWWT%3A19%240

Class struct:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YOWWT
function name:  __construct
number of ops:  4
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        ASSIGN_OBJ                                               'args'
          2        OP_DATA                                                  !0
    7     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/YOWWT
function name:  __invoke
number of ops:  13
compiled vars:  !0 = $signature
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        INIT_DYNAMIC_CALL                                        !0
          2        INIT_FCALL                                               'array_values'
          3        FETCH_OBJ_R                                      ~1      'args'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6        SEND_UNPACK                                              $2
          7        CHECK_UNDEF_ARGS                                         
          8        DO_FCALL                                      1  $3      
          9        VERIFY_RETURN_TYPE                                       $3
         10      > RETURN                                                   $3
   10    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function __invoke

End of class struct.

Class Dinosaur:
Function signature:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YOWWT
function name:  signature
number of ops:  7
compiled vars:  !0 = $legs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'get_defined_vars'
          2        DO_ICALL                                         $1      
          3        VERIFY_RETURN_TYPE                                       $1
          4      > RETURN                                                   $1
   16     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function signature

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YOWWT
function name:  __construct
number of ops:  4
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        ASSIGN_OBJ                                               'args'
          2        OP_DATA                                                  !0
    7     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/YOWWT
function name:  __invoke
number of ops:  13
compiled vars:  !0 = $signature
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        INIT_DYNAMIC_CALL                                        !0
          2        INIT_FCALL                                               'array_values'
          3        FETCH_OBJ_R                                      ~1      'args'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6        SEND_UNPACK                                              $2
          7        CHECK_UNDEF_ARGS                                         
          8        DO_FCALL                                      1  $3      
          9        VERIFY_RETURN_TYPE                                       $3
         10      > RETURN                                                   $3
   10    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function __invoke

End of class Dinosaur.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.1 ms | 1408 KiB | 19 Q