3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=0); function acceptBool(bool $x) {} function acceptInt(int $x) {} function acceptFloat(float $x) {} function acceptString(string $x) {} function acceptArray(array $x) {} function acceptObject(object $x) {} $functions = [ "bool" => "acceptBool", "int" => "acceptInt", "float" => "acceptFloat", "string" => "acceptString", "array" => "acceptArray", "object" => "acceptObject", ]; $vars = [ "null" => null, "bool" => true, "int" => 1, "float" => 3.14, "numeric string" => "2.72", "non-numeric string" => "elephphant", "array" => [1, 2, 3], "object" => new stdClass(), ]; foreach ($vars as $passedType => $var) { foreach ($functions as $acceptedType => $function) { if ($passedType === $acceptedType) { continue; } echo str_pad($passedType, 18) . " -> " . str_pad($acceptedType, 10) . ": "; try { $function($var); echo "success"; } catch(TypeError $e) { echo "failure"; } echo "\n"; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 44
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 44
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 16, Position 2 = 42
Branch analysis from position: 16
2 jumps found. (Code = 78) Position 1 = 17, Position 2 = 42
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 21
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 42
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
Found catch point at position: 38
Branch analysis from position: 38
2 jumps found. (Code = 107) Position 1 = 39, Position 2 = -2
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
filename:       /in/lSGSr
function name:  (null)
number of ops:  46
compiled vars:  !0 = $functions, !1 = $vars, !2 = $var, !3 = $passedType, !4 = $function, !5 = $acceptedType, !6 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   12     0  E >   ASSIGN                                                       !0, <array>
   22     1        INIT_ARRAY                                           ~8      null, 'null'
          2        ADD_ARRAY_ELEMENT                                    ~8      <true>, 'bool'
   24     3        ADD_ARRAY_ELEMENT                                    ~8      1, 'int'
   25     4        ADD_ARRAY_ELEMENT                                    ~8      3.14, 'float'
   26     5        ADD_ARRAY_ELEMENT                                    ~8      '2.72', 'numeric+string'
   27     6        ADD_ARRAY_ELEMENT                                    ~8      'elephphant', 'non-numeric+string'
   22     7        ADD_ARRAY_ELEMENT                                    ~8      <array>, 'array'
   29     8        NEW                                                  $9      'stdClass'
          9        DO_FCALL                                          0          
         10        ADD_ARRAY_ELEMENT                                    ~8      $9, 'object'
   21    11        ASSIGN                                                       !1, ~8
   32    12      > FE_RESET_R                                           $12     !1, ->44
         13    > > FE_FETCH_R                                           ~13     $12, !2, ->44
         14    >   ASSIGN                                                       !3, ~13
   33    15      > FE_RESET_R                                           $15     !0, ->42
         16    > > FE_FETCH_R                                           ~16     $15, !4, ->42
         17    >   ASSIGN                                                       !5, ~16
   34    18        IS_IDENTICAL                                                 !3, !5
         19      > JMPZ                                                         ~18, ->21
   35    20    > > JMP                                                          ->16
   38    21    >   INIT_FCALL                                                   'str_pad'
         22        SEND_VAR                                                     !3
         23        SEND_VAL                                                     18
         24        DO_ICALL                                             $19     
         25        CONCAT                                               ~20     $19, '+-%3E+'
         26        INIT_FCALL                                                   'str_pad'
         27        SEND_VAR                                                     !5
         28        SEND_VAL                                                     10
         29        DO_ICALL                                             $21     
         30        CONCAT                                               ~22     ~20, $21
         31        CONCAT                                               ~23     ~22, '%3A+'
         32        ECHO                                                         ~23
   40    33        INIT_DYNAMIC_CALL                                            !4
         34        SEND_VAR_EX                                                  !2
         35        DO_FCALL                                          0          
   41    36        ECHO                                                         'success'
         37      > JMP                                                          ->40
   42    38  E > > CATCH                                           last         'TypeError'
   43    39    >   ECHO                                                         'failure'
   45    40    >   ECHO                                                         '%0A'
   33    41      > JMP                                                          ->16
         42    >   FE_FREE                                                      $15
   32    43      > JMP                                                          ->13
         44    >   FE_FREE                                                      $12
   47    45      > RETURN                                                       1

Function acceptbool:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lSGSr
function name:  acceptBool
number of ops:  2
compiled vars:  !0 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of function acceptbool

Function acceptint:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lSGSr
function name:  acceptInt
number of ops:  2
compiled vars:  !0 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of function acceptint

Function acceptfloat:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lSGSr
function name:  acceptFloat
number of ops:  2
compiled vars:  !0 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of function acceptfloat

Function acceptstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lSGSr
function name:  acceptString
number of ops:  2
compiled vars:  !0 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of function acceptstring

Function acceptarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lSGSr
function name:  acceptArray
number of ops:  2
compiled vars:  !0 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of function acceptarray

Function acceptobject:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lSGSr
function name:  acceptObject
number of ops:  2
compiled vars:  !0 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
          1      > RETURN                                                       null

End of function acceptobject

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.39 ms | 2417 KiB | 14 Q