Description
createPregMatchPattern appears in six constraint files across Draft 6, 7, and 2019-09, but the active replacements are inconsistent between files and several ECMA regex shorthand replacements are commented out without explanation.
Affected Files
src/JsonSchema/Constraints/Drafts/Draft06/AdditionalPropertiesConstraint.php
src/JsonSchema/Constraints/Drafts/Draft06/PatternPropertiesConstraint.php
src/JsonSchema/Constraints/Drafts/Draft07/AdditionalPropertiesConstraint.php
src/JsonSchema/Constraints/Drafts/Draft07/PatternPropertiesConstraint.php
src/JsonSchema/Constraints/Drafts/Draft2019/AdditionalPropertiesConstraint.php
src/JsonSchema/Constraints/Drafts/Draft2019/PatternPropertiesConstraint.php
Current State
The replacements active in each class differ, and several are left commented out:
| Replacement |
PatternConstraint (all drafts) |
PatternPropertiesConstraint (all drafts) |
AdditionalPropertiesConstraint (all drafts) |
\D → [^0-9] |
active |
commented out |
commented out |
\d → [0-9] |
active |
active |
commented out |
\p{digit} → ... |
→ [0-9] |
→ [0-9] |
→ \p{Nd} (inconsistent) |
\w → [A-Za-z0-9_] |
active |
commented out |
commented out |
\W → [^A-Za-z0-9_] |
active |
commented out |
commented out |
\s → [\s\x{200B}] |
active |
commented out |
commented out |
\p{Letter} → \p{L} |
active |
active |
active |
PatternConstraint (which validates string values against a pattern keyword) has all replacements active. The PatternPropertiesConstraint and AdditionalPropertiesConstraint versions (which match property key names against patterns) are missing most of them, with no explanation for why they should differ.
There is also a concrete inconsistency: \p{digit} maps to \p{Nd} in AdditionalPropertiesConstraint but to [0-9] in PatternPropertiesConstraint and PatternConstraint.
Expected Behaviour
- A decision should be made on whether the commented-out replacements should be enabled or permanently removed.
- If there is a deliberate reason for
PatternPropertiesConstraint / AdditionalPropertiesConstraint to use a different (reduced) set of replacements compared to PatternConstraint, that reason should be documented.
- The
\p{digit} mapping should be consistent across all files.
- Commented-out code should not remain in the codebase without explanation.
Description
createPregMatchPatternappears in six constraint files across Draft 6, 7, and 2019-09, but the active replacements are inconsistent between files and several ECMA regex shorthand replacements are commented out without explanation.Affected Files
src/JsonSchema/Constraints/Drafts/Draft06/AdditionalPropertiesConstraint.phpsrc/JsonSchema/Constraints/Drafts/Draft06/PatternPropertiesConstraint.phpsrc/JsonSchema/Constraints/Drafts/Draft07/AdditionalPropertiesConstraint.phpsrc/JsonSchema/Constraints/Drafts/Draft07/PatternPropertiesConstraint.phpsrc/JsonSchema/Constraints/Drafts/Draft2019/AdditionalPropertiesConstraint.phpsrc/JsonSchema/Constraints/Drafts/Draft2019/PatternPropertiesConstraint.phpCurrent State
The replacements active in each class differ, and several are left commented out:
PatternConstraint(all drafts)PatternPropertiesConstraint(all drafts)AdditionalPropertiesConstraint(all drafts)\D→[^0-9]\d→[0-9]\p{digit}→ ...[0-9][0-9]\p{Nd}(inconsistent)\w→[A-Za-z0-9_]\W→[^A-Za-z0-9_]\s→[\s\x{200B}]\p{Letter}→\p{L}PatternConstraint(which validates string values against apatternkeyword) has all replacements active. ThePatternPropertiesConstraintandAdditionalPropertiesConstraintversions (which match property key names against patterns) are missing most of them, with no explanation for why they should differ.There is also a concrete inconsistency:
\p{digit}maps to\p{Nd}inAdditionalPropertiesConstraintbut to[0-9]inPatternPropertiesConstraintandPatternConstraint.Expected Behaviour
PatternPropertiesConstraint/AdditionalPropertiesConstraintto use a different (reduced) set of replacements compared toPatternConstraint, that reason should be documented.\p{digit}mapping should be consistent across all files.