Laravel 13 compatibility + PHP 8.2 modernization#57
Open
navneetkumar-pim-webkul wants to merge 17 commits into
Open
Laravel 13 compatibility + PHP 8.2 modernization#57navneetkumar-pim-webkul wants to merge 17 commits into
navneetkumar-pim-webkul wants to merge 17 commits into
Conversation
- Add declare(strict_types=1) to all source files - Add typed parameters, return types, and property types - Use constructor property promotion (LaravelValidator, ValidatorException) - Make ValidatorException::$messageBag readonly - Switch ValidatorException to Illuminate\Contracts\Support\MessageBag for wider type compatibility - Initialize $errors as empty MessageBag in AbstractValidator constructor (fixes latent fatal when errors() called before passes()) - Remove redundant PHPDoc blocks superseded by type declarations - Refactor parserValidationRules() with foreach instead of array_walk by-reference Breaking: ValidatorInterface signatures now typed. Consumers implementing the interface or extending AbstractValidator must update method signatures.
- Assert errors() returns [] on fresh instance (regression for latent bug) - Assert errors() returns [] after successful validation - Cover ValidatorException::getMessageBag(), toArray(), toJson()
ValidatorException previously did not call parent::__construct(), so $e->getMessage() returned an empty string. Restore that behavior to avoid silently changing what API consumers display via getMessage().
Covers pipe-separated rule strings and non-unique rules left untouched by setId() / parserValidationRules().
- Throw on json_encode failure in ValidatorException::toJson instead of silently returning an empty string, so invalid JSON surfaces as an error rather than a malformed payload. - Fix stale README install snippet that referenced the wrong package name and outdated version constraint.
…ibility # Conflicts: # composer.json
Author
|
Hi @andersao — friendly nudge on this PR. Beyond the dependency bumps in
Branch rebased clean against current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Laravel 13 compatibility, modernizes source for PHP 8.2+, adds a real test suite (none existed before), and replaces the dead Travis config with a GitHub Actions matrix.
This is a broader-scope alternative to #55 (which is the minimal Shift bump). Maintainer can pick whichever fits the project direction.
Dependencies
^8.2illuminate/support+illuminate/validation→^11.0|^12.0|^13.0require-devaddsphpunit/phpunit ^11|^12andorchestra/testbench ^9|^10|^11Source modernization
declare(strict_types=1);in all source filesLaravelValidatorandValidatorExceptionreadonly$messageBaginValidatorExceptionparserValidationRules()refactored from by-referencearray_walktoforeachLatent bug fix
AbstractValidator::__construct()now initializes$errors = new MessageBag(). Previously, callingerrors()before a failedpasses()producedError: Call to a member function all() on array. New regression test guards this.Tests
11 Pest-style PHPUnit tests booting a real Laravel container via Orchestra Testbench. Covers
passes,passesOrFail, action-scoped rules,setIdunique-rule rewriter (including pipe-string and non-unique edge cases), custom messages/attributes, fresh-instanceerrors(), and theValidatorExceptionpayload.CI
.github/workflows/tests.ymlreplaces.travis.yml. Matrix:Breaking changes (documented in README)
ValidatorInterfaceandAbstractValidatorsignatures are now typed — subclasses must update.ValidatorException::getMessageBag()now returnsIlluminate\Contracts\Support\MessageBag(contract) instead of the concrete class.AbstractValidatorsubclasses overriding__construct()must callparent::__construct()so$errorsis initialized.Test plan
vendor/bin/phpunit— 11 tests, 19 assertions, green on Laravel 13.11.2 / PHP 8.3.30 locallycomposer validate— valid-lsyntax check — clean on all 6 PHP files