3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Validator { private array $rules; public function __construct(array $rules) { $this->rules = $rules; } public function validate (Enrollee $enrollee): ErrorList { $errorList = new ErrorList(); foreach ($this->rules as $fieldName => $checklist) { foreach ($checklist as $rule) { $result = $rule($enrollee->get($fieldName)); if (!$result===null) { $errorList->add($fieldName, new Error($result)); } } } return $errorList; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AC3p8
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E > > RETURN                                                   1

Class Validator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AC3p8
function name:  __construct
number of ops:  4
compiled vars:  !0 = $rules
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    9     1        ASSIGN_OBJ                                               'rules'
          2        OP_DATA                                                  !0
   10     3      > RETURN                                                   null

End of function __construct

Function validate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 30
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 30
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 28
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 28
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 27
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 27
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 28
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/AC3p8
function name:  validate
number of ops:  35
compiled vars:  !0 = $enrollee, !1 = $errorList, !2 = $checklist, !3 = $fieldName, !4 = $rule, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        NEW                                              $6      'ErrorList'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
   16     4        FETCH_OBJ_R                                      ~9      'rules'
          5      > FE_RESET_R                                       $10     ~9, ->30
          6    > > FE_FETCH_R                                       ~11     $10, !2, ->30
          7    >   ASSIGN                                                   !3, ~11
   18     8      > FE_RESET_R                                       $13     !2, ->28
          9    > > FE_FETCH_R                                               $13, !4, ->28
   20    10    >   INIT_DYNAMIC_CALL                                        !4
         11        INIT_METHOD_CALL                                         !0, 'get'
         12        SEND_VAR_EX                                              !3
         13        DO_FCALL                                      0  $14     
         14        SEND_VAR_NO_REF_EX                                       $14
         15        DO_FCALL                                      0  $15     
         16        ASSIGN                                                   !5, $15
   21    17        BOOL_NOT                                         ~17     !5
         18        TYPE_CHECK                                    2          ~17
         19      > JMPZ                                                     ~18, ->27
   22    20    >   INIT_METHOD_CALL                                         !1, 'add'
         21        SEND_VAR_EX                                              !3
         22        NEW                                              $19     'Error'
         23        SEND_VAR_EX                                              !5
         24        DO_FCALL                                      0          
         25        SEND_VAR_NO_REF_EX                                       $19
         26        DO_FCALL                                      0          
   18    27    > > JMP                                                      ->9
         28    >   FE_FREE                                                  $13
   16    29      > JMP                                                      ->6
         30    >   FE_FREE                                                  $10
   26    31        VERIFY_RETURN_TYPE                                       !1
         32      > RETURN                                                   !1
   27    33*       VERIFY_RETURN_TYPE                                       
         34*     > RETURN                                                   null

End of function validate

End of class Validator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.99 ms | 1000 KiB | 13 Q