3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class AbstractCommand { use DataTransferObject; } trait DataTransferObject { private function __construct(array $params) { foreach ($params as $key => $value) { $this->{'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key)))}($value); } } public static function fromParams(array $params) { return new static($params); } public function asArray() { return get_object_vars($this); } public function __call($method, $args) { if (substr($method, 0, 3) == 'set' && property_exists($this, lcfirst(substr($method, 3)))) { $this->{lcfirst(substr($method, 3))} = reset($args); } } } class Command extends AbstractCommand { protected $foo; } $foo = Command::fromParams(array('foo' => 'foo')); var_dump($foo);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vjlKV
function name:  (null)
number of ops:  10
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'abstractcommand'
   36     1        DECLARE_CLASS                                            'command', 'abstractcommand'
   41     2        INIT_STATIC_METHOD_CALL                                  'Command', 'fromParams'
          3        SEND_VAL_EX                                              <array>
          4        DO_FCALL                                      0  $1      
          5        ASSIGN                                                   !0, $1
   43     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Class AbstractCommand: [no user functions]
Class DataTransferObject:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 22
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 22
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/vjlKV
function name:  __construct
number of ops:  24
compiled vars:  !0 = $params, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1      > FE_RESET_R                                       $3      !0, ->22
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->22
          3    >   ASSIGN                                                   !2, ~4
   13     4        INIT_FCALL                                               'str_replace'
          5        SEND_VAL                                                 '+'
          6        SEND_VAL                                                 ''
          7        INIT_FCALL                                               'ucwords'
          8        INIT_FCALL                                               'str_replace'
          9        SEND_VAL                                                 '_'
         10        SEND_VAL                                                 '+'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                         $6      
         13        SEND_VAR                                                 $6
         14        DO_ICALL                                         $7      
         15        SEND_VAR                                                 $7
         16        DO_ICALL                                         $8      
         17        CONCAT                                           ~9      'set', $8
         18        INIT_METHOD_CALL                                         ~9
         19        SEND_VAR_EX                                              !1
         20        DO_FCALL                                      0          
   11    21      > JMP                                                      ->2
         22    >   FE_FREE                                                  $3
   15    23      > RETURN                                                   null

End of function __construct

Function fromparams:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vjlKV
function name:  fromParams
number of ops:  6
compiled vars:  !0 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        NEW                          static              $1      
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
   20     5*     > RETURN                                                   null

End of function fromparams

Function asarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vjlKV
function name:  asArray
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'get_object_vars'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   25     5*     > RETURN                                                   null

End of function asarray

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 22
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 35
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Branch analysis from position: 22
filename:       /in/vjlKV
function name:  __call
number of ops:  36
compiled vars:  !0 = $method, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   29     2        INIT_FCALL                                               'substr'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 3
          6        DO_ICALL                                         $2      
          7        IS_EQUAL                                         ~3      $2, 'set'
          8      > JMPZ_EX                                          ~3      ~3, ->22
          9    >   INIT_FCALL                                               'property_exists'
         10        FETCH_THIS                                       ~4      
         11        SEND_VAL                                                 ~4
         12        INIT_FCALL                                               'lcfirst'
         13        INIT_FCALL                                               'substr'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 3
         16        DO_ICALL                                         $5      
         17        SEND_VAR                                                 $5
         18        DO_ICALL                                         $6      
         19        SEND_VAR                                                 $6
         20        DO_ICALL                                         $7      
         21        BOOL                                             ~3      $7
         22    > > JMPZ                                                     ~3, ->35
   31    23    >   INIT_FCALL                                               'lcfirst'
         24        INIT_FCALL                                               'substr'
         25        SEND_VAR                                                 !0
         26        SEND_VAL                                                 3
         27        DO_ICALL                                         $8      
         28        SEND_VAR                                                 $8
         29        DO_ICALL                                         $9      
         30        INIT_FCALL                                               'reset'
         31        SEND_REF                                                 !1
         32        DO_ICALL                                         $11     
         33        ASSIGN_OBJ                                               $9
         34        OP_DATA                                                  $11
   33    35    > > RETURN                                                   null

End of function __call

End of class DataTransferObject.

Class Command: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.54 ms | 1404 KiB | 29 Q