3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); class Test { public static function valid(?float $value): bool { if ($value !== null && !is_float($value)) throw new InvalidArgumentException('Not valid'); return true; } } var_dump(Test::valid('1.2')); // "valid" because of implicit typecast, which can disabled with declare strict_types var_dump(Test::valid('not a number')); // triggers TypeError, NOT InvalidArgumentException
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mNaCv
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                                   'var_dump'
          1        INIT_STATIC_METHOD_CALL                                      'Test', 'valid'
          2        SEND_VAL                                                     '1.2'
          3        DO_FCALL                                          0  $0      
          4        SEND_VAR                                                     $0
          5        DO_ICALL                                                     
   14     6        INIT_FCALL                                                   'var_dump'
          7        INIT_STATIC_METHOD_CALL                                      'Test', 'valid'
          8        SEND_VAL                                                     'not+a+number'
          9        DO_FCALL                                          0  $2      
         10        SEND_VAR                                                     $2
         11        DO_ICALL                                                     
         12      > RETURN                                                       1

Class Test:
Function valid:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/mNaCv
function name:  valid
number of ops:  14
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
    8     1        TYPE_CHECK                                      1020  ~1      !0
          2      > JMPZ_EX                                              ~1      ~1, ->6
          3    >   TYPE_CHECK                                       32  ~2      !0
          4        BOOL_NOT                                             ~3      ~2
          5        BOOL                                                 ~1      ~3
          6    > > JMPZ                                                         ~1, ->11
          7    >   NEW                                                  $4      'InvalidArgumentException'
          8        SEND_VAL_EX                                                  'Not+valid'
          9        DO_FCALL                                          0          
         10      > THROW                                             0          $4
    9    11    > > RETURN                                                       <true>
   10    12*       VERIFY_RETURN_TYPE                                           
         13*     > RETURN                                                       null

End of function valid

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
151.17 ms | 1543 KiB | 14 Q