3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait toArray { public function toArray() { return get_object_vars($this); } public function fromArray(array $properties) { foreach ($properties as $key => $value) { if (method_exists($this, 'set' . ucfirst($key))) { $this->{'set' . ucfirst($key)}($value); } } } } interface BazInterface { } class Bazz implements BazInterface { } interface FooInterface { public function add(BazInterface $baz); public function toArray(); public function fromArray(array $properties); } class Foo implements FooInterface { use toArray; private $bar; private $baz; public function add(Bazz $bazz) { } public function setBar($bar) { $this->bar = $bar; return $this; } public function setBaz($baz) { $this->baz = $baz; return $this; } } $foo = new Foo; $foo->fromArray(['bar' => 'boo', 'baz' => 'test']); $fooArray = $foo->toArray(); var_export($fooArray);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rBBn1
function name:  (null)
number of ops:  15
compiled vars:  !0 = $foo, !1 = $fooArray
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   DECLARE_CLASS                                            'bazz'
   36     1        DECLARE_CLASS                                            'foo'
   60     2        NEW                                              $2      'Foo'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   61     5        INIT_METHOD_CALL                                         !0, 'fromArray'
          6        SEND_VAL_EX                                              <array>
          7        DO_FCALL                                      0          
   62     8        INIT_METHOD_CALL                                         !0, 'toArray'
          9        DO_FCALL                                      0  $6      
         10        ASSIGN                                                   !1, $6
   63    11        INIT_FCALL                                               'var_export'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

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

End of function toarray

Function fromarray:
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
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 21
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 21
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/rBBn1
function name:  fromArray
number of ops:  24
compiled vars:  !0 = $properties, !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
   12     4        INIT_FCALL                                               'method_exists'
          5        FETCH_THIS                                       ~6      
          6        SEND_VAL                                                 ~6
          7        INIT_FCALL                                               'ucfirst'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                         $7      
         10        CONCAT                                           ~8      'set', $7
         11        SEND_VAL                                                 ~8
         12        DO_ICALL                                         $9      
         13      > JMPZ                                                     $9, ->21
   13    14    >   INIT_FCALL                                               'ucfirst'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                         $10     
         17        CONCAT                                           ~11     'set', $10
         18        INIT_METHOD_CALL                                         ~11
         19        SEND_VAR_EX                                              !1
         20        DO_FCALL                                      0          
   11    21    > > JMP                                                      ->2
         22    >   FE_FREE                                                  $3
   16    23      > RETURN                                                   null

End of function fromarray

End of class toArray.

Class BazInterface: [no user functions]
Class Bazz: [no user functions]
Class FooInterface:
Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rBBn1
function name:  add
number of ops:  2
compiled vars:  !0 = $baz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function add

Function toarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rBBn1
function name:  toArray
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E > > RETURN                                                   null

End of function toarray

Function fromarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rBBn1
function name:  fromArray
number of ops:  2
compiled vars:  !0 = $properties
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function fromarray

End of class FooInterface.

Class Foo:
Function add:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rBBn1
function name:  add
number of ops:  2
compiled vars:  !0 = $bazz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
   47     1      > RETURN                                                   null

End of function add

Function setbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rBBn1
function name:  setBar
number of ops:  6
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   RECV                                             !0      
   50     1        ASSIGN_OBJ                                               'bar'
          2        OP_DATA                                                  !0
   51     3        FETCH_THIS                                       ~2      
          4      > RETURN                                                   ~2
   52     5*     > RETURN                                                   null

End of function setbar

Function setbaz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rBBn1
function name:  setBaz
number of ops:  6
compiled vars:  !0 = $baz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
   55     1        ASSIGN_OBJ                                               'baz'
          2        OP_DATA                                                  !0
   56     3        FETCH_THIS                                       ~2      
          4      > RETURN                                                   ~2
   57     5*     > RETURN                                                   null

End of function setbaz

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.37 ms | 1396 KiB | 21 Q