3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $foo; protected $bar; protected $baz; } class FooSelfHydratingProxy extends Foo { /** zero-argument constructor since this is just a helper class for hydration */ public function __construct() { } /** * the `Foo` typehint is not part of the interface - here only for the sake of readability/clearness */ public function hydrate($data, Foo $object) { $object->foo = $data['foo']; $object->bar = $data['bar']; $object->baz = $data['baz']; } /** * the `Foo` typehint is not part of the interface - here only for the sake of readability/clearness */ public function extract(Foo $object) { return array('foo' => $object->foo, 'bar' => $object->bar, 'baz' => $object->baz); } } $iterations = 100000; $data = array('foo' => 1, 'bar' => 2, 'baz' => 3); $hydrator = new FooSelfHydratingProxy(); $hydrated = new Foo(); for ($i = 0; $i < $iterations; $i++) { $hydrator->hydrate($data, $hydrated); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 10
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 17, Position 2 = 10
Branch analysis from position: 17
Branch analysis from position: 10
filename:       /in/7BceR
function name:  (null)
number of ops:  18
compiled vars:  !0 = $iterations, !1 = $data, !2 = $hydrator, !3 = $hydrated, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   ASSIGN                                                   !0, 100000
   38     1        ASSIGN                                                   !1, <array>
   40     2        NEW                                              $7      'FooSelfHydratingProxy'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !2, $7
   42     5        NEW                                              $10     'Foo'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !3, $10
   44     8        ASSIGN                                                   !4, 0
          9      > JMP                                                      ->15
   45    10    >   INIT_METHOD_CALL                                         !2, 'hydrate'
         11        SEND_VAR_EX                                              !1
         12        SEND_VAR_EX                                              !3
         13        DO_FCALL                                      0          
   44    14        PRE_INC                                                  !4
         15    >   IS_SMALLER                                               !4, !0
         16      > JMPNZ                                                    ~16, ->10
   46    17    > > RETURN                                                   1

Class Foo: [no user functions]
Class FooSelfHydratingProxy:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7BceR
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E > > RETURN                                                   null

End of function __construct

Function hydrate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7BceR
function name:  hydrate
number of ops:  12
compiled vars:  !0 = $data, !1 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   22     2        FETCH_DIM_R                                      ~3      !0, 'foo'
          3        ASSIGN_OBJ                                               !1, 'foo'
          4        OP_DATA                                                  ~3
   23     5        FETCH_DIM_R                                      ~5      !0, 'bar'
          6        ASSIGN_OBJ                                               !1, 'bar'
          7        OP_DATA                                                  ~5
   24     8        FETCH_DIM_R                                      ~7      !0, 'baz'
          9        ASSIGN_OBJ                                               !1, 'baz'
         10        OP_DATA                                                  ~7
   25    11      > RETURN                                                   null

End of function hydrate

Function extract:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7BceR
function name:  extract
number of ops:  9
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   32     1        FETCH_OBJ_R                                      ~1      !0, 'foo'
          2        INIT_ARRAY                                       ~2      ~1, 'foo'
          3        FETCH_OBJ_R                                      ~3      !0, 'bar'
          4        ADD_ARRAY_ELEMENT                                ~2      ~3, 'bar'
          5        FETCH_OBJ_R                                      ~4      !0, 'baz'
          6        ADD_ARRAY_ELEMENT                                ~2      ~4, 'baz'
          7      > RETURN                                                   ~2
   33     8*     > RETURN                                                   null

End of function extract

End of class FooSelfHydratingProxy.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.52 ms | 1399 KiB | 13 Q