3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class A{ static protected $shared = array(); static function create(){ if (isset(static::$shared['mailer'])){ return static::$shared['mailer']; } $mailer = new static(); //this is the correct way return static::$shared['mailer'] = $mailer; } } class B extends A{ } $obj=B::create(); $obj1=B::create(); var_dump($obj); var_dump($obj1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2m2t4
function name:  (null)
number of ops:  13
compiled vars:  !0 = $obj, !1 = $obj1
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_STATIC_METHOD_CALL                                  'B', 'create'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   26     3        INIT_STATIC_METHOD_CALL                                  'B', 'create'
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                                   !1, $4
   28     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
   29     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Class A:
Function create:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2m2t4
function name:  create
number of ops:  14
compiled vars:  !0 = $mailer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_STATIC_PROP_IS                             ~1      'shared'
          1        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, 'mailer'
          2      > JMPZ                                                     ~2, ->6
    9     3    >   FETCH_STATIC_PROP_R          unknown             ~3      'shared'
          4        FETCH_DIM_R                                      ~4      ~3, 'mailer'
          5      > RETURN                                                   ~4
   13     6    >   NEW                          static              $5      
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $5
   14     9        FETCH_STATIC_PROP_W          unknown             $8      'shared'
         10        ASSIGN_DIM                                       ~9      $8, 'mailer'
         11        OP_DATA                                                  !0
         12      > RETURN                                                   ~9
   17    13*     > RETURN                                                   null

End of function create

End of class A.

Class B:
Function create:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/2m2t4
function name:  create
number of ops:  14
compiled vars:  !0 = $mailer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_STATIC_PROP_IS                             ~1      'shared'
          1        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, 'mailer'
          2      > JMPZ                                                     ~2, ->6
    9     3    >   FETCH_STATIC_PROP_R          unknown             ~3      'shared'
          4        FETCH_DIM_R                                      ~4      ~3, 'mailer'
          5      > RETURN                                                   ~4
   13     6    >   NEW                          static              $5      
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !0, $5
   14     9        FETCH_STATIC_PROP_W          unknown             $8      'shared'
         10        ASSIGN_DIM                                       ~9      $8, 'mailer'
         11        OP_DATA                                                  !0
         12      > RETURN                                                   ~9
   17    13*     > RETURN                                                   null

End of function create

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.84 ms | 1400 KiB | 15 Q