Skip to content

Commit 73552ea

Browse files
committed
Rewrite bundle for PHP 8.5, Symfony 8, and Respect/Validation 3
This is a hard reset. The bundle had been untouched for over a decade — it still targeted PHP 5.3, Symfony 2.6, and Respect/Validation 0.9, none of which are supportable today. Rather than incrementally migrate through a chain of dead intermediate versions, the entire surface is rewritten against the current stack. Validation 3.0 makes this much easier than it used to be. The library now exposes a proper `ValidatorBuilder` as the entry point, an explicit `ValidatorFactory` interface, and a `ContainerRegistry` that accepts any PSR-11 container. That last piece is what unlocks a clean Symfony integration: every service Validation needs is registered directly in Symfony's container, and `RespectValidationBundle::boot()` calls `ContainerRegistry::setContainer($this->container)` so Validation's static API (`v::xxx()`, `ValidatorBuilder::init()`) also resolves through Symfony. There is no second PHP-DI container at runtime — users get a single container they can override services on, and `ValidatorBuilder` / `ValidatorFactory` are autowireable like any other service. The bundle exposes a `rule_namespaces` config so applications can plug in their own rule classes without touching internals; user namespaces are checked before the built-in `Respect\\Validation\\Validators` so custom rules can shadow defaults. The old `Assert` / `AssertValidator` constraint pair (and its tie to `symfony/validator` annotations) is dropped — the new fluent builder API does not map cleanly onto a single annotation, and the legacy integration was already broken against modern Symfony. Reintroducing it can happen later if there is real demand. Dev tooling is brought in line with the Validation library: PHPUnit 12.5, PHPStan 2 at level 8, PHP_CodeSniffer 4 with the Respect coding standard, and a GitHub Actions workflow replacing the unmaintained Travis config. Project layout moves to the modern `src/` + `tests/` + `config/` split with PSR-4 autoloading.
1 parent 8e32b52 commit 73552ea

37 files changed

Lines changed: 968 additions & 321 deletions

.github/CODE_OF_CONDUCT.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--
2+
SPDX-FileCopyrightText: (c) Respect Project Contributors
3+
SPDX-License-Identifier: MIT
4+
-->
5+
6+
# Code of Conduct
7+
8+
## Our Pledge
9+
10+
We pledge to make participation in our project a harassment-free experience for everyone.
11+
12+
## Our Standards
13+
14+
- Be respectful
15+
- Be collaborative
16+
- Be inclusive
17+
18+
## Enforcement
19+
20+
Contact the maintainers if you experience or witness unacceptable behavior.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
name: Bug Report
3+
about: Report a bug
4+
labels: bug
5+
---
6+
7+
**Describe the bug**
8+
A clear description of the bug.
9+
10+
**To Reproduce**
11+
Steps to reproduce.
12+
13+
**Expected behavior**
14+
What should happen.
15+
16+
**Environment**
17+
- OS:
18+
- PHP Version:
19+
- Symfony Version:
20+
- Respect\ValidationBundle version:
21+
- Respect\Validation version:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: Feature Request
3+
about: Suggest a new feature
4+
labels: enhancement
5+
---
6+
7+
**Is your feature request related to a problem?**
8+
Describe the problem.
9+
10+
**Describe the solution**
11+
What do you want to happen.
12+
13+
**Alternatives**
14+
Any alternatives considered.

.github/PULL_REQUEST_TEMPLATE.md

Whitespace-only changes.

.github/SECURITY.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!--
2+
SPDX-FileCopyrightText: (c) Respect Project Contributors
3+
SPDX-License-Identifier: MIT
4+
-->
5+
6+
# Security Policy
7+
8+
## Reporting Vulnerabilities
9+
10+
Report security issues using:
11+
12+
https://github.com/Respect/ValidationBundle/security/advisories/new
13+
14+
We will work to make them public in a timely fashion and properly credit
15+
whoever discovered it.
16+
17+
## Supported Versions
18+
19+
Only the latest version receives security updates.

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 2
2+
updates:
3+
4+
# Maintain dependencies for GitHub Actions
5+
- package-ecosystem: "github-actions"
6+
directory: "/"
7+
schedule:
8+
interval: "weekly"
9+
10+
# Maintain dependencies for Composer
11+
- package-ecosystem: "composer"
12+
directory: "/"
13+
schedule:
14+
interval: "weekly"

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
tests:
9+
name: Tests
10+
runs-on: ubuntu-latest
11+
12+
strategy:
13+
matrix:
14+
php-version: ["8.5"]
15+
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: ${{ matrix.php-version }}
22+
coverage: none
23+
24+
- uses: ramsey/composer-install@v4
25+
26+
- run: composer phpunit
27+
28+
static-analysis:
29+
name: Static Analysis
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- uses: actions/checkout@v6
34+
35+
- uses: shivammathur/setup-php@v2
36+
with:
37+
php-version: "8.5"
38+
coverage: none
39+
40+
- uses: ramsey/composer-install@v4
41+
42+
- run: composer phpcs
43+
- run: composer phpstan

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/vendor/
2+
/composer.lock
3+
/.phpunit.cache/
4+
/.phpcs.cache
5+
/.phpstan.cache/
6+
/.idea/

.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!--
2+
SPDX-FileCopyrightText: (c) Respect Project Contributors
3+
SPDX-License-Identifier: MIT
4+
-->
5+
6+
# Contributing
7+
8+
Contributions to Respect\ValidationBundle are always welcome. You make our lives
9+
easier by sending us your contributions through [pull requests][].
10+
11+
Due to time constraints, we are not always able to respond as quickly as we
12+
would like. Please do not take delays personally.
13+
14+
Before writing anything, feature or bug fix:
15+
16+
- Check if there is already an issue related to it (opened or closed) and if
17+
someone is already working on that;
18+
- If there is not, [open an issue][] and notify everybody that you're going
19+
to work on that;
20+
- If there is, create a comment to notify everybody that you're going to
21+
work on that.
22+
- Make sure that what you need is not done yet.
23+
24+
This bundle is intentionally small: it wires
25+
[Respect\Validation](https://github.com/Respect/Validation) into a Symfony
26+
application's service container. New validation rules belong in the
27+
[Respect\Validation](https://github.com/Respect/Validation) library, not here.
28+
If you want to make a new rule available to your Symfony app without contributing
29+
it upstream, add your namespace via the `rule_namespaces` configuration option
30+
documented in the README.
31+
32+
## Scope of contributions
33+
34+
Changes that belong in this repository:
35+
36+
- Bundle wiring (`src/`, `config/`) for new services Respect\Validation exposes.
37+
- Configuration options that influence how Validation services are constructed.
38+
- Tests covering the bundle's integration with Symfony.
39+
- Tooling, CI, and documentation for the bundle itself.
40+
41+
Changes that should go to [Respect\Validation](https://github.com/Respect/Validation):
42+
43+
- New validation rules.
44+
- Changes to existing validation rules' behaviour.
45+
- Changes to `ValidatorBuilder`, `ValidatorFactory`, or any class under
46+
`Respect\Validation\*`.
47+
48+
## Running Checks
49+
50+
After running `composer install` in the bundle's root directory you must run
51+
`composer qa`.
52+
53+
This alias runs PHP_CodeSniffer, PHPStan, and PHPUnit. All three must pass.
54+
55+
Check the `scripts` section of `composer.json` for the individual commands.
56+
57+
[open an issue]: https://github.com/Respect/ValidationBundle/issues
58+
[pull requests]: https://help.github.com/pull-requests "GitHub pull requests"

0 commit comments

Comments
 (0)