3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestingInjectingToProtected { protected $value; public function getValue() { return $this->value; } } $object = new TestingInjectingToProtected(); $reflection = new ReflectionObject($object); $property = $reflection->getProperty('value'); $property->setAccessible(true); $property->setValue($object, 'foo'); $property->setAccessible(false); echo $object->getValue(); $injector = Closure::bind(function ($property, $value) { $this->$property = $value; }, $object, $object); $injector('value', 'bar'); echo $object->getValue();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NsOFf
function name:  (null)
number of ops:  39
compiled vars:  !0 = $object, !1 = $reflection, !2 = $property, !3 = $injector
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $4      'TestingInjectingToProtected'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   15     3        NEW                                              $7      'ReflectionObject'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $7
   16     7        INIT_METHOD_CALL                                         !1, 'getProperty'
          8        SEND_VAL_EX                                              'value'
          9        DO_FCALL                                      0  $10     
         10        ASSIGN                                                   !2, $10
   17    11        INIT_METHOD_CALL                                         !2, 'setAccessible'
         12        SEND_VAL_EX                                              <true>
         13        DO_FCALL                                      0          
   18    14        INIT_METHOD_CALL                                         !2, 'setValue'
         15        SEND_VAR_EX                                              !0
         16        SEND_VAL_EX                                              'foo'
         17        DO_FCALL                                      0          
   19    18        INIT_METHOD_CALL                                         !2, 'setAccessible'
         19        SEND_VAL_EX                                              <false>
         20        DO_FCALL                                      0          
   21    21        INIT_METHOD_CALL                                         !0, 'getValue'
         22        DO_FCALL                                      0  $15     
         23        ECHO                                                     $15
   23    24        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         25        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FNsOFf%3A23%240'
         26        SEND_VAL                                                 ~16
         27        SEND_VAR                                                 !0
         28        SEND_VAR                                                 !0
         29        DO_FCALL                                      0  $17     
         30        ASSIGN                                                   !3, $17
   24    31        INIT_DYNAMIC_CALL                                        !3
         32        SEND_VAL_EX                                              'value'
         33        SEND_VAL_EX                                              'bar'
         34        DO_FCALL                                      0          
   26    35        INIT_METHOD_CALL                                         !0, 'getValue'
         36        DO_FCALL                                      0  $20     
         37        ECHO                                                     $20
         38      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FNsOFf%3A23%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NsOFf
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $property, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_THIS                                       $2      
          3        ASSIGN_OBJ                                               $2, !0
          4        OP_DATA                                                  !1
          5      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FNsOFf%3A23%240

Class TestingInjectingToProtected:
Function getvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NsOFf
function name:  getValue
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1      > RETURN                                                   ~0
   10     2*     > RETURN                                                   null

End of function getvalue

End of class TestingInjectingToProtected.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.9 ms | 1399 KiB | 13 Q