diff --git a/CHANGELOG.md b/CHANGELOG.md index f24a0cc0..873feb86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Replace traditional syntax array with short syntax array ([#747](https://github.com/jsonrainbow/json-schema/pull/747)) - Increase phpstan level to 8 with baseline to swallow existing errors ([#673](https://github.com/jsonrainbow/json-schema/pull/673)) - Add ext-json to composer.json to ensure JSON extension available ([#759](https://github.com/jsonrainbow/json-schema/pull/759)) +- Add visibility modifiers to class constants ([#757](https://github.com/jsonrainbow/json-schema/pull/757)) ## [6.0.0] - 2024-07-30 ### Added diff --git a/src/JsonSchema/ConstraintError.php b/src/JsonSchema/ConstraintError.php index 52d53211..ac7358a1 100644 --- a/src/JsonSchema/ConstraintError.php +++ b/src/JsonSchema/ConstraintError.php @@ -6,51 +6,51 @@ class ConstraintError extends Enum { - const ADDITIONAL_ITEMS = 'additionalItems'; - const ADDITIONAL_PROPERTIES = 'additionalProp'; - const ALL_OF = 'allOf'; - const ANY_OF = 'anyOf'; - const DEPENDENCIES = 'dependencies'; - const DISALLOW = 'disallow'; - const DIVISIBLE_BY = 'divisibleBy'; - const ENUM = 'enum'; - const CONSTANT = 'const'; - const EXCLUSIVE_MINIMUM = 'exclusiveMinimum'; - const EXCLUSIVE_MAXIMUM = 'exclusiveMaximum'; - const FORMAT_COLOR = 'colorFormat'; - const FORMAT_DATE = 'dateFormat'; - const FORMAT_DATE_TIME = 'dateTimeFormat'; - const FORMAT_DATE_UTC = 'dateUtcFormat'; - const FORMAT_EMAIL = 'emailFormat'; - const FORMAT_HOSTNAME = 'styleHostName'; - const FORMAT_IP = 'ipFormat'; - const FORMAT_PHONE = 'phoneFormat'; - const FORMAT_REGEX= 'regexFormat'; - const FORMAT_STYLE = 'styleFormat'; - const FORMAT_TIME = 'timeFormat'; - const FORMAT_URL = 'urlFormat'; - const FORMAT_URL_REF = 'urlRefFormat'; - const INVALID_SCHEMA = 'invalidSchema'; - const LENGTH_MAX = 'maxLength'; - const LENGTH_MIN = 'minLength'; - const MAXIMUM = 'maximum'; - const MIN_ITEMS = 'minItems'; - const MINIMUM = 'minimum'; - const MISSING_ERROR = 'missingError'; - const MISSING_MAXIMUM = 'missingMaximum'; - const MISSING_MINIMUM = 'missingMinimum'; - const MAX_ITEMS = 'maxItems'; - const MULTIPLE_OF = 'multipleOf'; - const NOT = 'not'; - const ONE_OF = 'oneOf'; - const REQUIRED = 'required'; - const REQUIRES = 'requires'; - const PATTERN = 'pattern'; - const PREGEX_INVALID = 'pregrex'; - const PROPERTIES_MIN = 'minProperties'; - const PROPERTIES_MAX = 'maxProperties'; - const TYPE = 'type'; - const UNIQUE_ITEMS = 'uniqueItems'; + public const ADDITIONAL_ITEMS = 'additionalItems'; + public const ADDITIONAL_PROPERTIES = 'additionalProp'; + public const ALL_OF = 'allOf'; + public const ANY_OF = 'anyOf'; + public const DEPENDENCIES = 'dependencies'; + public const DISALLOW = 'disallow'; + public const DIVISIBLE_BY = 'divisibleBy'; + public const ENUM = 'enum'; + public const CONSTANT = 'const'; + public const EXCLUSIVE_MINIMUM = 'exclusiveMinimum'; + public const EXCLUSIVE_MAXIMUM = 'exclusiveMaximum'; + public const FORMAT_COLOR = 'colorFormat'; + public const FORMAT_DATE = 'dateFormat'; + public const FORMAT_DATE_TIME = 'dateTimeFormat'; + public const FORMAT_DATE_UTC = 'dateUtcFormat'; + public const FORMAT_EMAIL = 'emailFormat'; + public const FORMAT_HOSTNAME = 'styleHostName'; + public const FORMAT_IP = 'ipFormat'; + public const FORMAT_PHONE = 'phoneFormat'; + public const FORMAT_REGEX= 'regexFormat'; + public const FORMAT_STYLE = 'styleFormat'; + public const FORMAT_TIME = 'timeFormat'; + public const FORMAT_URL = 'urlFormat'; + public const FORMAT_URL_REF = 'urlRefFormat'; + public const INVALID_SCHEMA = 'invalidSchema'; + public const LENGTH_MAX = 'maxLength'; + public const LENGTH_MIN = 'minLength'; + public const MAXIMUM = 'maximum'; + public const MIN_ITEMS = 'minItems'; + public const MINIMUM = 'minimum'; + public const MISSING_ERROR = 'missingError'; + public const MISSING_MAXIMUM = 'missingMaximum'; + public const MISSING_MINIMUM = 'missingMinimum'; + public const MAX_ITEMS = 'maxItems'; + public const MULTIPLE_OF = 'multipleOf'; + public const NOT = 'not'; + public const ONE_OF = 'oneOf'; + public const REQUIRED = 'required'; + public const REQUIRES = 'requires'; + public const PATTERN = 'pattern'; + public const PREGEX_INVALID = 'pregrex'; + public const PROPERTIES_MIN = 'minProperties'; + public const PROPERTIES_MAX = 'maxProperties'; + public const TYPE = 'type'; + public const UNIQUE_ITEMS = 'uniqueItems'; /** * @return string diff --git a/src/JsonSchema/Constraints/Constraint.php b/src/JsonSchema/Constraints/Constraint.php index 2390bf90..62da7a85 100644 --- a/src/JsonSchema/Constraints/Constraint.php +++ b/src/JsonSchema/Constraints/Constraint.php @@ -21,16 +21,16 @@ abstract class Constraint extends BaseConstraint implements ConstraintInterface { protected $inlineSchemaProperty = '$schema'; - const CHECK_MODE_NONE = 0x00000000; - const CHECK_MODE_NORMAL = 0x00000001; - const CHECK_MODE_TYPE_CAST = 0x00000002; - const CHECK_MODE_COERCE_TYPES = 0x00000004; - const CHECK_MODE_APPLY_DEFAULTS = 0x00000008; - const CHECK_MODE_EXCEPTIONS = 0x00000010; - const CHECK_MODE_DISABLE_FORMAT = 0x00000020; - const CHECK_MODE_EARLY_COERCE = 0x00000040; - const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080; - const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100; + public const CHECK_MODE_NONE = 0x00000000; + public const CHECK_MODE_NORMAL = 0x00000001; + public const CHECK_MODE_TYPE_CAST = 0x00000002; + public const CHECK_MODE_COERCE_TYPES = 0x00000004; + public const CHECK_MODE_APPLY_DEFAULTS = 0x00000008; + public const CHECK_MODE_EXCEPTIONS = 0x00000010; + public const CHECK_MODE_DISABLE_FORMAT = 0x00000020; + public const CHECK_MODE_EARLY_COERCE = 0x00000040; + public const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080; + public const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100; /** * Bubble down the path diff --git a/src/JsonSchema/Constraints/SchemaConstraint.php b/src/JsonSchema/Constraints/SchemaConstraint.php index b804e6b0..220a2dea 100644 --- a/src/JsonSchema/Constraints/SchemaConstraint.php +++ b/src/JsonSchema/Constraints/SchemaConstraint.php @@ -24,7 +24,7 @@ */ class SchemaConstraint extends Constraint { - const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#'; + private const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#'; /** * {@inheritdoc} diff --git a/src/JsonSchema/Rfc3339.php b/src/JsonSchema/Rfc3339.php index adca581a..e3226ec7 100644 --- a/src/JsonSchema/Rfc3339.php +++ b/src/JsonSchema/Rfc3339.php @@ -4,7 +4,7 @@ class Rfc3339 { - const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/'; + private const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/'; /** * Try creating a DateTime instance diff --git a/src/JsonSchema/SchemaStorage.php b/src/JsonSchema/SchemaStorage.php index 69b8b061..81691699 100644 --- a/src/JsonSchema/SchemaStorage.php +++ b/src/JsonSchema/SchemaStorage.php @@ -10,7 +10,7 @@ class SchemaStorage implements SchemaStorageInterface { - const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/'; + public const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/'; protected $uriRetriever; protected $uriResolver; diff --git a/src/JsonSchema/Validator.php b/src/JsonSchema/Validator.php index ac376f9d..97365d43 100644 --- a/src/JsonSchema/Validator.php +++ b/src/JsonSchema/Validator.php @@ -22,12 +22,12 @@ */ class Validator extends BaseConstraint { - const SCHEMA_MEDIA_TYPE = 'application/schema+json'; + public const SCHEMA_MEDIA_TYPE = 'application/schema+json'; - const ERROR_NONE = 0x00000000; - const ERROR_ALL = 0xFFFFFFFF; - const ERROR_DOCUMENT_VALIDATION = 0x00000001; - const ERROR_SCHEMA_VALIDATION = 0x00000002; + public const ERROR_NONE = 0x00000000; + public const ERROR_ALL = 0xFFFFFFFF; + public const ERROR_DOCUMENT_VALIDATION = 0x00000001; + public const ERROR_SCHEMA_VALIDATION = 0x00000002; /** * Validates the given data against the schema and returns an object containing the results