3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Filter { abstract public static function check($value, array $options = array()); } final class IntFilter extends Filter { public static function check($value, array $options = array()) { return $value; } } final class StringFilter extends Filter { public static function check($value, array $options = array()) { $length = mb_strlen($value, '8bit'); // Empty if (false === ($options['empty'] ?? true)) { if (0 === $length) { throw new LengthException('chaine vide !'); } } // Min & max length if ($options['max']) { $maxLength = IntFilter::check($options['max'], ['min' => 1]); if ($length > $maxLength) { throw new LengthException('trop long !'); } } if ($options['min']) { $minLength = IntFilter::check($options['min'], ['min' => 1]); if ($length > $minLength) { throw new LengthException('trop court !'); } } return $value; } } var_dump(StringFilter::check('test '));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/92ZU2
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_STATIC_METHOD_CALL                                  'StringFilter', 'check'
          2        SEND_VAL                                                 'test++++'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
          6      > RETURN                                                   1

Class Filter:
Function check:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/92ZU2
function name:  check
number of ops:  3
compiled vars:  !0 = $value, !1 = $options
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
          2      > RETURN                                                   null

End of function check

End of class Filter.

Class IntFilter:
Function check:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/92ZU2
function name:  check
number of ops:  4
compiled vars:  !0 = $value, !1 = $options
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   12     2      > RETURN                                                   !0
   13     3*     > RETURN                                                   null

End of function check

End of class IntFilter.

Class StringFilter:
Function check:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 32
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 46
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 46
Branch analysis from position: 42
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 46
Branch analysis from position: 32
Branch analysis from position: 18
filename:       /in/92ZU2
function name:  check
number of ops:  48
compiled vars:  !0 = $value, !1 = $options, !2 = $length, !3 = $maxLength, !4 = $minLength
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   21     2        INIT_FCALL                                               'mb_strlen'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 '8bit'
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
   24     7        FETCH_DIM_IS                                     ~7      !1, 'empty'
          8        COALESCE                                         ~8      ~7
          9        QM_ASSIGN                                        ~8      <true>
         10        TYPE_CHECK                                    4          ~8
         11      > JMPZ                                                     ~9, ->18
   25    12    >   IS_IDENTICAL                                             !2, 0
         13      > JMPZ                                                     ~10, ->18
   26    14    >   NEW                                              $11     'LengthException'
         15        SEND_VAL_EX                                              'chaine+vide+%21'
         16        DO_FCALL                                      0          
         17      > THROW                                         0          $11
   31    18    >   FETCH_DIM_R                                      ~13     !1, 'max'
         19      > JMPZ                                                     ~13, ->32
   32    20    >   INIT_STATIC_METHOD_CALL                                  'IntFilter', 'check'
         21        FETCH_DIM_R                                      ~14     !1, 'max'
         22        SEND_VAL                                                 ~14
         23        SEND_VAL                                                 <array>
         24        DO_FCALL                                      0  $15     
         25        ASSIGN                                                   !3, $15
   34    26        IS_SMALLER                                               !3, !2
         27      > JMPZ                                                     ~17, ->32
   35    28    >   NEW                                              $18     'LengthException'
         29        SEND_VAL_EX                                              'trop+long+%21'
         30        DO_FCALL                                      0          
         31      > THROW                                         0          $18
   39    32    >   FETCH_DIM_R                                      ~20     !1, 'min'
         33      > JMPZ                                                     ~20, ->46
   40    34    >   INIT_STATIC_METHOD_CALL                                  'IntFilter', 'check'
         35        FETCH_DIM_R                                      ~21     !1, 'min'
         36        SEND_VAL                                                 ~21
         37        SEND_VAL                                                 <array>
         38        DO_FCALL                                      0  $22     
         39        ASSIGN                                                   !4, $22
   42    40        IS_SMALLER                                               !4, !2
         41      > JMPZ                                                     ~24, ->46
   43    42    >   NEW                                              $25     'LengthException'
         43        SEND_VAL_EX                                              'trop+court+%21'
         44        DO_FCALL                                      0          
         45      > THROW                                         0          $25
   47    46    > > RETURN                                                   !0
   48    47*     > RETURN                                                   null

End of function check

End of class StringFilter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.3 ms | 1400 KiB | 17 Q