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) { return $callback(5); } $x = showCase(new class ($x) 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/sCmP2
function name:  (null)
number of ops:  23
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   INIT_FCALL                                               'showcase'
          1        DECLARE_ANON_CLASS                               <undef> 'test'
          2        NEW                                              $2      $1
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        SEND_VAR                                                 $2
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !0, $4
   39     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !0, 'multiplyByNo'
         10        SEND_VAL_EX                                              10
         11        DO_FCALL                                      0  $6      
         12        SEND_VAR                                                 $6
         13        DO_ICALL                                                 
   40    14        INIT_FCALL                                               'var_dump'
         15        INIT_METHOD_CALL                                         !0, 'getParentVar'
         16        DO_FCALL                                      0  $8      
         17        SEND_VAR                                                 $8
         18        DO_ICALL                                                 
   41    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/sCmP2
function name:  showCase
number of ops:  6
compiled vars:  !0 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        INIT_DYNAMIC_CALL                                        !0
          2        SEND_VAL_EX                                              5
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   16     5*     > 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/sCmP2
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/sCmP2
function name:  __construct
number of ops:  6
compiled vars:  !0 = $classArg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        INIT_STATIC_METHOD_CALL                                  
          2        DO_FCALL                                      0          
   24     3        ASSIGN_OBJ                                               'holder'
          4        OP_DATA                                                  !0
   25     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/sCmP2
function name:  multiplyByNo
number of ops:  5
compiled vars:  !0 = $multiplier
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   29     1        FETCH_OBJ_R                                      ~1      'holder'
          2        MUL                                              ~2      !0, ~1
          3      > RETURN                                                   ~2
   30     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/sCmP2
function name:  getParentVar
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   FETCH_OBJ_R                                      ~1      'protectedVariable'
          1        ASSIGN_OBJ                                               'publicVar'
          2        OP_DATA                                                  ~1
   35     3        FETCH_OBJ_R                                      ~2      'protectedVariable'
          4      > RETURN                                                   ~2
   36     5*     > RETURN                                                   null

End of function getparentvar

End of class Test@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.3 ms | 1394 KiB | 16 Q