690 Commits

Author SHA1 Message Date
Danny van der Sluijs
0f69f0e72c
Fix objects are non unique despite key order (#819)
As pointed out by the [bowtie
report](https://bowtie.report/#/dialects/draft4?language=php) there
where some issues when validating the uniqueness of values espec. when
the order of the keys was different.
2025-04-11 15:32:43 +02:00
Danny van der Sluijs
35d262c949 docs: prepare 6.4.1 release 6.4.1 2025-04-04 15:08:07 +02:00
Nicolas Grekas
074a821fcf
Fix support for 32bits PHP (#817)
Fix https://github.com/jsonrainbow/json-schema/issues/816

---------

Co-authored-by: Jordi Boggiano <j.boggiano@seld.be>
Co-authored-by: Danny van der Sluijs <danny.van.der.sluijs@infi.nl>
2025-04-04 15:07:17 +02:00
Danny van der Sluijs
16b274cb46 docs: prepare release 6.4.0 6.4.0 2025-04-01 20:50:59 +02:00
Danny van der Sluijs
20114118c4
ci: prepare PHP 8.5 in CI (#815)
Related to #798
2025-04-01 20:31:19 +02:00
Danny van der Sluijs
5168e8178e
ci: Add cs2pr handling for php-cs-fixer; avoid doing composer install (#814)
This PR uses the tools available from the [setup-php
](https://github.com/marketplace/actions/setup-php-action) action to
improve the feedback to better readable for humans using
[cs2pr](https://github.com/staabm/annotate-pull-request-from-checkstyle)
and avoids running `composer install` during the flow.
2025-04-01 09:05:30 +02:00
Danny van der Sluijs
528b39f4f3
fix: Array with number values with mathematical equality are considered valid (#813)
Our Bowtie
[report](https://bowtie.report/#/dialects/draft4?language=php) pointed
out we are not correctly validating an enum type with an array holding a
number type
2025-03-31 22:33:44 +02:00
Danny van der Sluijs
76ba104c5c Correct PHPStan findings in validator (#808)
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.
2025-03-25 19:55:43 +01:00
Danny van der Sluijs
f769861f5d
Use parallel-lint and cs2pr for improved feedback on linting errors (#812)
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.
2025-03-25 13:42:55 +01:00
Danny van der Sluijs
e199ea24c7
Run PHPStan using the lowest and highest php version (#811)
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.
2025-03-25 13:20:34 +01:00
Danny van der Sluijs
c9f00dec76 docs: prepare release 6.3.1 6.3.1 2025-03-18 20:03:56 +01:00
Nicos Panayides
cba7697e87
Fix null comparison (#807)
Fixes null not equal to null.

Issue: https://github.com/jsonrainbow/json-schema/issues/806
2025-03-18 18:57:34 +01:00
Danny van der Sluijs
e9ac599ff9
fix: ensure numeric issues in const are correctly evaluated (#805)
Fixes https://github.com/jsonrainbow/json-schema/issues/778
2025-03-14 13:26:17 +01:00
Danny van der Sluijs
fbb4049557 docs: 6.3.0 release 6.3.0 2025-03-14 12:57:01 +01:00
Danny van der Sluijs
191bd4eb1a
ci: Reduce duplicate workflow runs (#804) 2025-03-14 12:55:55 +01:00
Danny van der Sluijs
cd30df36e0
refactor: replace icecave/parity with custom deep comparator (#803)
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
2025-03-14 12:52:27 +01:00
Danny van der Sluijs
848c9ee9b3 fix: replace filter_var for uri and uri-reference to userland code to be RFC 3986 compliant (#800)
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
2025-03-14 12:46:35 +01:00
Danny van der Sluijs
a8c008885d
fix: only check minProperties or maxProperties on objects (#802)
`minProperties` and `maxProperties` are only applicable on objects.

https://www.learnjsonschema.com/draft4/validation/minproperties/ 

https://json-schema.org/draft-04/draft-fge-json-schema-validation-00#rfc.section.5.4.2
2025-03-07 14:35:34 +01:00
Danny van der Sluijs
dff04e3c7c docs: release 6.2.1 6.2.1 2025-03-06 22:27:10 +01:00
Danny van der Sluijs
949a4d5c89
fix: allow items: true to pass validation (#801)
Fixes #799
2025-03-06 22:25:30 +01:00
Danny van der Sluijs
bb68276a3b
feat: include actual count in collection constraint errors (#797)
Includes the actual count in min/maxItems.

Fixes https://github.com/jsonrainbow/json-schema/issues/501
2025-02-27 12:06:44 +01:00
Danny van der Sluijs
460c0a0940 docs: release 6.2.0 6.2.0 2025-02-26 21:58:15 +01:00
Danny van der Sluijs
d9d665f276
refactor: cleanup redundant checks (#796)
Fixes #793 removing PHP 5.5 and HHVM checks
2025-02-26 21:36:44 +01:00
Aistis
b62fea73bd
fix: property is passed as integer and cannot be accessed (#784) 2025-02-26 20:15:26 +01:00
Danny van der Sluijs
a94f60c332
fix: create deep copy before checking each sub schema in oneOf when only check_mode_apply_defaults is set (#795)
Fixes https://github.com/jsonrainbow/json-schema/issues/510
2025-02-26 19:41:16 +01:00
Danny van der Sluijs
649793d2b9
Correctly set the schema ID when passing it as assoc array (#794)
Replaces #769 due to lack of permissions to update PR
Closes https://github.com/jsonrainbow/json-schema/issues/767.

---------

Co-authored-by: Dalibor Karlović <dalibor.karlovic@sigwin.hr>
2025-02-26 16:47:32 +01:00
Danny van der Sluijs
44066980b7
fix: Create deep copy before checking each sub schema in anyOf (#792)
Fixes https://github.com/jsonrainbow/json-schema/issues/711
2025-02-26 15:40:07 +01:00
Danny van der Sluijs
7eea9e4f11
fix: Create deep copy before checking each sub schema in oneOf (#791)
This PR creates a deep copy of the value before passing it by reference
for validating sub schemas of a `oneOf` with type coercion enabled.

Fixes #790
2025-02-26 12:11:20 +01:00
Danny van der Sluijs
ec0eab03f2
fix: Upgrade php cs fixer to latest (#783)
Fixes #598
2025-02-21 10:50:06 +01:00
Danny van der Sluijs
f84193ea05
fix: add required permissions for welcome action (#789)
This PR adds the required permissions for making comments on the issues
and pull requests

References:
-
https://github.com/jsonrainbow/json-schema/actions/runs/13372875791/job/37345272696#step:2:1
-
https://github.com/wow-actions/welcome/issues/9#issuecomment-2663235613
2025-02-21 10:31:03 +01:00
Danny van der Sluijs
7660882388
feat: welcome first time contributors (#782)
* feat: welcome first time contributers

* docs: add changelog entry
2025-02-10 21:58:50 +01:00
Jack Worman
afee666c00
More-phpstan-typing (#781) 2025-02-10 20:58:59 +01:00
Jack Worman
56f34b8ced
Use phpstan's int-mask-of<T> (#779)
* Better phpstan typing

* Better phpstan typing
2025-02-06 08:10:30 +01:00
Danny van der Sluijs
f7d78c345d docs: Release 6.1.0 6.1.0 2025-02-04 12:13:26 +01:00
Danny van der Sluijs
97e7e4d772
docs: add contribution and contributor information (#771)
* docs: add contribution and contributor information

* docs: add changelog entry
2025-01-28 11:39:45 +01:00
Dieter Beck
caa0c6c9c8
fix: Succeed format validation if the type is not in the set of given instance types (#773) (#773)
See https://json-schema.org/draft-04/draft-fge-json-schema-validation-00#rfc.section.7.1: If the type of the instance to validate is not in this set, validation for this format attribute and instance SHOULD succeed.
2025-01-28 11:35:36 +01:00
Dieter Beck
d212ecacc2
Remove obsolete check if FILTER_FLAG_EMAIL_UNICODE is defined (#772)
* Remove obsolete check because PHP 7.1 or lower is not supported anymore

* Refresh phpstan baseline

* Add changelog
2025-01-20 21:33:40 +01:00
Danny van der Sluijs
14e41d82de
refactor: Cleanup test from @param annotations (#768)
* refactor: Cleanup test from @param annotations

* docs: add changelog entry
2025-01-10 11:16:00 +01:00
Danny van der Sluijs
377231495a
Raise minimum level php enum (#766)
* build: raise minimum level of marc-mabe/php-enum

* docs: add changelog entry
2024-11-21 22:19:10 +01:00
Danny van der Sluijs
b5c8c9ee12
refactor: add declare strict_types to all classes in ./src (#758)
* refactor: add declare strict_types to all classes in ./src

* fix: correct regression from adding declare strict_types

* refactor: enforce string at datetime casting

* docs: add changelog entry
2024-11-21 22:10:43 +01:00
Danny van der Sluijs
63d6369385
build: include php 8.4 in workflow (#765) 2024-11-21 22:01:07 +01:00
Tac Tacelosky
3fe73adcee
tweak spacing (#763)
* 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>
2024-11-21 21:57:07 +01:00
Danny van der Sluijs
ba2d3c7700
fix: correct phpstan baseline (#764) 2024-11-21 21:46:33 +01:00
Danny van der Sluijs
24e7cbf8c5
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
2024-10-21 11:37:15 +02:00
Ali Yousefi
73e38269ed
Update: add ext-json to composer.json to ensure JSON extension availa… (#759)
* 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>
2024-10-21 11:13:21 +02:00
Witold Wasiczko
f0b02264a3
Invalid string validation (#704)
* 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>
2024-09-20 13:40:40 +02:00
Niklas Correnz
eac0893905
Fix wrong combined paths when traversing upwards. Fixes #557 (#652)
* Fix wrong combined paths when traversing upwards. Fixes #557

* docs: add changelog entry

---------

Co-authored-by: Danny van der Sluijs <danny.van.der.sluijs@infi.nl>
2024-09-20 13:29:14 +02:00
Danny van der Sluijs
60488b2317
Resolve deprecations: Optional parameter $... declared before required parameter $... (#752)
* fix: remove default value to resolve deprecations notice

* docs: add changelog entry
2024-09-13 15:28:30 +02:00
Jordi Boggiano
5b3bd2b1b6
Increase phpstan level to 8 with baseline to swallow existing errors (#673)
* 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>
2024-09-13 15:20:41 +02:00
Danny van der Sluijs
23c8551197
Add return types to test suite (#748)
* refactor: Add return types in the test suite

* docs: Add changelog entry
2024-08-30 15:09:12 +02:00