3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestingInjectingToProtected { protected $value; public function getValue() { return $value; } } $object = new TestingInjectingToProtected(); $reflection = new ReflectionObject($object); $property = $reflection->getProperty('value'); $property->setAccessible(true); $property->setValue('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/d1VlM
function name:  (null)
number of ops:  38
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_VAL_EX                                              'foo'
         16        DO_FCALL                                      0          
   19    17        INIT_METHOD_CALL                                         !2, 'setAccessible'
         18        SEND_VAL_EX                                              <false>
         19        DO_FCALL                                      0          
   21    20        INIT_METHOD_CALL                                         !0, 'getValue'
         21        DO_FCALL                                      0  $15     
         22        ECHO                                                     $15
   23    23        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         24        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fd1VlM%3A23%240'
         25        SEND_VAL                                                 ~16
         26        SEND_VAR                                                 !0
         27        SEND_VAR                                                 !0
         28        DO_FCALL                                      0  $17     
         29        ASSIGN                                                   !3, $17
   24    30        INIT_DYNAMIC_CALL                                        !3
         31        SEND_VAL_EX                                              'value'
         32        SEND_VAL_EX                                              'bar'
         33        DO_FCALL                                      0          
   26    34        INIT_METHOD_CALL                                         !0, 'getValue'
         35        DO_FCALL                                      0  $20     
         36        ECHO                                                     $20
         37      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fd1VlM%3A23%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d1VlM
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%2Fd1VlM%3A23%240

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

End of function getvalue

End of class TestingInjectingToProtected.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.08 ms | 1399 KiB | 13 Q