3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace App\Com; class Test { protected static $_instance; public static function getInstance() { if(!self::$_instance) { self::$_instance = new self(); } return self::$_instance; } public function test() { return 'works'; } protected function __construct() { } } class Service { protected static $_instance; protected $_connection; protected $_case = []; public static function getInstance() { if(!self::$_instance) { self::$_instance = new self(); } return self::$_instance; } protected function __construct() { $this->_case[] = Test::getInstance(); // TODO: Establish entity to database } public function using($nsp) { foreach($this->_case as $obj) { if($nsp instanceof $obj) { return $obj::getInstance(); } } throw new \Exception("Call to $nsp did not match any libraries."); } protected function __clone() {} } echo Service::getInstance()->using('\App\Com\Test')->test();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/knhjm
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   INIT_STATIC_METHOD_CALL                                  'App%5CCom%5CService', 'getInstance'
          1        DO_FCALL                                      0  $0      
          2        INIT_METHOD_CALL                                         $0, 'using'
          3        SEND_VAL_EX                                              '%5CApp%5CCom%5CTest'
          4        DO_FCALL                                      0  $1      
          5        INIT_METHOD_CALL                                         $1, 'test'
          6        DO_FCALL                                      0  $2      
          7        ECHO                                                     $2
          8      > RETURN                                                   1

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

End of function getinstance

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

End of function test

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

End of function __construct

End of class App\Com\Test.

Class App\Com\Service:
Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/knhjm
function name:  getInstance
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      '_instance'
          1        BOOL_NOT                                         ~1      ~0
          2      > JMPZ                                                     ~1, ->7
   38     3    >   NEW                          self                $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       '_instance'
          6        OP_DATA                                                  $3
   40     7    >   FETCH_STATIC_PROP_R          unknown             ~5      '_instance'
          8      > RETURN                                                   ~5
   41     9*     > 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/knhjm
function name:  __construct
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   INIT_STATIC_METHOD_CALL                                  'App%5CCom%5CTest', 'getInstance'
          1        DO_FCALL                                      0  $2      
          2        FETCH_OBJ_W                                      $0      '_case'
          3        ASSIGN_DIM                                               $0
          4        OP_DATA                                                  $2
   47     5      > RETURN                                                   null

End of function __construct

Function using:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 13
filename:       /in/knhjm
function name:  using
number of ops:  22
compiled vars:  !0 = $nsp, !1 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   RECV                                             !0      
   51     1        FETCH_OBJ_R                                      ~2      '_case'
          2      > FE_RESET_R                                       $3      ~2, ->13
          3    > > FE_FETCH_R                                               $3, !1, ->13
   53     4    >   FETCH_CLASS                                   0  $4      !1
          5        INSTANCEOF                                               !0, $4
          6      > JMPZ                                                     ~5, ->12
   55     7    >   FETCH_CLASS                                   0  $6      !1
          8        INIT_STATIC_METHOD_CALL                                  $6, 'getInstance'
          9        DO_FCALL                                      0  $7      
         10        FE_FREE                                                  $3
         11      > RETURN                                                   $7
   51    12    > > JMP                                                      ->3
         13    >   FE_FREE                                                  $3
   58    14        NEW                                              $8      'Exception'
         15        ROPE_INIT                                     3  ~10     'Call+to+'
         16        ROPE_ADD                                      1  ~10     ~10, !0
         17        ROPE_END                                      2  ~9      ~10, '+did+not+match+any+libraries.'
         18        SEND_VAL_EX                                              ~9
         19        DO_FCALL                                      0          
         20      > THROW                                         0          $8
   59    21*     > RETURN                                                   null

End of function using

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

End of function __clone

End of class App\Com\Service.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.47 ms | 1004 KiB | 13 Q