Skip to content

Commit 772552a

Browse files
authored
Update package versions (#39)
1 parent d73aa29 commit 772552a

File tree

8 files changed

+56
-45
lines changed

8 files changed

+56
-45
lines changed

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,12 @@
5353
*.ttf -text diff
5454
*.woff -text diff
5555
*.woff2 -text diff
56+
57+
# Exclude directories/files from composer vendor package
58+
/tests export-ignore
59+
/.* export-ignore
60+
/php*.json export-ignore
61+
/php*.xml export-ignore
62+
/php*.dist export-ignore
63+
/php*.neon export-ignore
64+
/renovate.json export-ignore

.github/workflows/test.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ permissions:
1111

1212
jobs:
1313
test:
14-
name: PHP ${{ matrix.php-versions }} Test ${{ matrix.composer-flags }}
14+
name: PHP ${{ matrix.php-versions }} - Symfony ${{ matrix.symfony }} - Test ${{ matrix.composer-flags }}
15+
env:
16+
SYMFONY_REQUIRE: ${{ matrix.symfony }}
1517
runs-on: ubuntu-latest
1618
strategy:
1719
matrix:
18-
php-versions: ['7.4', '8.0', '8.1', '8.2']
19-
composer-flags: ['', '--prefer-lowest']
20+
php-versions: [ '8.1', '8.2', '8.3' ]
21+
symfony: [ '^6.2', '^7.0' ]
22+
composer-flags: [ '', '--prefer-lowest' ]
23+
exclude:
24+
- php-versions: 8.1
25+
symfony: '^7.0'
2026
steps:
2127
- uses: actions/checkout@v4
2228

@@ -26,6 +32,9 @@ jobs:
2632
php-version: ${{ matrix.php-versions }}
2733
coverage: none
2834

35+
- name: Add symfony flex
36+
run: composer global config --no-interaction allow-plugins.symfony/flex true && composer global require symfony/flex
37+
2938
- name: Validate composer.json and composer.lock
3039
run: composer validate
3140

@@ -44,7 +53,7 @@ jobs:
4453
- name: Setup PHP
4554
uses: shivammathur/setup-php@v2
4655
with:
47-
php-version: 8.2
56+
php-version: 8.3
4857
coverage: pcov
4958

5059
- name: Install dependencies
@@ -54,7 +63,7 @@ jobs:
5463
run: php -dpcov.enabled=1 -dpcov.exclude="~vendor~" vendor/bin/phpunit --testsuite unit --coverage-clover ./.coverage/coverage.xml
5564

5665
- name: Check coverage
57-
run: php vendor/bin/phpfci inspect ./.coverage/coverage.xml ./.coverage/phpfci.xml --exit-code-on-failure
66+
run: test ! -f ./.coverage/coverage.xml || php vendor/bin/phpfci inspect ./.coverage/coverage.xml --exit-code-on-failure --reportText
5867

5968
quality:
6069
name: Quality checks
@@ -65,7 +74,7 @@ jobs:
6574
- name: Setup PHP
6675
uses: shivammathur/setup-php@v2
6776
with:
68-
php-version: 7.4
77+
php-version: 8.1
6978
coverage: none
7079

7180
- name: Install dependencies

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.4-8892BF)](https://php.net/)
2-
[![Minimum Symfony Version](https://img.shields.io/badge/symfony-%3E%3D%204.4-brightgreen)](https://symfony.com/doc/current/validation.html)
3-
![Run tests](https://github.com/123inkt/symfony-request-validation/workflows/Run%20tests/badge.svg)
1+
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF)](https://php.net/)
2+
[![Minimum Symfony Version](https://img.shields.io/badge/symfony-%3E%3D%206.2-brightgreen)](https://symfony.com/doc/current/validation.html)
3+
![Run tests](https://github.com/123inkt/symfony-request-validation/actions/workflows/test.yml/badge.svg)
44

55
# Symfony Request Validation
66
A request validation component for Symfony. Ease the validation of request properties without the need for an entire Symfony Form.

composer.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@
1111
}
1212
},
1313
"require": {
14-
"php": ">=7.4",
15-
"symfony/config": "^5.4 || ^6.0",
16-
"symfony/dependency-injection": "^5.4 || ^6.0",
17-
"symfony/http-foundation": "^5.4 || ^6.0",
18-
"symfony/http-kernel": "^5.4 || ^6.0",
19-
"symfony/validator": "^5.4 || ^6.0",
20-
"digitalrevolution/symfony-validation-shorthand": "^1.0.4"
14+
"php": ">=8.1",
15+
"symfony/config": "^6.2 || ^7.0",
16+
"symfony/dependency-injection": "^6.2 || ^7.0",
17+
"symfony/http-foundation": "^6.2 || ^7.0",
18+
"symfony/http-kernel": "^6.2 || ^7.0",
19+
"symfony/validator": "^6.2 || ^7.0",
20+
"digitalrevolution/symfony-validation-shorthand": "^1.2"
2121
},
2222
"require-dev": {
23-
"digitalrevolution/phpunit-file-coverage-inspection": "^v1.0",
23+
"digitalrevolution/phpunit-file-coverage-inspection": "^v2.0.0",
2424
"roave/security-advisories": "dev-latest",
2525
"squizlabs/php_codesniffer": "^3.6",
26-
"phpmd/phpmd": "@stable",
27-
"phpunit/phpunit": "^9.5",
28-
"phpstan/phpstan": "^1.4",
29-
"phpstan/phpstan-phpunit": "^1.0",
30-
"phpstan/phpstan-strict-rules": "^1.1",
31-
"phpstan/phpstan-symfony": "^1.2",
32-
"phpstan/extension-installer": "^1.1"
26+
"phpmd/phpmd": "^2.14",
27+
"phpunit/phpunit": "^9.6",
28+
"phpstan/phpstan": "^1.10",
29+
"phpstan/phpstan-phpunit": "^1.3",
30+
"phpstan/phpstan-strict-rules": "^1.5",
31+
"phpstan/phpstan-symfony": "^1.3",
32+
"phpstan/extension-installer": "^1.3"
3333
},
3434
"autoload": {
3535
"psr-4": {
@@ -44,7 +44,7 @@
4444
"scripts": {
4545
"check": ["@check:phpstan", "@check:phpmd", "@check:phpcs"],
4646
"check:phpstan": "phpstan analyse",
47-
"check:phpmd": "phpmd src,tests text phpmd.xml.dist --suffixes=php",
47+
"check:phpmd": "phpmd src,tests text phpmd.xml.dist --suffixes php",
4848
"check:phpcs": "phpcs src tests",
4949
"fix": "@fix:phpcbf",
5050
"fix:phpcbf": "phpcbf src tests",

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
55
forceCoversAnnotation="true"
66
failOnRisky="true"

src/Constraint/RequestConstraint.php

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,28 @@ class RequestConstraint extends Constraint
1313
public const INVALID_BODY_CONTENT = '3b41f393-5f46-471e-8a2e-c4035d5fb3cb';
1414

1515
/** @var array<string, string> */
16-
protected static $errorNames = [
16+
protected const ERROR_NAMES = [
1717
self::WRONG_VALUE_TYPE => 'WRONG_VALUE_TYPE',
1818
self::MISSING_QUERY_CONSTRAINT => 'MISSING_QUERY_CONSTRAINT',
1919
self::MISSING_REQUEST_CONSTRAINT => 'MISSING_REQUEST_CONSTRAINT',
2020
self::INVALID_BODY_CONTENT => 'INVALID_BODY_CONTENT',
2121
];
2222

23-
/** @var string */
24-
public $wrongTypeMessage = 'Expect value to be of type Symfony\Component\HttpFoundation\Request';
25-
/** @var string */
26-
public $queryMessage = 'Request::query is not empty, but there is no constraint configured.';
27-
/** @var string */
28-
public $requestMessage = 'Request::request is not empty, but there is no constraint configured.';
29-
/** @var string */
30-
public $invalidBodyMessage = 'Request::content cant be decoded';
23+
public string $wrongTypeMessage = 'Expect value to be of type Symfony\Component\HttpFoundation\Request';
24+
public string $queryMessage = 'Request::query is not empty, but there is no constraint configured.';
25+
public string $requestMessage = 'Request::request is not empty, but there is no constraint configured.';
26+
public string $invalidBodyMessage = 'Request::content cant be decoded';
3127

3228
/** @var Constraint|Constraint[]|null */
33-
public $query;
29+
public Constraint|array|null $query = null;
3430

3531
/** @var Constraint|Constraint[]|null */
36-
public $request;
32+
public Constraint|array|null $request = null;
3733

3834
/** @var Constraint|Constraint[]|null */
39-
public $attributes;
35+
public Constraint|array|null $attributes = null;
4036

41-
/** @var bool */
42-
public $allowExtraFields;
37+
public bool $allowExtraFields = false;
4338

4439
/**
4540
* @param array{
@@ -49,7 +44,7 @@ class RequestConstraint extends Constraint
4944
* allowExtraFields?: bool
5045
* }|null $options
5146
*/
52-
public function __construct($options = null)
47+
public function __construct(?array $options = null)
5348
{
5449
// make sure defaults are set
5550
$options = $options ?? [];

src/Constraint/RequestConstraintValidator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ private function validateRequest(RequestConstraint $constraint, Request $request
6868
return;
6969
}
7070

71-
// `getContentType` deprecated since symfony 6.2
72-
$contentType = method_exists($request, 'getContentTypeFormat') ? $request->getContentTypeFormat() : $request->getContentType();
73-
71+
$contentType = $request->getContentTypeFormat();
7472
if (in_array($contentType, ['json', 'jsonld'], true)) {
7573
$data = $this->validateAndGetJsonBody($constraint, $request);
7674
if ($data === null) {

src/ValidationRules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
/**
1010
* @phpstan-type ConstraintList array<string, string|Constraint|array<string|Constraint>>|array<int, Constraint>
11-
* @phpstan-type DefinitionCollection array{query?: ConstraintList, request?: ConstraintList, attributes?: ConstraintList }
11+
* @phpstan-type DefinitionCollection array{query?: ConstraintList, request?: ConstraintList, attributes?: ConstraintList}
1212
*/
1313
class ValidationRules
1414
{

0 commit comments

Comments
 (0)