After considering the options and rethinking the problem we are trying
to solve I came top the conclusion we don't need a external library
which can handle PHP class equality. Since we are working with JSON we
only have scalar types (boolean, float, integer and string) and two
collections types array and `stdClass`.
This made it simple to write our own deep comparison.
Fixes https://github.com/jsonrainbow/json-schema/issues/753
This pull request introduces new validators for URI and relative
references and integrates them into the `FormatConstraint` class. The
changes also include corresponding unit tests to ensure the validators
work as expected.
### New Validators:
*
[`src/JsonSchema/Tool/Validator/UriValidator.php`](diffhunk://#diff-2019f410f3ef4cdf8478ffa71444226beb8a118d60b3337c40eaaec8d3aef7a3R1-R65):
Added a new class `UriValidator` to validate URIs according to RFC 3986
and RFC 5322 for `mailto:` URIs.
*
[`src/JsonSchema/Tool/Validator/RelativeReferenceValidator.php`](diffhunk://#diff-0bfeeb9c38593a2d65cc2e8c49fe873c78765eac81c00cf0a398bd754ca9c7a8R1-R53):
Added a new class `RelativeReferenceValidator` to validate relative
references according to RFC 3986.
### Integration into `FormatConstraint`:
*
[`src/JsonSchema/Constraints/FormatConstraint.php`](diffhunk://#diff-44020f0c0690a2a4c1c446e97185986c31b19374b4a99f4b0970c5df36279067L104-R114):
Integrated the new `UriValidator` and `RelativeReferenceValidator` into
the `check` method to replace the previous inline validation logic for
`uri` and `uri-reference` formats.
### Unit Tests:
*
[`tests/Tool/Validator/UriValidatorTest.php`](diffhunk://#diff-6b107cb8679795fb59c070ba500d0646f6d357e4c03a585f4a0c67181e4101fcR1-R49):
Added unit tests for `UriValidator` to ensure it correctly validates
valid and invalid URIs.
*
[`tests/Tool/Validator/RelativeReferenceValidatorTest.php`](diffhunk://#diff-97a7acc2a16f7653d307a16e356c7545b0a0bc26156ce60f7ca13332a6656729R1-R40):
Added unit tests for `RelativeReferenceValidator` to ensure it correctly
validates valid and invalid relative references.
# Closing keywords
fixes https://github.com/jsonrainbow/json-schema/issues/685
* tweak spacing
tweak spacing so array keys are indented the same.
* docs: add changelog entry
---------
Co-authored-by: Danny van der Sluijs <danny.vandersluijs@icloud.com>
* Update: add ext-json to composer.json to ensure JSON extension availability
* docs: add changelog entry
---------
Co-authored-by: Danny van der Sluijs <danny.van.der.sluijs@infi.nl>
* Add test case for invalid string type validation
* docs: add changelog entry
---------
Co-authored-by: Danny van der Sluijs <danny.van.der.sluijs@infi.nl>
* Increase phpstan level to 8 with baseline to swallow existing errors
* Add phpstan to composer.json
* docs: a changelog entry
---------
Co-authored-by: Danny van der Sluijs <danny.van.der.sluijs@infi.nl>
* ci: Add PHP 8.0 and greater to build matrix
* ci: Remove PHP 5.3 - 7.1 from workflows
* build: Require minimum PHP 7.2
* build: Upgrade to PHPUnit 8.5
* refactor: Add now required void return types for setup() methods
* build: Include phpspec/prophecy dependency
* refactor: Replace setExpectedException with expectException/expectExceptionMessage
* refactor: Replace @expectedException annotation for expectException method
* refactor: Replace assertInternalType for assertIsArray
* refactor: Replace getMock for createMock
* test: Improve test assertions
* fix: Solve return type issues with Objectiterator (port of #682)
See https://github.com/jsonrainbow/json-schema/pull/682
* build: Update icecave/parity to ^3.0 as 1.0 uses deprecated each() method
* style: Correct code style issues
* fix: Fix deprecation notices found from GHA workflow run
See https://github.com/jsonrainbow/json-schema/actions/runs/10216569969/job/28268331091
* fix: Add fallback to empty string when null value is passed in UriResolver::parse
* fix: Port #717: Fixes for implicit nullability deprecation
See https://github.com/jsonrainbow/json-schema/pull/717
* ci: Avoid GHA run on each push and pull request; Include PHP 8.4 in matrix
* ci(Drop-PHP-8.4-from-matrix): This PR adds phpspec/prophecy as an explicit dependency which is restrictive and doesnt support upcoming PHP versions
* refactor: Replace ternary variable with explicit cast to string
* test: Correct misconfigured mocks
* test: Refactor to use willReturn() method
* test: Make use of already imported classname
* test: Ignore return value when exception is expected to be thrown
* test: Mock complete interface
* docs: Add changelog entry