3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { protected $protectedVariable; public function __construct() { $this->protectedVariable = 'this belongs to test class'; } } $x = new class ($passedVar) extends Test { public $holder; public $publicVar; public function __construct($classArg) { parent::__construct(); $this->holder = $classArg; } public function multiplyByNo($multiplier) { return $this->holder * $multiplier; } }; $templateFunction = function ($someNumber) { return $this->multiplyByNo($someNumber); }; var_dump($x->call($templateFunction, 10));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sCS89
function name:  (null)
number of ops:  15
compiled vars:  !0 = $x, !1 = $passedVar, !2 = $templateFunction
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   DECLARE_ANON_CLASS                               <unknown> 'test'
          1        NEW                                              $4      $3
          2        SEND_VAR_EX                                              !1
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $4
   29     5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FsCS89%3A29%241'
          6        ASSIGN                                                   !2, ~7
   30     7        INIT_FCALL                                               'var_dump'
          8        INIT_METHOD_CALL                                         !0, 'call'
          9        SEND_VAR_EX                                              !2
         10        SEND_VAL_EX                                              10
         11        DO_FCALL                                      0  $9      
         12        SEND_VAR                                                 $9
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FsCS89%3A29%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sCS89
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $someNumber
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        FETCH_THIS                                       $1      
          2        INIT_METHOD_CALL                                         $1, 'multiplyByNo'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5      > RETURN                                                   $2
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FsCS89%3A29%241

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sCS89
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ASSIGN_OBJ                                               'protectedVariable'
          1        OP_DATA                                                  'this+belongs+to+test+class'
   10     2      > RETURN                                                   null

End of function __construct

End of class Test.

Class Test@anonymous:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sCS89
function name:  __construct
number of ops:  6
compiled vars:  !0 = $classArg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        INIT_STATIC_METHOD_CALL                                  
          2        DO_FCALL                                      0          
   20     3        ASSIGN_OBJ                                               'holder'
          4        OP_DATA                                                  !0
   21     5      > RETURN                                                   null

End of function __construct

Function multiplybyno:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sCS89
function name:  multiplyByNo
number of ops:  5
compiled vars:  !0 = $multiplier
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        FETCH_OBJ_R                                      ~1      'holder'
          2        MUL                                              ~2      !0, ~1
          3      > RETURN                                                   ~2
   26     4*     > RETURN                                                   null

End of function multiplybyno

End of class Test@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
196.67 ms | 1400 KiB | 15 Q