3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Foo {} interface Bar { /** * @return scalar|array|object|null */ public function __get(string $k); } function Baz(string $thing) : bool { return method_exists($thing, '__get'); } function Bat(string $thing) : bool { return (class_exists($thing) || interface_exists($thing)) && (new ReflectionClass($thing))->hasMethod('__get'); } var_dump(Baz(Foo::class), Bat(Foo::class), Baz(Bar::class), Bat(Bar::class));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bhsRi
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'baz'
          2        SEND_VAL                                                 'Foo'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        INIT_FCALL                                               'bat'
          6        SEND_VAL                                                 'Foo'
          7        DO_FCALL                                      0  $1      
          8        SEND_VAR                                                 $1
          9        INIT_FCALL                                               'baz'
         10        SEND_VAL                                                 'Bar'
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        INIT_FCALL                                               'bat'
         14        SEND_VAL                                                 'Bar'
         15        DO_FCALL                                      0  $3      
         16        SEND_VAR                                                 $3
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function baz:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bhsRi
function name:  Baz
number of ops:  9
compiled vars:  !0 = $thing
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'method_exists'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '__get'
          4        DO_ICALL                                         $1      
          5        VERIFY_RETURN_TYPE                                       $1
          6      > RETURN                                                   $1
   13     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function baz

Function bat:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
Branch analysis from position: 9
filename:       /in/bhsRi
function name:  Bat
number of ops:  21
compiled vars:  !0 = $thing
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        INIT_FCALL                                               'class_exists'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > JMPNZ_EX                                         ~2      $1, ->9
          5    >   INIT_FCALL                                               'interface_exists'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $3      
          8        BOOL                                             ~2      $3
          9    > > JMPZ_EX                                          ~2      ~2, ->17
         10    >   NEW                                              $4      'ReflectionClass'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0          
         13        INIT_METHOD_CALL                                         $4, 'hasMethod'
         14        SEND_VAL_EX                                              '__get'
         15        DO_FCALL                                      0  $6      
         16        BOOL                                             ~2      $6
         17    >   VERIFY_RETURN_TYPE                                       ~2
         18      > RETURN                                                   ~2
   17    19*       VERIFY_RETURN_TYPE                                       
         20*     > RETURN                                                   null

End of function bat

Class Foo: [no user functions]
Class Bar:
Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bhsRi
function name:  __get
number of ops:  2
compiled vars:  !0 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function __get

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.12 ms | 1447 KiB | 21 Q