3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Retriever { private static $instance; protected $listOfVars = array(); public static function getInstance() { if(self::$instance) return self::$instance; self::$instance = new self(); return self::$instance; } private function __construct() {} public function addVar($var) { array_push($this->listOfVars, $var); return $this; } public function getVars() { return $this->listOfVars; } public function reset() { $this->listOfVars = array(); return $this; } } function name($var1, $var2, $var3) { echo $var1; } function anotherName($var1, $var2) { echo $var2; } Retriever::getInstance()->addVar("var1text")->addVar("var2text")->addVar("var3text"); name(...Retriever::getInstance()->getVars()); # Output: var1test Retriever::getInstance()->reset()->addVar("var1text")->addVar("var2text"); anotherName(...Retriever::getInstance()->getVars()); # Output: var2text
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjcGe
function name:  (null)
number of ops:  38
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   INIT_STATIC_METHOD_CALL                                      'Retriever', 'getInstance'
          1        DO_FCALL                                          0  $0      
          2        INIT_METHOD_CALL                                             $0, 'addVar'
          3        SEND_VAL_EX                                                  'var1text'
          4        DO_FCALL                                          0  $1      
          5        INIT_METHOD_CALL                                             $1, 'addVar'
          6        SEND_VAL_EX                                                  'var2text'
          7        DO_FCALL                                          0  $2      
          8        INIT_METHOD_CALL                                             $2, 'addVar'
          9        SEND_VAL_EX                                                  'var3text'
         10        DO_FCALL                                          0          
   28    11        INIT_FCALL                                                   'name'
         12        INIT_STATIC_METHOD_CALL                                      'Retriever', 'getInstance'
         13        DO_FCALL                                          0  $4      
         14        INIT_METHOD_CALL                                             $4, 'getVars'
         15        DO_FCALL                                          0  $5      
         16        SEND_UNPACK                                                  $5
         17        CHECK_UNDEF_ARGS                                             
         18        DO_FCALL                                          0          
   30    19        INIT_STATIC_METHOD_CALL                                      'Retriever', 'getInstance'
         20        DO_FCALL                                          0  $7      
         21        INIT_METHOD_CALL                                             $7, 'reset'
         22        DO_FCALL                                          0  $8      
         23        INIT_METHOD_CALL                                             $8, 'addVar'
         24        SEND_VAL_EX                                                  'var1text'
         25        DO_FCALL                                          0  $9      
         26        INIT_METHOD_CALL                                             $9, 'addVar'
         27        SEND_VAL_EX                                                  'var2text'
         28        DO_FCALL                                          0          
   31    29        INIT_FCALL                                                   'anothername'
         30        INIT_STATIC_METHOD_CALL                                      'Retriever', 'getInstance'
         31        DO_FCALL                                          0  $11     
         32        INIT_METHOD_CALL                                             $11, 'getVars'
         33        DO_FCALL                                          0  $12     
         34        SEND_UNPACK                                                  $12
         35        CHECK_UNDEF_ARGS                                             
         36        DO_FCALL                                          0          
         37      > RETURN                                                       1

Function name:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjcGe
function name:  name
number of ops:  5
compiled vars:  !0 = $var1, !1 = $var2, !2 = $var3
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   20     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   21     3        ECHO                                                         !0
   22     4      > RETURN                                                       null

End of function name

Function anothername:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjcGe
function name:  anotherName
number of ops:  4
compiled vars:  !0 = $var1, !1 = $var2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   23     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   24     2        ECHO                                                         !1
   25     3      > RETURN                                                       null

End of function anothername

Class Retriever:
Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjcGe
function name:  getInstance
number of ops:  11
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   FETCH_STATIC_PROP_R              unknown             ~0      'instance'
          1      > JMPZ                                                         ~0, ->4
          2    >   FETCH_STATIC_PROP_R              unknown             ~1      'instance'
          3      > RETURN                                                       ~1
    9     4    >   NEW                              self                $3      
          5        DO_FCALL                                          0          
          6        ASSIGN_STATIC_PROP                                           'instance'
          7        OP_DATA                                                      $3
   10     8        FETCH_STATIC_PROP_R              unknown             ~5      'instance'
          9      > RETURN                                                       ~5
   11    10*     > RETURN                                                       null

End of function getinstance

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjcGe
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E > > RETURN                                                       null

End of function __construct

Function addvar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjcGe
function name:  addVar
number of ops:  9
compiled vars:  !0 = $var
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   RECV                                                 !0      
          1        INIT_FCALL                                                   'array_push'
          2        FETCH_OBJ_W                                          $1      'listOfVars'
          3        SEND_REF                                                     $1
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                                     
          6        FETCH_THIS                                           ~3      
          7      > RETURN                                                       ~3
          8*     > RETURN                                                       null

End of function addvar

Function getvars:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjcGe
function name:  getVars
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   16     0  E >   FETCH_OBJ_R                                          ~0      'listOfVars'
          1      > RETURN                                                       ~0
          2*     > RETURN                                                       null

End of function getvars

Function reset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SjcGe
function name:  reset
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   ASSIGN_OBJ                                                   'listOfVars'
          1        OP_DATA                                                      <array>
          2        FETCH_THIS                                           ~1      
          3      > RETURN                                                       ~1
          4*     > RETURN                                                       null

End of function reset

End of class Retriever.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.59 ms | 2537 KiB | 16 Q