3v4l.org

run code in 300+ PHP versions simultaneously
<?php class InvalidArgumentType extends InvalidArgumentException { public function __construct(int $position, string $requiredType, $value) { $encoded = json_encode($value); if (strlen($encoded) > 10) { $encoded = sprintf('%s ... %s', substr($encoded, 0, 10), substr($encoded, -1)); } $inferredType = is_object($value) ? get_class($value) : gettype($value); parent::__construct(sprintf( 'Argument %d value %s should be %s but is %s.', $position, $encoded, $requiredType, $inferredType )); } } class Foo {} echo (new InvalidArgumentType(1, 'string', new Foo()))->getMessage().PHP_EOL; echo (new InvalidArgumentType(2, 'string', [1,2,3,4,5,6,7,8,9,10]))->getMessage().PHP_EOL; echo (new InvalidArgumentType(3, 'string', 123))->getMessage().PHP_EOL; echo (new InvalidArgumentType(2, 'string', null))->getMessage();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ko7o1
function name:  (null)
number of ops:  38
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $0      'InvalidArgumentType'
          1        SEND_VAL_EX                                              1
          2        SEND_VAL_EX                                              'string'
          3        NEW                                              $1      'Foo'
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $1
          6        DO_FCALL                                      0          
          7        INIT_METHOD_CALL                                         $0, 'getMessage'
          8        DO_FCALL                                      0  $4      
          9        CONCAT                                           ~5      $4, '%0A'
         10        ECHO                                                     ~5
   28    11        NEW                                              $6      'InvalidArgumentType'
         12        SEND_VAL_EX                                              2
         13        SEND_VAL_EX                                              'string'
         14        SEND_VAL_EX                                              <array>
         15        DO_FCALL                                      0          
         16        INIT_METHOD_CALL                                         $6, 'getMessage'
         17        DO_FCALL                                      0  $8      
         18        CONCAT                                           ~9      $8, '%0A'
         19        ECHO                                                     ~9
   29    20        NEW                                              $10     'InvalidArgumentType'
         21        SEND_VAL_EX                                              3
         22        SEND_VAL_EX                                              'string'
         23        SEND_VAL_EX                                              123
         24        DO_FCALL                                      0          
         25        INIT_METHOD_CALL                                         $10, 'getMessage'
         26        DO_FCALL                                      0  $12     
         27        CONCAT                                           ~13     $12, '%0A'
         28        ECHO                                                     ~13
   30    29        NEW                                              $14     'InvalidArgumentType'
         30        SEND_VAL_EX                                              2
         31        SEND_VAL_EX                                              'string'
         32        SEND_VAL_EX                                              null
         33        DO_FCALL                                      0          
         34        INIT_METHOD_CALL                                         $14, 'getMessage'
         35        DO_FCALL                                      0  $16     
         36        ECHO                                                     $16
         37      > RETURN                                                   1

Class InvalidArgumentType:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 25
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/ko7o1
function name:  __construct
number of ops:  44
compiled vars:  !0 = $position, !1 = $requiredType, !2 = $value, !3 = $encoded, !4 = $inferredType
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    7     3        INIT_FCALL                                               'json_encode'
          4        SEND_VAR                                                 !2
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !3, $5
    9     7        STRLEN                                           ~7      !3
          8        IS_SMALLER                                               10, ~7
          9      > JMPZ                                                     ~8, ->25
   10    10    >   INIT_FCALL                                               'sprintf'
         11        SEND_VAL                                                 '%25s+...+%25s'
         12        INIT_FCALL                                               'substr'
         13        SEND_VAR                                                 !3
         14        SEND_VAL                                                 0
         15        SEND_VAL                                                 10
         16        DO_ICALL                                         $9      
         17        SEND_VAR                                                 $9
         18        INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !3
         20        SEND_VAL                                                 -1
         21        DO_ICALL                                         $10     
         22        SEND_VAR                                                 $10
         23        DO_ICALL                                         $11     
         24        ASSIGN                                                   !3, $11
   13    25    >   TYPE_CHECK                                  256          !2
         26      > JMPZ                                                     ~13, ->30
         27    >   GET_CLASS                                        ~14     !2
         28        QM_ASSIGN                                        ~15     ~14
         29      > JMP                                                      ->32
         30    >   GET_TYPE                                         ~16     !2
         31        QM_ASSIGN                                        ~15     ~16
         32    >   ASSIGN                                                   !4, ~15
   15    33        INIT_STATIC_METHOD_CALL                                  
         34        INIT_FCALL                                               'sprintf'
   16    35        SEND_VAL                                                 'Argument+%25d+value+%25s+should+be+%25s+but+is+%25s.'
   17    36        SEND_VAR                                                 !0
   18    37        SEND_VAR                                                 !3
   19    38        SEND_VAR                                                 !1
   20    39        SEND_VAR                                                 !4
   15    40        DO_ICALL                                         $18     
   20    41        SEND_VAR_NO_REF_EX                                       $18
   15    42        DO_FCALL                                      0          
   22    43      > RETURN                                                   null

End of function __construct

End of class InvalidArgumentType.

Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
242.49 ms | 1017 KiB | 16 Q