Skip to content

Commit 24e7cbf

Browse files
refactor: add visibility modifiers to class constants (#757)
* refactor: add visibility modifiers to class constants https://wiki.php.net/rfc/class_const_visibility * docs: add changelog entry
1 parent 73e3826 commit 24e7cbf

File tree

7 files changed

+64
-63
lines changed

7 files changed

+64
-63
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
- Replace traditional syntax array with short syntax array ([#747](https://github.com/jsonrainbow/json-schema/pull/747))
2424
- Increase phpstan level to 8 with baseline to swallow existing errors ([#673](https://github.com/jsonrainbow/json-schema/pull/673))
2525
- Add ext-json to composer.json to ensure JSON extension available ([#759](https://github.com/jsonrainbow/json-schema/pull/759))
26+
- Add visibility modifiers to class constants ([#757](https://github.com/jsonrainbow/json-schema/pull/757))
2627

2728
## [6.0.0] - 2024-07-30
2829
### Added

src/JsonSchema/ConstraintError.php

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,51 @@
66

77
class ConstraintError extends Enum
88
{
9-
const ADDITIONAL_ITEMS = 'additionalItems';
10-
const ADDITIONAL_PROPERTIES = 'additionalProp';
11-
const ALL_OF = 'allOf';
12-
const ANY_OF = 'anyOf';
13-
const DEPENDENCIES = 'dependencies';
14-
const DISALLOW = 'disallow';
15-
const DIVISIBLE_BY = 'divisibleBy';
16-
const ENUM = 'enum';
17-
const CONSTANT = 'const';
18-
const EXCLUSIVE_MINIMUM = 'exclusiveMinimum';
19-
const EXCLUSIVE_MAXIMUM = 'exclusiveMaximum';
20-
const FORMAT_COLOR = 'colorFormat';
21-
const FORMAT_DATE = 'dateFormat';
22-
const FORMAT_DATE_TIME = 'dateTimeFormat';
23-
const FORMAT_DATE_UTC = 'dateUtcFormat';
24-
const FORMAT_EMAIL = 'emailFormat';
25-
const FORMAT_HOSTNAME = 'styleHostName';
26-
const FORMAT_IP = 'ipFormat';
27-
const FORMAT_PHONE = 'phoneFormat';
28-
const FORMAT_REGEX= 'regexFormat';
29-
const FORMAT_STYLE = 'styleFormat';
30-
const FORMAT_TIME = 'timeFormat';
31-
const FORMAT_URL = 'urlFormat';
32-
const FORMAT_URL_REF = 'urlRefFormat';
33-
const INVALID_SCHEMA = 'invalidSchema';
34-
const LENGTH_MAX = 'maxLength';
35-
const LENGTH_MIN = 'minLength';
36-
const MAXIMUM = 'maximum';
37-
const MIN_ITEMS = 'minItems';
38-
const MINIMUM = 'minimum';
39-
const MISSING_ERROR = 'missingError';
40-
const MISSING_MAXIMUM = 'missingMaximum';
41-
const MISSING_MINIMUM = 'missingMinimum';
42-
const MAX_ITEMS = 'maxItems';
43-
const MULTIPLE_OF = 'multipleOf';
44-
const NOT = 'not';
45-
const ONE_OF = 'oneOf';
46-
const REQUIRED = 'required';
47-
const REQUIRES = 'requires';
48-
const PATTERN = 'pattern';
49-
const PREGEX_INVALID = 'pregrex';
50-
const PROPERTIES_MIN = 'minProperties';
51-
const PROPERTIES_MAX = 'maxProperties';
52-
const TYPE = 'type';
53-
const UNIQUE_ITEMS = 'uniqueItems';
9+
public const ADDITIONAL_ITEMS = 'additionalItems';
10+
public const ADDITIONAL_PROPERTIES = 'additionalProp';
11+
public const ALL_OF = 'allOf';
12+
public const ANY_OF = 'anyOf';
13+
public const DEPENDENCIES = 'dependencies';
14+
public const DISALLOW = 'disallow';
15+
public const DIVISIBLE_BY = 'divisibleBy';
16+
public const ENUM = 'enum';
17+
public const CONSTANT = 'const';
18+
public const EXCLUSIVE_MINIMUM = 'exclusiveMinimum';
19+
public const EXCLUSIVE_MAXIMUM = 'exclusiveMaximum';
20+
public const FORMAT_COLOR = 'colorFormat';
21+
public const FORMAT_DATE = 'dateFormat';
22+
public const FORMAT_DATE_TIME = 'dateTimeFormat';
23+
public const FORMAT_DATE_UTC = 'dateUtcFormat';
24+
public const FORMAT_EMAIL = 'emailFormat';
25+
public const FORMAT_HOSTNAME = 'styleHostName';
26+
public const FORMAT_IP = 'ipFormat';
27+
public const FORMAT_PHONE = 'phoneFormat';
28+
public const FORMAT_REGEX= 'regexFormat';
29+
public const FORMAT_STYLE = 'styleFormat';
30+
public const FORMAT_TIME = 'timeFormat';
31+
public const FORMAT_URL = 'urlFormat';
32+
public const FORMAT_URL_REF = 'urlRefFormat';
33+
public const INVALID_SCHEMA = 'invalidSchema';
34+
public const LENGTH_MAX = 'maxLength';
35+
public const LENGTH_MIN = 'minLength';
36+
public const MAXIMUM = 'maximum';
37+
public const MIN_ITEMS = 'minItems';
38+
public const MINIMUM = 'minimum';
39+
public const MISSING_ERROR = 'missingError';
40+
public const MISSING_MAXIMUM = 'missingMaximum';
41+
public const MISSING_MINIMUM = 'missingMinimum';
42+
public const MAX_ITEMS = 'maxItems';
43+
public const MULTIPLE_OF = 'multipleOf';
44+
public const NOT = 'not';
45+
public const ONE_OF = 'oneOf';
46+
public const REQUIRED = 'required';
47+
public const REQUIRES = 'requires';
48+
public const PATTERN = 'pattern';
49+
public const PREGEX_INVALID = 'pregrex';
50+
public const PROPERTIES_MIN = 'minProperties';
51+
public const PROPERTIES_MAX = 'maxProperties';
52+
public const TYPE = 'type';
53+
public const UNIQUE_ITEMS = 'uniqueItems';
5454

5555
/**
5656
* @return string

src/JsonSchema/Constraints/Constraint.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ abstract class Constraint extends BaseConstraint implements ConstraintInterface
2121
{
2222
protected $inlineSchemaProperty = '$schema';
2323

24-
const CHECK_MODE_NONE = 0x00000000;
25-
const CHECK_MODE_NORMAL = 0x00000001;
26-
const CHECK_MODE_TYPE_CAST = 0x00000002;
27-
const CHECK_MODE_COERCE_TYPES = 0x00000004;
28-
const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
29-
const CHECK_MODE_EXCEPTIONS = 0x00000010;
30-
const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
31-
const CHECK_MODE_EARLY_COERCE = 0x00000040;
32-
const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
33-
const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
24+
public const CHECK_MODE_NONE = 0x00000000;
25+
public const CHECK_MODE_NORMAL = 0x00000001;
26+
public const CHECK_MODE_TYPE_CAST = 0x00000002;
27+
public const CHECK_MODE_COERCE_TYPES = 0x00000004;
28+
public const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
29+
public const CHECK_MODE_EXCEPTIONS = 0x00000010;
30+
public const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
31+
public const CHECK_MODE_EARLY_COERCE = 0x00000040;
32+
public const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
33+
public const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
3434

3535
/**
3636
* Bubble down the path

src/JsonSchema/Constraints/SchemaConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
class SchemaConstraint extends Constraint
2626
{
27-
const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
27+
private const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
2828

2929
/**
3030
* {@inheritdoc}

src/JsonSchema/Rfc3339.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class Rfc3339
66
{
7-
const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
7+
private const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
88

99
/**
1010
* Try creating a DateTime instance

src/JsonSchema/SchemaStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class SchemaStorage implements SchemaStorageInterface
1212
{
13-
const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
13+
public const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
1414

1515
protected $uriRetriever;
1616
protected $uriResolver;

src/JsonSchema/Validator.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
*/
2323
class Validator extends BaseConstraint
2424
{
25-
const SCHEMA_MEDIA_TYPE = 'application/schema+json';
25+
public const SCHEMA_MEDIA_TYPE = 'application/schema+json';
2626

27-
const ERROR_NONE = 0x00000000;
28-
const ERROR_ALL = 0xFFFFFFFF;
29-
const ERROR_DOCUMENT_VALIDATION = 0x00000001;
30-
const ERROR_SCHEMA_VALIDATION = 0x00000002;
27+
public const ERROR_NONE = 0x00000000;
28+
public const ERROR_ALL = 0xFFFFFFFF;
29+
public const ERROR_DOCUMENT_VALIDATION = 0x00000001;
30+
public const ERROR_SCHEMA_VALIDATION = 0x00000002;
3131

3232
/**
3333
* Validates the given data against the schema and returns an object containing the results

0 commit comments

Comments
 (0)