3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private static $instance; public static function getInstance() { if (!self::$instance instanceof self) { self::$instance = new self; } return self::$instance; } } $foo = Foo::getInstance(); assert($foo instanceof Foo); $foo = Foo::getInstance(); assert($foo instanceof Foo);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EXWaq
function name:  (null)
number of ops:  19
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_STATIC_METHOD_CALL                                  'Foo', 'getInstance'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN                                                   !0, $1
   15     3        ASSERT_CHECK                                             
          4        INIT_FCALL                                               'assert'
          5        INSTANCEOF                                       ~3      !0, 'Foo'
          6        SEND_VAL                                                 ~3
          7        SEND_VAL                                                 'assert%28%24foo+instanceof+Foo%29'
          8        DO_ICALL                                                 
   16     9        INIT_STATIC_METHOD_CALL                                  'Foo', 'getInstance'
         10        DO_FCALL                                      0  $5      
         11        ASSIGN                                                   !0, $5
   17    12        ASSERT_CHECK                                             
         13        INIT_FCALL                                               'assert'
         14        INSTANCEOF                                       ~7      !0, 'Foo'
         15        SEND_VAL                                                 ~7
         16        SEND_VAL                                                 'assert%28%24foo+instanceof+Foo%29'
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

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

End of function getinstance

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.59 ms | 1396 KiB | 15 Q