3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Mailer{ } class Container { static protected $shared = array(); protected $parameters = array(); public function __construct(array $parameters = array()) { $this->parameters = $parameters; var_dump($parameters); } // ... public function getMailer() { if (isset(self::$shared['mailer'])) { return self::$shared['mailer']; } $class = $this->parameters['mailer.class']; $mailer = new $class(); return self::$shared['mailer'] = $mailer; } } $container = new Container(array( 'mailer.username' => 'foo', 'mailer.password' => 'bar', 'mailer.class' => 'Mailer', )); $mailer = $container->getMailer(); var_dump($mailer);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8hvLr
function name:  (null)
number of ops:  11
compiled vars:  !0 = $container, !1 = $mailer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   NEW                                              $2      'Container'
   35     1        SEND_VAL_EX                                              <array>
          2        DO_FCALL                                      0          
   34     3        ASSIGN                                                   !0, $2
   39     4        INIT_METHOD_CALL                                         !0, 'getMailer'
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !1, $5
   40     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Class Mailer: [no user functions]
Class Container:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8hvLr
function name:  __construct
number of ops:  7
compiled vars:  !0 = $parameters
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV_INIT                                        !0      <array>
   13     1        ASSIGN_OBJ                                               'parameters'
          2        OP_DATA                                                  !0
   14     3        INIT_FCALL                                               'var_dump'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                                 
   16     6      > RETURN                                                   null

End of function __construct

Function getmailer:
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/8hvLr
function name:  getMailer
number of ops:  18
compiled vars:  !0 = $class, !1 = $mailer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_STATIC_PROP_IS                             ~2      'shared'
          1        ISSET_ISEMPTY_DIM_OBJ                         0          ~2, 'mailer'
          2      > JMPZ                                                     ~3, ->6
   24     3    >   FETCH_STATIC_PROP_R          unknown             ~4      'shared'
          4        FETCH_DIM_R                                      ~5      ~4, 'mailer'
          5      > RETURN                                                   ~5
   27     6    >   FETCH_OBJ_R                                      ~6      'parameters'
          7        FETCH_DIM_R                                      ~7      ~6, 'mailer.class'
          8        ASSIGN                                                   !0, ~7
   29     9        FETCH_CLASS                                   0  $9      !0
         10        NEW                                              $10     $9
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $10
   31    13        FETCH_STATIC_PROP_W          unknown             $13     'shared'
         14        ASSIGN_DIM                                       ~14     $13, 'mailer'
         15        OP_DATA                                                  !1
         16      > RETURN                                                   ~14
   32    17*     > RETURN                                                   null

End of function getmailer

End of class Container.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.7 ms | 1400 KiB | 15 Q