3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { } $ref = new ReflectionClass('A'); var_dump(method_exists($ref, 'getDocComment')); //bool(true) var_dump($ref->getDocComment()); //bool(false) // serialize only the class name $refClass = unserialize(serialize($ref)); try { $refClass->getDocComment(); } catch (Error $e) { $recoveredRef = new ReflectionClass($refClass->getName()); var_dump($recoveredRef); var_dump($recoveredRef->getDocComment()); // works correctly echo "Malformed Reflection object, but recovered: ".$e->getMessage(); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 26
Branch analysis from position: 26
2 jumps found. (Code = 107) Position 1 = 27, Position 2 = -2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cFpdR
function name:  (null)
number of ops:  46
compiled vars:  !0 = $ref, !1 = $refClass, !2 = $e, !3 = $recoveredRef
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $4      'ReflectionClass'
          1        SEND_VAL_EX                                              'A'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $4
    4     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'method_exists'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 'getDocComment'
          8        DO_ICALL                                         $7      
          9        SEND_VAR                                                 $7
         10        DO_ICALL                                                 
    5    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !0, 'getDocComment'
         13        DO_FCALL                                      0  $9      
         14        SEND_VAR                                                 $9
         15        DO_ICALL                                                 
    8    16        INIT_FCALL                                               'unserialize'
         17        INIT_FCALL                                               'serialize'
         18        SEND_VAR                                                 !0
         19        DO_ICALL                                         $11     
         20        SEND_VAR                                                 $11
         21        DO_ICALL                                         $12     
         22        ASSIGN                                                   !1, $12
   10    23        INIT_METHOD_CALL                                         !1, 'getDocComment'
         24        DO_FCALL                                      0          
         25      > JMP                                                      ->45
   12    26  E > > CATCH                                       last         'Error'
   13    27    >   NEW                                              $15     'ReflectionClass'
         28        INIT_METHOD_CALL                                         !1, 'getName'
         29        DO_FCALL                                      0  $16     
         30        SEND_VAR_NO_REF_EX                                       $16
         31        DO_FCALL                                      0          
         32        ASSIGN                                                   !3, $15
   14    33        INIT_FCALL                                               'var_dump'
         34        SEND_VAR                                                 !3
         35        DO_ICALL                                                 
   15    36        INIT_FCALL                                               'var_dump'
         37        INIT_METHOD_CALL                                         !3, 'getDocComment'
         38        DO_FCALL                                      0  $20     
         39        SEND_VAR                                                 $20
         40        DO_ICALL                                                 
   16    41        INIT_METHOD_CALL                                         !2, 'getMessage'
         42        DO_FCALL                                      0  $22     
         43        CONCAT                                           ~23     'Malformed+Reflection+object%2C+but+recovered%3A+', $22
         44        ECHO                                                     ~23
   17    45    > > RETURN                                                   1

Class A: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.73 ms | 1024 KiB | 17 Q