3v4l.org

run code in 300+ PHP versions simultaneously
<?php class User { } class UserProvider { public function getServices() { return ['user']; } public function user() { return new User(); } } $provider = new UserProvider(); $services = array_map(function($factoryName) use($provider) { return $provider->{$factoryName}(); // <-- dynamic call }, $provider->getServices()); var_dump($services);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Naug
function name:  (null)
number of ops:  16
compiled vars:  !0 = $provider, !1 = $services
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $2      'UserProvider'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   19     3        INIT_FCALL                                               'array_map'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F4Naug%3A19%240'
          5        BIND_LEXICAL                                             ~5, !0
   23     6        SEND_VAL                                                 ~5
          7        INIT_METHOD_CALL                                         !0, 'getServices'
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                         $7      
   19    11        ASSIGN                                                   !1, $7
   25    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F4Naug%3A19%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Naug
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $factoryName, !1 = $provider
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   21     2        INIT_METHOD_CALL                                         !1, !0
          3        DO_FCALL                                      0  $2      
          4      > RETURN                                                   $2
   23     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F4Naug%3A19%240

Class User: [no user functions]
Class UserProvider:
Function getservices:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Naug
function name:  getServices
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E > > RETURN                                                   <array>
   10     1*     > RETURN                                                   null

End of function getservices

Function user:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Naug
function name:  user
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $0      'User'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
   14     3*     > RETURN                                                   null

End of function user

End of class UserProvider.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.33 ms | 1400 KiB | 17 Q