3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Base { static function getClass() { return get_called_class(); } }; class Animal extends Base {}; class Dog extends Animal {}; class noAnimal extends Base{}; $tests = [ Animal::class, Dog::class, noAnimal::class, new Animal(), new Dog(), new noAnimal() ]; foreach($tests as $i => $test) { printf('Test #%d is_a(%-10s) => %s'."\n", $i, $test::getClass(), var_export(is_a($test, Animal::class, true), true) ); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 35
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 35
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/ind2m
function name:  (null)
number of ops:  37
compiled vars:  !0 = $tests, !1 = $test, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   INIT_ARRAY                                       ~3      'Animal'
          1        ADD_ARRAY_ELEMENT                                ~3      'Dog'
          2        ADD_ARRAY_ELEMENT                                ~3      'noAnimal'
   14     3        NEW                                              $4      'Animal'
          4        DO_FCALL                                      0          
          5        ADD_ARRAY_ELEMENT                                ~3      $4
   15     6        NEW                                              $6      'Dog'
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~3      $6
   16     9        NEW                                              $8      'noAnimal'
         10        DO_FCALL                                      0          
         11        ADD_ARRAY_ELEMENT                                ~3      $8
   10    12        ASSIGN                                                   !0, ~3
   19    13      > FE_RESET_R                                       $11     !0, ->35
         14    > > FE_FETCH_R                                       ~12     $11, !1, ->35
         15    >   ASSIGN                                                   !2, ~12
   20    16        INIT_FCALL                                               'printf'
         17        SEND_VAL                                                 'Test+%23%25d+is_a%28%25-10s%29+%3D%3E+%25s%0A'
   21    18        SEND_VAR                                                 !2
   22    19        FETCH_CLASS                                   0  $14     !1
         20        INIT_STATIC_METHOD_CALL                                  $14, 'getClass'
         21        DO_FCALL                                      0  $15     
         22        SEND_VAR                                                 $15
   23    23        INIT_FCALL                                               'var_export'
         24        INIT_FCALL                                               'is_a'
         25        SEND_VAR                                                 !1
         26        SEND_VAL                                                 'Animal'
         27        SEND_VAL                                                 <true>
         28        DO_ICALL                                         $16     
         29        SEND_VAR                                                 $16
         30        SEND_VAL                                                 <true>
         31        DO_ICALL                                         $17     
         32        SEND_VAR                                                 $17
   20    33        DO_ICALL                                                 
   19    34      > JMP                                                      ->14
         35    >   FE_FREE                                                  $11
   25    36      > RETURN                                                   1

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

End of function getclass

End of class Base.

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

End of function getclass

End of class Animal.

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

End of function getclass

End of class Dog.

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

End of function getclass

End of class noAnimal.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.71 ms | 1012 KiB | 16 Q