You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: update BaseConstraint.php to PHP 7.2 language level (#826)
This pull request refactors the `BaseConstraint` class in the
`JsonSchema` package to improve code readability, enforce immutability,
and align with modern PHP practices. The changes include replacing
anonymous functions with static closures, updating type casting, and
removing outdated comments.
### Code modernization and immutability:
* Replaced anonymous functions with `static` closures in methods like
`addError`, `addErrors`, and `convertJsonPointerIntoPropertyPath` to
enforce immutability and improve performance.
[[1]](diffhunk://#diff-05cd63f6b003f185a215e10402525e33d94466ec4d83a685c5a6ccd1befcf921L53-R48)
[[2]](diffhunk://#diff-05cd63f6b003f185a215e10402525e33d94466ec4d83a685c5a6ccd1befcf921L81-R75)
[[3]](diffhunk://#diff-05cd63f6b003f185a215e10402525e33d94466ec4d83a685c5a6ccd1befcf921L167-R162)
* Updated type casting for better readability and adherence to modern
PHP conventions, e.g., `(string)` instead of `strval`.
### Code readability and cleanup:
* Removed outdated docblock comments and unnecessary annotations, such
as the `@return` tag in `convertJsonPointerIntoPropertyPath`.
* Replaced `\JSON_ERROR_NONE` with the `JSON_ERROR_NONE` constant for
consistency with the `use` statement.
### Other improvements:
* Adjusted the `json_decode` call to explicitly set the `associative`
parameter to `false` for clarity.
0 commit comments