3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Base { public static function test(self $obj) : self { echo get_class($obj) . "\n"; if (!$obj instanceof static) { throw new InvalidArgumentException(sprintf( "Object (%s) must be an instance of %s", get_class($obj), static::class )); } return new static($obj); } } class Ext extends Base {} $base = new Base; $ext = new Ext; Base::test($base); Base::test($ext); Ext::test($ext); Ext::test($base);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Tp7k6
function name:  (null)
number of ops:  19
compiled vars:  !0 = $base, !1 = $ext
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $2      'Base'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   22     3        NEW                                              $5      'Ext'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   24     6        INIT_STATIC_METHOD_CALL                                  'Base', 'test'
          7        SEND_VAR                                                 !0
          8        DO_FCALL                                      0          
   25     9        INIT_STATIC_METHOD_CALL                                  'Base', 'test'
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0          
   27    12        INIT_STATIC_METHOD_CALL                                  'Ext', 'test'
         13        SEND_VAR                                                 !1
         14        DO_FCALL                                      0          
   28    15        INIT_STATIC_METHOD_CALL                                  'Ext', 'test'
         16        SEND_VAR                                                 !0
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Class Base:
Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Tp7k6
function name:  test
number of ops:  25
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        GET_CLASS                                        ~1      !0
          2        CONCAT                                           ~2      ~1, '%0A'
          3        ECHO                                                     ~2
    7     4        INSTANCEOF                                       ~3      !0
          5        BOOL_NOT                                         ~4      ~3
          6      > JMPZ                                                     ~4, ->18
    8     7    >   NEW                                              $5      'InvalidArgumentException'
          8        INIT_FCALL                                               'sprintf'
    9     9        SEND_VAL                                                 'Object+%28%25s%29+must+be+an+instance+of+%25s'
   10    10        GET_CLASS                                        ~6      !0
         11        SEND_VAL                                                 ~6
   11    12        FETCH_CLASS_NAME                                 ~7      
         13        SEND_VAL                                                 ~7
    8    14        DO_ICALL                                         $8      
   11    15        SEND_VAR_NO_REF_EX                                       $8
    8    16        DO_FCALL                                      0          
   11    17      > THROW                                         0          $5
   15    18    >   NEW                          static              $10     
         19        SEND_VAR_EX                                              !0
         20        DO_FCALL                                      0          
         21        VERIFY_RETURN_TYPE                                       $10
         22      > RETURN                                                   $10
   16    23*       VERIFY_RETURN_TYPE                                       
         24*     > RETURN                                                   null

End of function test

End of class Base.

Class Ext:
Function test:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 18
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Tp7k6
function name:  test
number of ops:  25
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        GET_CLASS                                        ~1      !0
          2        CONCAT                                           ~2      ~1, '%0A'
          3        ECHO                                                     ~2
    7     4        INSTANCEOF                                       ~3      !0
          5        BOOL_NOT                                         ~4      ~3
          6      > JMPZ                                                     ~4, ->18
    8     7    >   NEW                                              $5      'InvalidArgumentException'
          8        INIT_FCALL                                               'sprintf'
    9     9        SEND_VAL                                                 'Object+%28%25s%29+must+be+an+instance+of+%25s'
   10    10        GET_CLASS                                        ~6      !0
         11        SEND_VAL                                                 ~6
   11    12        FETCH_CLASS_NAME                                 ~7      
         13        SEND_VAL                                                 ~7
    8    14        DO_ICALL                                         $8      
   11    15        SEND_VAR_NO_REF_EX                                       $8
    8    16        DO_FCALL                                      0          
   11    17      > THROW                                         0          $5
   15    18    >   NEW                          static              $10     
         19        SEND_VAR_EX                                              !0
         20        DO_FCALL                                      0          
         21        VERIFY_RETURN_TYPE                                       $10
         22      > RETURN                                                   $10
   16    23*       VERIFY_RETURN_TYPE                                       
         24*     > RETURN                                                   null

End of function test

End of class Ext.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.03 ms | 1003 KiB | 14 Q