3v4l.org

run code in 500+ 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 = 17
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Tp7k6
function name:  test
number of ops:  24
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, ->17
    8     7    >   NEW                                                  $5      'InvalidArgumentException'
   10     8        GET_CLASS                                            ~6      !0
   11     9        FETCH_CLASS_NAME                                     ~7      
         10        ROPE_INIT                                         4  ~9      'Object+%28'
         11        ROPE_ADD                                          1  ~9      ~9, ~6
         12        ROPE_ADD                                          2  ~9      ~9, '%29+must+be+an+instance+of+'
         13        ROPE_END                                          3  ~8      ~9, ~7
         14        SEND_VAL_EX                                                  ~8
    8    15        DO_FCALL                                          0          
   11    16      > THROW                                             0          $5
   15    17    >   NEW                              static              $12     
         18        SEND_VAR_EX                                                  !0
         19        DO_FCALL                                          0          
         20        VERIFY_RETURN_TYPE                                           $12
         21      > RETURN                                                       $12
   16    22*       VERIFY_RETURN_TYPE                                           
         23*     > 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 = 17
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Tp7k6
function name:  test
number of ops:  24
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, ->17
    8     7    >   NEW                                                  $5      'InvalidArgumentException'
   10     8        GET_CLASS                                            ~6      !0
   11     9        FETCH_CLASS_NAME                                     ~7      
         10        ROPE_INIT                                         4  ~9      'Object+%28'
         11        ROPE_ADD                                          1  ~9      ~9, ~6
         12        ROPE_ADD                                          2  ~9      ~9, '%29+must+be+an+instance+of+'
         13        ROPE_END                                          3  ~8      ~9, ~7
         14        SEND_VAL_EX                                                  ~8
    8    15        DO_FCALL                                          0          
   11    16      > THROW                                             0          $5
   15    17    >   NEW                              static              $12     
         18        SEND_VAR_EX                                                  !0
         19        DO_FCALL                                          0          
         20        VERIFY_RETURN_TYPE                                           $12
         21      > RETURN                                                       $12
   16    22*       VERIFY_RETURN_TYPE                                           
         23*     > RETURN                                                       null

End of function test

End of class Ext.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.25 ms | 2295 KiB | 13 Q