3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Container { protected $s=array(); function __set($k, $c) { $this->s[$k]=$c; } function __get($k) { return $this->s[$k]($this); } } $c = new Container(); // parameters $c->mailer_class = function () { return 'Zend_Mail'; }; $c->mailer_username = function () { return 'fabien'; }; $c->mailer_password = function () { return 'myPass'; }; // objects / services $c->mailer_transport = function ($c) { return new Zend_Mail_Transport_Smtp( 'smtp.gmail.com', array( 'auth' => 'login', 'username' => $c->mailer_username, 'password' => $c->mailer_password, 'ssl' => 'ssl', 'port' => 465, ) ); }; $c->mailer = function ($c) { $obj = new $c->mailer_class(); $obj->setDefaultTransport($c->mailer_transport); return $obj; }; // get the mailer $mailer = $c->mailer;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9MsEp
function name:  (null)
number of ops:  21
compiled vars:  !0 = $c, !1 = $mailer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   NEW                                              $2      'Container'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   12     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9MsEp%3A12%240'
          4        ASSIGN_OBJ                                               !0, 'mailer_class'
          5        OP_DATA                                                  ~6
   13     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9MsEp%3A13%241'
          7        ASSIGN_OBJ                                               !0, 'mailer_username'
          8        OP_DATA                                                  ~8
   14     9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9MsEp%3A14%242'
         10        ASSIGN_OBJ                                               !0, 'mailer_password'
         11        OP_DATA                                                  ~10
   17    12        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9MsEp%3A17%243'
         13        ASSIGN_OBJ                                               !0, 'mailer_transport'
   28    14        OP_DATA                                                  ~12
   29    15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9MsEp%3A29%244'
         16        ASSIGN_OBJ                                               !0, 'mailer'
   33    17        OP_DATA                                                  ~14
   36    18        FETCH_OBJ_R                                      ~15     !0, 'mailer'
         19        ASSIGN                                                   !1, ~15
         20      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F9MsEp%3A12%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9MsEp
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E > > RETURN                                                   'Zend_Mail'
          1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9MsEp%3A12%240

Function %00%7Bclosure%7D%2Fin%2F9MsEp%3A13%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9MsEp
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E > > RETURN                                                   'fabien'
          1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9MsEp%3A13%241

Function %00%7Bclosure%7D%2Fin%2F9MsEp%3A14%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9MsEp
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E > > RETURN                                                   'myPass'
          1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9MsEp%3A14%242

Function %00%7Bclosure%7D%2Fin%2F9MsEp%3A17%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9MsEp
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   18     1        NEW                                              $1      'Zend_Mail_Transport_Smtp'
   19     2        SEND_VAL_EX                                              'smtp.gmail.com'
   21     3        INIT_ARRAY                                       ~2      'login', 'auth'
   22     4        FETCH_OBJ_R                                      ~3      !0, 'mailer_username'
          5        ADD_ARRAY_ELEMENT                                ~2      ~3, 'username'
   23     6        FETCH_OBJ_R                                      ~4      !0, 'mailer_password'
          7        ADD_ARRAY_ELEMENT                                ~2      ~4, 'password'
   24     8        ADD_ARRAY_ELEMENT                                ~2      'ssl', 'ssl'
   25     9        ADD_ARRAY_ELEMENT                                ~2      465, 'port'
         10        SEND_VAL_EX                                              ~2
         11        DO_FCALL                                      0          
         12      > RETURN                                                   $1
   28    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9MsEp%3A17%243

Function %00%7Bclosure%7D%2Fin%2F9MsEp%3A29%244:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9MsEp
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $c, !1 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   30     1        FETCH_OBJ_R                                      ~2      !0, 'mailer_class'
          2        FETCH_CLASS                                   0  $3      ~2
          3        NEW                                              $4      $3
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $4
   31     6        INIT_METHOD_CALL                                         !1, 'setDefaultTransport'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_OBJ_FUNC_ARG                               $7      !0, 'mailer_transport'
          9        SEND_FUNC_ARG                                            $7
         10        DO_FCALL                                      0          
   32    11      > RETURN                                                   !1
   33    12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9MsEp%3A29%244

Class Container:
Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9MsEp
function name:  __set
number of ops:  6
compiled vars:  !0 = $k, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_OBJ_W                                      $2      's'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
          5      > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9MsEp
function name:  __get
number of ops:  9
compiled vars:  !0 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        FETCH_OBJ_R                                      ~1      's'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3        INIT_DYNAMIC_CALL                                        ~2
          4        FETCH_THIS                                       $3      
          5        SEND_VAR_EX                                              $3
          6        DO_FCALL                                      0  $4      
          7      > RETURN                                                   $4
          8*     > RETURN                                                   null

End of function __get

End of class Container.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.87 ms | 1403 KiB | 13 Q