3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface PolicyRule { public function isSatisfiedBy(); } abstract class EnforcedRule implements PolicyRule { const TYPE_NO = 'No'; const TYPE_YES = 'Yes'; protected $enforcementType; protected function isEnforced() { return ($this->enforcementType == self::TYPE_YES); } protected function guardEnforcementType($aType) { if (! in_array($aType, [self::TYPE_NO, self::TYPE_YES])) { throw new InvalidEnforcementTypeException($aType); } } } abstract class MinimumCharacterCountRule extends EnforcedRule { const DEFAULT_MINIMUM = 1; protected $regexPattern; protected $minimumCount = self::DEFAULT_MINIMUM; public function isSatisfiedBy($aValue) { if (! $this->isEnforced()) { return true; } $matches = []; preg_match_all($this->regexPattern, $aValue, $matches); return (count($matches[0]) >= $this->minimumCount); } } class NumericRule extends MinimumCharacterCountRule { protected $regexPattern = '/[0-9]/'; public function __construct($aMinimumCount = self::DEFAULT_MINIMUM) { $this->minimumCount = $aMinimumCount; } } class SpecialCharacterRule extends MinimumCharacterCountRule { protected $regexPattern = '/[~`#\$%\^&\*\(\)\-_\+\|,\.<>]/'; public function __construct($aMinimumCount = self::DEFAULT_MINIMUM) { $this->minimumCount = $aMinimumCount; } } $numeric = new NumericRule(); var_dump($numeric->isSatisfiedBy("for5"));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbJKB
function name:  (null)
number of ops:  14
compiled vars:  !0 = $numeric
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_CLASS                                            'enforcedrule'
   28     1        DECLARE_CLASS                                            'minimumcharactercountrule', 'enforcedrule'
   49     2        DECLARE_CLASS                                            'numericrule', 'minimumcharactercountrule'
   59     3        DECLARE_CLASS                                            'specialcharacterrule', 'minimumcharactercountrule'
   69     4        NEW                                              $1      'NumericRule'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $1
   70     7        INIT_FCALL                                               'var_dump'
          8        INIT_METHOD_CALL                                         !0, 'isSatisfiedBy'
          9        SEND_VAL_EX                                              'for5'
         10        DO_FCALL                                      0  $4      
         11        SEND_VAR                                                 $4
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Class PolicyRule:
Function issatisfiedby:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbJKB
function name:  isSatisfiedBy
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   null

End of function issatisfiedby

End of class PolicyRule.

Class EnforcedRule:
Function isenforced:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbJKB
function name:  isEnforced
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   FETCH_OBJ_R                                      ~0      'enforcementType'
          1        IS_EQUAL                                         ~1      ~0, 'Yes'
          2      > RETURN                                                   ~1
   18     3*     > RETURN                                                   null

End of function isenforced

Function guardenforcementtype:
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
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbJKB
function name:  guardEnforcementType
number of ops:  9
compiled vars:  !0 = $aType
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1        IN_ARRAY                                         ~1      !0, <array>
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->8
   23     4    >   NEW                                              $3      'InvalidEnforcementTypeException'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7      > THROW                                         0          $3
   25     8    > > RETURN                                                   null

End of function guardenforcementtype

End of class EnforcedRule.

Class MinimumCharacterCountRule:
Function issatisfiedby:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbJKB
function name:  isSatisfiedBy
number of ops:  19
compiled vars:  !0 = $aValue, !1 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
   38     1        INIT_METHOD_CALL                                         'isEnforced'
          2        DO_FCALL                                      0  $2      
          3        BOOL_NOT                                         ~3      $2
          4      > JMPZ                                                     ~3, ->6
   39     5    > > RETURN                                                   <true>
   42     6    >   ASSIGN                                                   !1, <array>
   43     7        INIT_FCALL                                               'preg_match_all'
          8        FETCH_OBJ_R                                      ~5      'regexPattern'
          9        SEND_VAL                                                 ~5
         10        SEND_VAR                                                 !0
         11        SEND_REF                                                 !1
         12        DO_ICALL                                                 
   45    13        FETCH_DIM_R                                      ~7      !1, 0
         14        COUNT                                            ~8      ~7
         15        FETCH_OBJ_R                                      ~9      'minimumCount'
         16        IS_SMALLER_OR_EQUAL                              ~10     ~9, ~8
         17      > RETURN                                                   ~10
   46    18*     > RETURN                                                   null

End of function issatisfiedby

End of class MinimumCharacterCountRule.

Class NumericRule:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbJKB
function name:  __construct
number of ops:  4
compiled vars:  !0 = $aMinimumCount
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV_INIT                                        !0      <const ast>
   55     1        ASSIGN_OBJ                                               'minimumCount'
          2        OP_DATA                                                  !0
   56     3      > RETURN                                                   null

End of function __construct

End of class NumericRule.

Class SpecialCharacterRule:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VbJKB
function name:  __construct
number of ops:  4
compiled vars:  !0 = $aMinimumCount
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   63     0  E >   RECV_INIT                                        !0      <const ast>
   65     1        ASSIGN_OBJ                                               'minimumCount'
          2        OP_DATA                                                  !0
   66     3      > RETURN                                                   null

End of function __construct

End of class SpecialCharacterRule.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.64 ms | 1404 KiB | 17 Q