Skip to content

Fix support for 32bits PHP #817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Fix support for 32bits PHP ([#817](https://github.com/jsonrainbow/json-schema/pull/817))

## [6.4.0] - 2025-04-01
### Added
Expand Down
5 changes: 5 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ parameters:
count: 1
path: src/JsonSchema/Constraints/BaseConstraint.php

-
message: "#^Property JsonSchema\\\\Constraints\\\\BaseConstraint\\:\\:\\$errorMask \\(int\\<\\-1, 3\\>\\) does not accept int\\.$#"
count: 1
path: src/JsonSchema/Constraints/BaseConstraint.php

-
message: "#^Property JsonSchema\\\\Constraints\\\\BaseConstraint\\:\\:\\$errors type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down
8 changes: 4 additions & 4 deletions src/JsonSchema/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class Validator extends BaseConstraint
{
public const SCHEMA_MEDIA_TYPE = 'application/schema+json';

public const ERROR_NONE = 0x00000000;
public const ERROR_ALL = 0xFFFFFFFF;
public const ERROR_DOCUMENT_VALIDATION = 0x00000001;
public const ERROR_SCHEMA_VALIDATION = 0x00000002;
public const ERROR_NONE = 0;
public const ERROR_ALL = -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self::ERROR_DOCUMENT_VALIDATION | self::ERROR_SCHEMA_VALIDATION also should work here no? Or just hardcode 3 because frankly this is very unlikely to change, so if a new type is added with 4 then you just gotta update the ERROR_ALL.. Doesn't sound that hard 🤷🏻

Suggested change
public const ERROR_ALL = -1;
public const ERROR_ALL = self::ERROR_DOCUMENT_VALIDATION | self::ERROR_SCHEMA_VALIDATION;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes more sense to me to use -1 for an E_ALL level. Like error_reporting(-1) is a common way to turn on all error levels for the engine...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, works for me with -1 too.. Not sure why PHPStan complains though, but I tried on my machine and wasn't able to quiet it down. Seems like the 0xFFFFFFFF makes it give up on some checks.

Copy link
Contributor

@staabm staabm Apr 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Phpstan complains because it doesn’t support int-ranges from binary & and | operator yet.

see phpstan/phpstan#7912

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks, i thought i saw this work but must remember it wrong then :)

public const ERROR_DOCUMENT_VALIDATION = 1;
public const ERROR_SCHEMA_VALIDATION = 2;

/**
* Validates the given data against the schema and returns an object containing the results
Expand Down
Loading