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()) { // Trim if (false !== ($options['trim'] ?? true)) { $value = trim($value); } $length = mb_strlen($value, '8bit'); // Empty if (false === ($options['empty'] ?? true)) { if (0 === $length) { throw new LengthException('chaine vide !'); } } // Min & max length if (isset($options['max'])) { $maxLength = IntFilter::check($options['max'], ['min' => 1]); if ($length > $maxLength) { throw new LengthException('trop long !'); } } if (isset($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/Pn4mP
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   55     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/Pn4mP
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/Pn4mP
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 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 27
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 41
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 41
Branch analysis from position: 37
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 55
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 55
Branch analysis from position: 51
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
Branch analysis from position: 41
Branch analysis from position: 27
Branch analysis from position: 11
filename:       /in/Pn4mP
function name:  check
number of ops:  57
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        FETCH_DIM_IS                                     ~5      !1, 'trim'
          3        COALESCE                                         ~6      ~5
          4        QM_ASSIGN                                        ~6      <true>
          5        TYPE_CHECK                                  1018          ~6
          6      > JMPZ                                                     ~7, ->11
   22     7    >   INIT_FCALL                                               'trim'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $8      
         10        ASSIGN                                                   !0, $8
   25    11    >   INIT_FCALL                                               'mb_strlen'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 '8bit'
         14        DO_ICALL                                         $10     
         15        ASSIGN                                                   !2, $10
   28    16        FETCH_DIM_IS                                     ~12     !1, 'empty'
         17        COALESCE                                         ~13     ~12
         18        QM_ASSIGN                                        ~13     <true>
         19        TYPE_CHECK                                    4          ~13
         20      > JMPZ                                                     ~14, ->27
   29    21    >   IS_IDENTICAL                                             !2, 0
         22      > JMPZ                                                     ~15, ->27
   30    23    >   NEW                                              $16     'LengthException'
         24        SEND_VAL_EX                                              'chaine+vide+%21'
         25        DO_FCALL                                      0          
         26      > THROW                                         0          $16
   35    27    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'max'
         28      > JMPZ                                                     ~18, ->41
   36    29    >   INIT_STATIC_METHOD_CALL                                  'IntFilter', 'check'
         30        FETCH_DIM_R                                      ~19     !1, 'max'
         31        SEND_VAL                                                 ~19
         32        SEND_VAL                                                 <array>
         33        DO_FCALL                                      0  $20     
         34        ASSIGN                                                   !3, $20
   38    35        IS_SMALLER                                               !3, !2
         36      > JMPZ                                                     ~22, ->41
   39    37    >   NEW                                              $23     'LengthException'
         38        SEND_VAL_EX                                              'trop+long+%21'
         39        DO_FCALL                                      0          
         40      > THROW                                         0          $23
   43    41    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'min'
         42      > JMPZ                                                     ~25, ->55
   44    43    >   INIT_STATIC_METHOD_CALL                                  'IntFilter', 'check'
         44        FETCH_DIM_R                                      ~26     !1, 'min'
         45        SEND_VAL                                                 ~26
         46        SEND_VAL                                                 <array>
         47        DO_FCALL                                      0  $27     
         48        ASSIGN                                                   !4, $27
   46    49        IS_SMALLER                                               !4, !2
         50      > JMPZ                                                     ~29, ->55
   47    51    >   NEW                                              $30     'LengthException'
         52        SEND_VAL_EX                                              'trop+court+%21'
         53        DO_FCALL                                      0          
         54      > THROW                                         0          $30
   51    55    > > RETURN                                                   !0
   52    56*     > RETURN                                                   null

End of function check

End of class StringFilter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.22 ms | 1404 KiB | 19 Q