3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { protected $protectedVariable; public function __construct() { $this->protectedVariable = 'this belongs to test class'; } } function showCase($callback) { var_dump($callback); return $callback(5); } $x = showCase(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; } public function getParentVar() { $this->publicVar = $this->protectedVariable; return $this->protectedVariable; } }); var_dump($x->multiplyByNo(10)); var_dump($x->getParentVar()); var_dump($x);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hYUgX
function name:  (null)
number of ops:  23
compiled vars:  !0 = $x, !1 = $passedVar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'showcase'
          1        DECLARE_ANON_CLASS                               <unknown> 'test'
          2        NEW                                              $3      $2
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0          
          5        SEND_VAR                                                 $3
          6        DO_FCALL                                      0  $5      
          7        ASSIGN                                                   !0, $5
   42     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !0, 'multiplyByNo'
         10        SEND_VAL_EX                                              10
         11        DO_FCALL                                      0  $7      
         12        SEND_VAR                                                 $7
         13        DO_ICALL                                                 
   43    14        INIT_FCALL                                               'var_dump'
         15        INIT_METHOD_CALL                                         !0, 'getParentVar'
         16        DO_FCALL                                      0  $9      
         17        SEND_VAR                                                 $9
         18        DO_ICALL                                                 
   44    19        INIT_FCALL                                               'var_dump'
         20        SEND_VAR                                                 !0
         21        DO_ICALL                                                 
         22      > RETURN                                                   1

Function showcase:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hYUgX
function name:  showCase
number of ops:  9
compiled vars:  !0 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   16     4        INIT_DYNAMIC_CALL                                        !0
          5        SEND_VAL_EX                                              5
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
   17     8*     > RETURN                                                   null

End of function showcase

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hYUgX
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/hYUgX
function name:  __construct
number of ops:  6
compiled vars:  !0 = $classArg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        INIT_STATIC_METHOD_CALL                                  
          2        DO_FCALL                                      0          
   27     3        ASSIGN_OBJ                                               'holder'
          4        OP_DATA                                                  !0
   28     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/hYUgX
function name:  multiplyByNo
number of ops:  5
compiled vars:  !0 = $multiplier
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   32     1        FETCH_OBJ_R                                      ~1      'holder'
          2        MUL                                              ~2      !0, ~1
          3      > RETURN                                                   ~2
   33     4*     > RETURN                                                   null

End of function multiplybyno

Function getparentvar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hYUgX
function name:  getParentVar
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   FETCH_OBJ_R                                      ~1      'protectedVariable'
          1        ASSIGN_OBJ                                               'publicVar'
          2        OP_DATA                                                  ~1
   38     3        FETCH_OBJ_R                                      ~2      'protectedVariable'
          4      > RETURN                                                   ~2
   39     5*     > RETURN                                                   null

End of function getparentvar

End of class Test@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.47 ms | 1403 KiB | 16 Q