This pull request includes several changes to the `JsonSchema` library,
focusing on adding type hints and improving code documentation. The most
important changes include removing certain entries from
`phpstan-baseline.neon`, adding type hints to methods in
`Validator.php`, and updating deprecation notices.
Improvements to type hints and code documentation:
*
[`src/JsonSchema/Validator.php`](diffhunk://#diff-41de454e04e08a0284513e682c94d3f01f9c4a2a6b2faa51b5868bdd0826e42eL44-R48):
Added type hints to the `validate`, `check`, and `coerce` methods,
specifying the return type as `int` and including detailed parameter
documentation.
[[1]](diffhunk://#diff-41de454e04e08a0284513e682c94d3f01f9c4a2a6b2faa51b5868bdd0826e42eL44-R48)
[[2]](diffhunk://#diff-41de454e04e08a0284513e682c94d3f01f9c4a2a6b2faa51b5868bdd0826e42eL85-R104)
Updates to `phpstan-baseline.neon`:
*
[`phpstan-baseline.neon`](diffhunk://#diff-995edee38ad4f8387e58ebd52c31bcc04c56cc2448d331b1cf5e0b35c57b9efaL903-L932):
Removed multiple entries related to the `JsonSchema\Validator` class,
which were previously indicating missing type hints. These entries are
no longer needed due to the added type hints in the code.
This pull request includes changes to the `.github/workflows/lint.yml`
file to improve the linting process for the project. The most important
changes include renaming the job from "tests" to "lint", updating the
PHP setup configuration, and modifying the linting command.
Improvements to linting workflow:
*
[`.github/workflows/lint.yml`](diffhunk://#diff-107e910e9f2ebfb9a741fa10b2aa7100cc1fc4f5f3aca2dfe78b905cbd73c0d2L12-R12):
Renamed the job from "tests" to "lint" to better reflect its purpose.
*
[`.github/workflows/lint.yml`](diffhunk://#diff-107e910e9f2ebfb9a741fa10b2aa7100cc1fc4f5f3aca2dfe78b905cbd73c0d2L30-R38):
Updated the PHP setup configuration to include `parallel-lint` and
`cs2pr` tools, and reordered the `php-version` and `coverage` parameters
for clarity.
*
[`.github/workflows/lint.yml`](diffhunk://#diff-107e910e9f2ebfb9a741fa10b2aa7100cc1fc4f5f3aca2dfe78b905cbd73c0d2L30-R38):
Modified the linting command to use `parallel-lint` with `cs2pr` for
better parallel processing and reporting.
This pull request makes changes to the GitHub Actions workflow
configuration for running PHPStan, a PHP static analysis tool. The most
important changes include renaming the job, adding a matrix strategy for
different PHP versions, and updating the PHP installation step.
Improvements to the GitHub Actions workflow:
*
[`.github/workflows/phpstan.yml`](diffhunk://#diff-73a1d6ddd0eabb7e1349cdb83b76ff10f29f9e4fe316c0cd29495174181f4546L15-R36):
Renamed the job from `tests` to `phpstan` to better reflect its purpose.
*
[`.github/workflows/phpstan.yml`](diffhunk://#diff-73a1d6ddd0eabb7e1349cdb83b76ff10f29f9e4fe316c0cd29495174181f4546L15-R36):
Added a matrix strategy to run PHPStan on multiple PHP versions (7.2 and
8.4).
*
[`.github/workflows/phpstan.yml`](diffhunk://#diff-73a1d6ddd0eabb7e1349cdb83b76ff10f29f9e4fe316c0cd29495174181f4546L15-R36):
Updated the PHP installation step to use the matrix's PHP version
instead of a hardcoded version.
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>