3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { private $a='data'; protected $b=123; public $c=true; } /** * @author Lisachenko Alexander <lisachenko.it@gmail.com> */ class Hydrator { private function getContext() { return get_object_vars($this); } public function __invoke($object) { static $hydrator = null; if (!$hydrator) { $hydrator = (new ReflectionMethod(__CLASS__, 'getContext'))->getClosure($this); } return $hydrator->bindTo($object, get_class($object))->__invoke($object); } } $test = new Test; $hydrator = new Hydrator(); $data = $hydrator($test); var_dump($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BtTRD
function name:  (null)
number of ops:  14
compiled vars:  !0 = $test, !1 = $hydrator, !2 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   NEW                                              $3      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   31     3        NEW                                              $6      'Hydrator'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
   32     6        INIT_DYNAMIC_CALL                                        !1
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $9      
          9        ASSIGN                                                   !2, $9
   33    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Class Test: [no user functions]
Class Hydrator:
Function getcontext:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BtTRD
function name:  getContext
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'get_object_vars'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   18     5*     > RETURN                                                   null

End of function getcontext

Function __invoke:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/BtTRD
function name:  __invoke
number of ops:  23
compiled vars:  !0 = $object, !1 = $hydrator
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        BIND_STATIC                                              !1
   23     2        BOOL_NOT                                         ~2      !1
          3      > JMPZ                                                     ~2, ->13
   24     4    >   NEW                                              $3      'ReflectionMethod'
          5        SEND_VAL_EX                                              'Hydrator'
          6        SEND_VAL_EX                                              'getContext'
          7        DO_FCALL                                      0          
          8        INIT_METHOD_CALL                                         $3, 'getClosure'
          9        FETCH_THIS                                       $5      
         10        SEND_VAR_EX                                              $5
         11        DO_FCALL                                      0  $6      
         12        ASSIGN                                                   !1, $6
   26    13    >   INIT_METHOD_CALL                                         !1, 'bindTo'
         14        SEND_VAR_EX                                              !0
         15        GET_CLASS                                        ~8      !0
         16        SEND_VAL_EX                                              ~8
         17        DO_FCALL                                      0  $9      
         18        INIT_METHOD_CALL                                         $9, '__invoke'
         19        SEND_VAR_EX                                              !0
         20        DO_FCALL                                      0  $10     
         21      > RETURN                                                   $10
   27    22*     > RETURN                                                   null

End of function __invoke

End of class Hydrator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.51 ms | 1405 KiB | 17 Q