3v4l.org

run code in 300+ PHP versions simultaneously
<?php // ClassA.php class A { public function __construct(){print "Init";} public function bye(){print "Hey :)";} } //ScriptAClassAction.php require 'ClassA.php'; $class = new A(); $reflection = new ReflectionClass($class); if (!empty($reflection) && $reflection->hasMethod('hello')){ if($reflection->hasMethod('init')) $class->init($request, $response); //Prints 'Init called' if($reflection->hasMethod('preDispatch')) $class->preDispatch(); // 'Predispatch called' $class->hello(); if($reflection->hasMethod('postDispatch')) $class->postDispatch(); // 'post dispatch called'.. } else { if (!$reflection) // I know this might not be the best check but.. print "Not a valid class supplied"; if (false == $reflection->hasMethod('hello')) // True trigger print "Supplied class does not have any manners and does not greet you :D"; // This is the expected output and it should be the only output }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 39
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
Branch analysis from position: 30
Branch analysis from position: 24
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 42
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 48
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 48
Branch analysis from position: 42
Branch analysis from position: 15
filename:       /in/Dgga5
function name:  (null)
number of ops:  49
compiled vars:  !0 = $class, !1 = $reflection, !2 = $request, !3 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INCLUDE_OR_EVAL                                          'ClassA.php', REQUIRE
   13     1        NEW                                              $5      'A'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $5
   14     4        NEW                                              $8      'ReflectionClass'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $8
   15     8        ISSET_ISEMPTY_CV                                 ~11     !1
          9        BOOL_NOT                                         ~12     ~11
         10      > JMPZ_EX                                          ~12     ~12, ->15
         11    >   INIT_METHOD_CALL                                         !1, 'hasMethod'
         12        SEND_VAL_EX                                              'hello'
         13        DO_FCALL                                      0  $13     
         14        BOOL                                             ~12     $13
         15    > > JMPZ                                                     ~12, ->39
   16    16    >   INIT_METHOD_CALL                                         !1, 'hasMethod'
         17        SEND_VAL_EX                                              'init'
         18        DO_FCALL                                      0  $14     
         19      > JMPZ                                                     $14, ->24
         20    >   INIT_METHOD_CALL                                         !0, 'init'
         21        SEND_VAR_EX                                              !2
         22        SEND_VAR_EX                                              !3
         23        DO_FCALL                                      0          
   17    24    >   INIT_METHOD_CALL                                         !1, 'hasMethod'
         25        SEND_VAL_EX                                              'preDispatch'
         26        DO_FCALL                                      0  $16     
         27      > JMPZ                                                     $16, ->30
         28    >   INIT_METHOD_CALL                                         !0, 'preDispatch'
         29        DO_FCALL                                      0          
   18    30    >   INIT_METHOD_CALL                                         !0, 'hello'
         31        DO_FCALL                                      0          
   19    32        INIT_METHOD_CALL                                         !1, 'hasMethod'
         33        SEND_VAL_EX                                              'postDispatch'
         34        DO_FCALL                                      0  $19     
         35      > JMPZ                                                     $19, ->38
         36    >   INIT_METHOD_CALL                                         !0, 'postDispatch'
         37        DO_FCALL                                      0          
         38    > > JMP                                                      ->48
   21    39    >   BOOL_NOT                                         ~21     !1
         40      > JMPZ                                                     ~21, ->42
   22    41    >   ECHO                                                     'Not+a+valid+class+supplied'
   24    42    >   INIT_METHOD_CALL                                         !1, 'hasMethod'
         43        SEND_VAL_EX                                              'hello'
         44        DO_FCALL                                      0  $22     
         45        BOOL_NOT                                         ~23     $22
         46      > JMPZ                                                     ~23, ->48
   25    47    >   ECHO                                                     'Supplied+class+does+not+have+any+manners+and+does+not+greet+you+%3AD'
   27    48    > > RETURN                                                   1

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

End of function __construct

Function bye:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Dgga5
function name:  bye
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ECHO                                                     'Hey+%3A%29'
          1      > RETURN                                                   null

End of function bye

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.87 ms | 1399 KiB | 13 Q