3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { static $instance; public static function instance() { return static::$instance ?: ( static::$instance = new static() ); } public function foo() { var_dump($this); } } class B extends A { } class C extends A { static $instance; } A::instance()->foo(); B::instance()->foo(); C::instance()->foo();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ndBqr
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_STATIC_METHOD_CALL                                  'A', 'instance'
          1        DO_FCALL                                      0  $0      
          2        INIT_METHOD_CALL                                         $0, 'foo'
          3        DO_FCALL                                      0          
   21     4        INIT_STATIC_METHOD_CALL                                  'B', 'instance'
          5        DO_FCALL                                      0  $2      
          6        INIT_METHOD_CALL                                         $2, 'foo'
          7        DO_FCALL                                      0          
   22     8        INIT_STATIC_METHOD_CALL                                  'C', 'instance'
          9        DO_FCALL                                      0  $4      
         10        INIT_METHOD_CALL                                         $4, 'foo'
         11        DO_FCALL                                      0          
         12      > RETURN                                                   1

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

End of function instance

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ndBqr
function name:  foo
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   10     4      > RETURN                                                   null

End of function foo

End of class A.

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

End of function instance

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ndBqr
function name:  foo
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   10     4      > RETURN                                                   null

End of function foo

End of class B.

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

End of function instance

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ndBqr
function name:  foo
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   10     4      > RETURN                                                   null

End of function foo

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.79 ms | 1392 KiB | 15 Q