3v4l.org

run code in 500+ PHP versions simultaneously
<?php class NumberInRange implements ValidatorRuleInterface { private string $format; private int $min; private int $max; private string $fieldName; public function __construct(int $min, int $max, string $fieldName) { $this->min = $min; $this->max = $max; $this->fieldName = $fieldName; $this->format = '%s не может быть больше $this->max и меньше $this->min.'; } public function __invoke(mixed $value): ?ValidationError { if (!is_int($value)) { throw new TypeException("Неправильный тип данных в аргументе функции."); } $resultMin = $value < $min; $resultMax = $value > $max; if ($resultMin || $resultMax) { $errorText = sprintf($this->format, $this->fieldName); return new ValidationError($errorText); } else { return null; } } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IZjC3
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                                'numberinrange'
   37     1      > RETURN                                                       1

Class NumberInRange:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IZjC3
function name:  __construct
number of ops:  12
compiled vars:  !0 = $min, !1 = $max, !2 = $fieldName
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   15     3        ASSIGN_OBJ                                                   'min'
          4        OP_DATA                                                      !0
   16     5        ASSIGN_OBJ                                                   'max'
          6        OP_DATA                                                      !1
   17     7        ASSIGN_OBJ                                                   'fieldName'
          8        OP_DATA                                                      !2
   18     9        ASSIGN_OBJ                                                   'format'
         10        OP_DATA                                                      '%25s+%D0%BD%D0%B5+%D0%BC%D0%BE%D0%B6%D0%B5%D1%82+%D0%B1%D1%8B%D1%82%D1%8C+%D0%B1%D0%BE%D0%BB%D1%8C%D1%88%D0%B5+%24this-%3Emax+%D0%B8+%D0%BC%D0%B5%D0%BD%D1%8C%D1%88%D0%B5+%24this-%3Emin.'
   19    11      > RETURN                                                       null

End of function __construct

Function __invoke:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 28
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/IZjC3
function name:  __invoke
number of ops:  31
compiled vars:  !0 = $value, !1 = $resultMin, !2 = $min, !3 = $resultMax, !4 = $max, !5 = $errorText
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   RECV                                                 !0      
   23     1        TYPE_CHECK                                       16  ~6      !0
          2        BOOL_NOT                                             ~7      ~6
          3      > JMPZ                                                         ~7, ->8
   24     4    >   NEW                                                  $8      'TypeException'
          5        SEND_VAL_EX                                                  '%D0%9D%D0%B5%D0%BF%D1%80%D0%B0%D0%B2%D0%B8%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9+%D1%82%D0%B8%D0%BF+%D0%B4%D0%B0%D0%BD%D0%BD%D1%8B%D1%85+%D0%B2+%D0%B0%D1%80%D0%B3%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D0%B5+%D1%84%D1%83%D0%BD%D0%BA%D1%86%D0%B8%D0%B8.'
          6        DO_FCALL                                          0          
          7      > THROW                                             0          $8
   27     8    >   IS_SMALLER                                           ~10     !0, !2
          9        ASSIGN                                                       !1, ~10
   28    10        IS_SMALLER                                           ~12     !4, !0
         11        ASSIGN                                                       !3, ~12
   30    12      > JMPNZ_EX                                             ~14     !1, ->14
         13    >   BOOL                                                 ~14     !3
         14    > > JMPZ                                                         ~14, ->28
   31    15    >   INIT_FCALL                                                   'sprintf'
         16        FETCH_OBJ_R                                          ~15     'format'
         17        SEND_VAL                                                     ~15
         18        FETCH_OBJ_R                                          ~16     'fieldName'
         19        SEND_VAL                                                     ~16
         20        DO_ICALL                                             $17     
         21        ASSIGN                                                       !5, $17
   32    22        NEW                                                  $19     'ValidationError'
         23        SEND_VAR_EX                                                  !5
         24        DO_FCALL                                          0          
         25        VERIFY_RETURN_TYPE                                           $19
         26      > RETURN                                                       $19
   30    27*       JMP                                                          ->29
   34    28    > > RETURN                                                       null
   36    29*       VERIFY_RETURN_TYPE                                           
         30*     > RETURN                                                       null

End of function __invoke

End of class NumberInRange.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.52 ms | 1674 KiB | 14 Q