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); } } $data = array('foo' => 1, 'bar' => 2, 'baz' => 3); $hydrator = new FooSelfHydratingProxy(); $hydrated = new Foo(); $hydrator->hydrate(array('foo' => 1, 'bar' => 2, 'baz' => 3), $hydrated); var_dump($hydrated);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6DvRK
function name:  (null)
number of ops:  15
compiled vars:  !0 = $data, !1 = $hydrator, !2 = $hydrated
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   ASSIGN                                                   !0, <array>
   39     1        NEW                                              $4      'FooSelfHydratingProxy'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $4
   41     4        NEW                                              $7      'Foo'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $7
   43     7        INIT_METHOD_CALL                                         !1, 'hydrate'
          8        SEND_VAL_EX                                              <array>
          9        SEND_VAR_EX                                              !2
         10        DO_FCALL                                      0          
   45    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                                 
         14      > 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/6DvRK
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/6DvRK
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/6DvRK
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:
140.94 ms | 1400 KiB | 15 Q