Skip to content

Commit

Permalink
refactor: add visibility modifiers to class constants (#757)
Browse files Browse the repository at this point in the history
* refactor: add visibility modifiers to class constants

https://wiki.php.net/rfc/class_const_visibility

* docs: add changelog entry
  • Loading branch information
DannyvdSluijs authored Oct 21, 2024
1 parent 73e3826 commit 24e7cbf
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 63 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
90 changes: 45 additions & 45 deletions src/JsonSchema/ConstraintError.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions src/JsonSchema/Constraints/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/JsonSchema/Constraints/SchemaConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion src/JsonSchema/Rfc3339.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/JsonSchema/SchemaStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/JsonSchema/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 24e7cbf

Please sign in to comment.