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 $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 = 10, Position 2 = 14
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 38
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 23
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 37
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
Branch analysis from position: 29
Branch analysis from position: 23
Branch analysis from position: 38
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 41
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 47
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
Branch analysis from position: 41
Branch analysis from position: 14
filename:       /in/ScYK9
function name:  (null)
number of ops:  48
compiled vars:  !0 = $class, !1 = $reflection, !2 = $request, !3 = $response
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $4      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
   13     3        NEW                                              $7      'ReflectionClass'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $7
   14     7        ISSET_ISEMPTY_CV                                 ~10     !1
          8        BOOL_NOT                                         ~11     ~10
          9      > JMPZ_EX                                          ~11     ~11, ->14
         10    >   INIT_METHOD_CALL                                         !1, 'hasMethod'
         11        SEND_VAL_EX                                              'hello'
         12        DO_FCALL                                      0  $12     
         13        BOOL                                             ~11     $12
         14    > > JMPZ                                                     ~11, ->38
   15    15    >   INIT_METHOD_CALL                                         !1, 'hasMethod'
         16        SEND_VAL_EX                                              'init'
         17        DO_FCALL                                      0  $13     
         18      > JMPZ                                                     $13, ->23
         19    >   INIT_METHOD_CALL                                         !0, 'init'
         20        SEND_VAR_EX                                              !2
         21        SEND_VAR_EX                                              !3
         22        DO_FCALL                                      0          
   16    23    >   INIT_METHOD_CALL                                         !1, 'hasMethod'
         24        SEND_VAL_EX                                              'preDispatch'
         25        DO_FCALL                                      0  $15     
         26      > JMPZ                                                     $15, ->29
         27    >   INIT_METHOD_CALL                                         !0, 'preDispatch'
         28        DO_FCALL                                      0          
   17    29    >   INIT_METHOD_CALL                                         !0, 'hello'
         30        DO_FCALL                                      0          
   18    31        INIT_METHOD_CALL                                         !1, 'hasMethod'
         32        SEND_VAL_EX                                              'postDispatch'
         33        DO_FCALL                                      0  $18     
         34      > JMPZ                                                     $18, ->37
         35    >   INIT_METHOD_CALL                                         !0, 'postDispatch'
         36        DO_FCALL                                      0          
         37    > > JMP                                                      ->47
   20    38    >   BOOL_NOT                                         ~20     !1
         39      > JMPZ                                                     ~20, ->41
   21    40    >   ECHO                                                     'Not+a+valid+class+supplied'
   23    41    >   INIT_METHOD_CALL                                         !1, 'hasMethod'
         42        SEND_VAL_EX                                              'hello'
         43        DO_FCALL                                      0  $21     
         44        BOOL_NOT                                         ~22     $21
         45      > JMPZ                                                     ~22, ->47
   24    46    >   ECHO                                                     'Supplied+class+does+not+have+any+manners+and+does+not+greet+you+%3AD'
   26    47    > > RETURN                                                   1

Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ScYK9
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/ScYK9
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:
161.28 ms | 1399 KiB | 13 Q