3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class AbstractClass { private $basePropertyI; private $basePropertyII; public function __construct() { } public function get($property) { $rc = new \ReflectionClass($this); $p = $rc->getProperty($property); $p->setAccessible(true); return $p->getValue($this); } public function set($property, $value) { $rc = new \ReflectionClass($this); $p = $rc->getProperty($property); $p->setAccessible(true); $p->setValue($this, $value); return $this; } } abstract class MetadataClass extends AbstractClass { private $metadataA; private $metadataB; } class ActualClass extends MetadataClass { private $realField1; private $realField2; } $ac = new ActualClass(); $ac->set('realField1', 'Hello World!'); echo $ac->get('realField1'); $ac->set('basePropertyI', 'Hello Metadata!'); echo $ac->get('basePropertyI');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5tbfb
function name:  (null)
number of ops:  20
compiled vars:  !0 = $ac
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   NEW                                              $1      'ActualClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   36     3        INIT_METHOD_CALL                                         !0, 'set'
          4        SEND_VAL_EX                                              'realField1'
          5        SEND_VAL_EX                                              'Hello+World%21'
          6        DO_FCALL                                      0          
   37     7        INIT_METHOD_CALL                                         !0, 'get'
          8        SEND_VAL_EX                                              'realField1'
          9        DO_FCALL                                      0  $5      
         10        ECHO                                                     $5
   39    11        INIT_METHOD_CALL                                         !0, 'set'
         12        SEND_VAL_EX                                              'basePropertyI'
         13        SEND_VAL_EX                                              'Hello+Metadata%21'
         14        DO_FCALL                                      0          
   40    15        INIT_METHOD_CALL                                         !0, 'get'
         16        SEND_VAL_EX                                              'basePropertyI'
         17        DO_FCALL                                      0  $7      
         18        ECHO                                                     $7
         19      > RETURN                                                   1

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

End of function __construct

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5tbfb
function name:  get
number of ops:  19
compiled vars:  !0 = $property, !1 = $rc, !2 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        NEW                                              $3      'ReflectionClass'
          2        FETCH_THIS                                       $4      
          3        SEND_VAR_EX                                              $4
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $3
   11     6        INIT_METHOD_CALL                                         !1, 'getProperty'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !2, $7
   12    10        INIT_METHOD_CALL                                         !2, 'setAccessible'
         11        SEND_VAL_EX                                              <true>
         12        DO_FCALL                                      0          
   13    13        INIT_METHOD_CALL                                         !2, 'getValue'
         14        FETCH_THIS                                       $10     
         15        SEND_VAR_EX                                              $10
         16        DO_FCALL                                      0  $11     
         17      > RETURN                                                   $11
   14    18*     > RETURN                                                   null

End of function get

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5tbfb
function name:  set
number of ops:  22
compiled vars:  !0 = $property, !1 = $value, !2 = $rc, !3 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        NEW                                              $4      'ReflectionClass'
          3        FETCH_THIS                                       $5      
          4        SEND_VAR_EX                                              $5
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $4
   18     7        INIT_METHOD_CALL                                         !2, 'getProperty'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $8      
         10        ASSIGN                                                   !3, $8
   19    11        INIT_METHOD_CALL                                         !3, 'setAccessible'
         12        SEND_VAL_EX                                              <true>
         13        DO_FCALL                                      0          
   20    14        INIT_METHOD_CALL                                         !3, 'setValue'
         15        FETCH_THIS                                       $11     
         16        SEND_VAR_EX                                              $11
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0          
   21    19        FETCH_THIS                                       ~13     
         20      > RETURN                                                   ~13
   22    21*     > RETURN                                                   null

End of function set

End of class AbstractClass.

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

End of function __construct

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5tbfb
function name:  get
number of ops:  19
compiled vars:  !0 = $property, !1 = $rc, !2 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        NEW                                              $3      'ReflectionClass'
          2        FETCH_THIS                                       $4      
          3        SEND_VAR_EX                                              $4
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $3
   11     6        INIT_METHOD_CALL                                         !1, 'getProperty'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !2, $7
   12    10        INIT_METHOD_CALL                                         !2, 'setAccessible'
         11        SEND_VAL_EX                                              <true>
         12        DO_FCALL                                      0          
   13    13        INIT_METHOD_CALL                                         !2, 'getValue'
         14        FETCH_THIS                                       $10     
         15        SEND_VAR_EX                                              $10
         16        DO_FCALL                                      0  $11     
         17      > RETURN                                                   $11
   14    18*     > RETURN                                                   null

End of function get

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5tbfb
function name:  set
number of ops:  22
compiled vars:  !0 = $property, !1 = $value, !2 = $rc, !3 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        NEW                                              $4      'ReflectionClass'
          3        FETCH_THIS                                       $5      
          4        SEND_VAR_EX                                              $5
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $4
   18     7        INIT_METHOD_CALL                                         !2, 'getProperty'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $8      
         10        ASSIGN                                                   !3, $8
   19    11        INIT_METHOD_CALL                                         !3, 'setAccessible'
         12        SEND_VAL_EX                                              <true>
         13        DO_FCALL                                      0          
   20    14        INIT_METHOD_CALL                                         !3, 'setValue'
         15        FETCH_THIS                                       $11     
         16        SEND_VAR_EX                                              $11
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0          
   21    19        FETCH_THIS                                       ~13     
         20      > RETURN                                                   ~13
   22    21*     > RETURN                                                   null

End of function set

End of class MetadataClass.

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

End of function __construct

Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5tbfb
function name:  get
number of ops:  19
compiled vars:  !0 = $property, !1 = $rc, !2 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        NEW                                              $3      'ReflectionClass'
          2        FETCH_THIS                                       $4      
          3        SEND_VAR_EX                                              $4
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $3
   11     6        INIT_METHOD_CALL                                         !1, 'getProperty'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !2, $7
   12    10        INIT_METHOD_CALL                                         !2, 'setAccessible'
         11        SEND_VAL_EX                                              <true>
         12        DO_FCALL                                      0          
   13    13        INIT_METHOD_CALL                                         !2, 'getValue'
         14        FETCH_THIS                                       $10     
         15        SEND_VAR_EX                                              $10
         16        DO_FCALL                                      0  $11     
         17      > RETURN                                                   $11
   14    18*     > RETURN                                                   null

End of function get

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5tbfb
function name:  set
number of ops:  22
compiled vars:  !0 = $property, !1 = $value, !2 = $rc, !3 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        NEW                                              $4      'ReflectionClass'
          3        FETCH_THIS                                       $5      
          4        SEND_VAR_EX                                              $5
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $4
   18     7        INIT_METHOD_CALL                                         !2, 'getProperty'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0  $8      
         10        ASSIGN                                                   !3, $8
   19    11        INIT_METHOD_CALL                                         !3, 'setAccessible'
         12        SEND_VAL_EX                                              <true>
         13        DO_FCALL                                      0          
   20    14        INIT_METHOD_CALL                                         !3, 'setValue'
         15        FETCH_THIS                                       $11     
         16        SEND_VAR_EX                                              $11
         17        SEND_VAR_EX                                              !1
         18        DO_FCALL                                      0          
   21    19        FETCH_THIS                                       ~13     
         20      > RETURN                                                   ~13
   22    21*     > RETURN                                                   null

End of function set

End of class ActualClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.04 ms | 1461 KiB | 13 Q