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) { var_dump($c->mailer_class()); exit; $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/fpLCv
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%2FfpLCv%3A12%240'
          4        ASSIGN_OBJ                                               !0, 'mailer_class'
          5        OP_DATA                                                  ~6
   13     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfpLCv%3A13%241'
          7        ASSIGN_OBJ                                               !0, 'mailer_username'
          8        OP_DATA                                                  ~8
   14     9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfpLCv%3A14%242'
         10        ASSIGN_OBJ                                               !0, 'mailer_password'
         11        OP_DATA                                                  ~10
   17    12        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfpLCv%3A17%243'
         13        ASSIGN_OBJ                                               !0, 'mailer_transport'
   28    14        OP_DATA                                                  ~12
   29    15        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FfpLCv%3A29%244'
         16        ASSIGN_OBJ                                               !0, 'mailer'
   36    17        OP_DATA                                                  ~14
   39    18        FETCH_OBJ_R                                      ~15     !0, 'mailer'
         19        ASSIGN                                                   !1, ~15
         20      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FfpLCv%3A12%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fpLCv
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%2FfpLCv%3A12%240

Function %00%7Bclosure%7D%2Fin%2FfpLCv%3A13%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fpLCv
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%2FfpLCv%3A13%241

Function %00%7Bclosure%7D%2Fin%2FfpLCv%3A14%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fpLCv
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%2FfpLCv%3A14%242

Function %00%7Bclosure%7D%2Fin%2FfpLCv%3A17%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fpLCv
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%2FfpLCv%3A17%243

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

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

Class Container:
Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fpLCv
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/fpLCv
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:
151.67 ms | 1404 KiB | 15 Q