Skip to content

Commit 33c3cdd

Browse files
authored
[v5] PHP 8.1, Symfony 6.4, phpstan (#2216)
* bump dependencies for to php >=8.1 * remove symfony 5.4 support & bump symfony 6 to minimum 6.4 * use ramsey/composer-install in ci * use ramsey/composer-install in ci * use ramsey/composer-install in ci * fix sensio/framework-extra-bundle dependency * ease symfony/framework-bundle constraint * remove unsupported sensio/framework-extra-bundle * Revert "remove unsupported sensio/framework-extra-bundle" This reverts commit a028601. * fix incompatible Symfony 7 job being skipped * fix incorrect docs for MapQueryString controller * rewrite annotation detection * fix symfony 7 not using serializer groups * update baseline * exclude symfony 7 with annotations support * skip symfony 7 & php 8.1 * replace phpunit baseline with ignoreFile * bump phpunit * improve ci readability * rename docs workflow * add phpstan * use ubuntu latest * ci docs: use same rules to lower jobs * cleanup phpunit.xml.dist * include root php files * generate phpstan baseline * style fix * bump dependencies for to php >=8.1 * remove symfony 5.4 support & bump symfony 6 to minimum 6.4 * use ramsey/composer-install in ci * use ramsey/composer-install in ci * use ramsey/composer-install in ci * fix sensio/framework-extra-bundle dependency * ease symfony/framework-bundle constraint * remove unsupported sensio/framework-extra-bundle * Revert "remove unsupported sensio/framework-extra-bundle" This reverts commit a028601. * fix incompatible Symfony 7 job being skipped * fix incorrect docs for MapQueryString controller * rewrite annotation detection * fix symfony 7 not using serializer groups * update baseline * exclude symfony 7 with annotations support * skip symfony 7 & php 8.1 * replace phpunit baseline with ignoreFile * bump phpunit * improve ci readability * rename docs workflow * add phpstan * use ubuntu latest * ci docs: use same rules to lower jobs * cleanup phpunit.xml.dist * include root php files * generate phpstan baseline * style fix * update phpstan-baseline
1 parent 61c08f1 commit 33c3cdd

16 files changed

+2413
-12926
lines changed

.github/workflows/continuous-integration.yml

+20-33
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,29 @@ env:
1919
jobs:
2020
phpunit:
2121
name: "PHPUnit"
22-
runs-on: "ubuntu-22.04"
22+
runs-on: "ubuntu-latest"
2323

2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
include:
28-
- php-version: 7.2
29-
composer-flags: "--prefer-lowest"
27+
php:
28+
- "8.1"
29+
- "8.2"
30+
- "8.3"
31+
symfony-require:
32+
- "^6.4"
33+
- "^7.0"
34+
dependencies:
35+
- "lowest"
36+
- "highest"
37+
doctrine-annotations:
38+
- true
39+
- false
40+
exclude:
41+
- symfony-require: "^7.0"
3042
doctrine-annotations: true
31-
- php-version: 7.3
32-
symfony-require: "5.4.*"
33-
doctrine-annotations: true
34-
- php-version: 7.4
35-
symfony-require: "5.4.*"
36-
doctrine-annotations: true
37-
- php-version: 8.0
38-
symfony-require: "5.4.*"
39-
doctrine-annotations: true
40-
- php-version: 8.1
41-
symfony-require: "5.4.*"
42-
doctrine-annotations: true
43-
- php-version: 8.3
44-
symfony-require: "5.4.*"
45-
doctrine-annotations: true
46-
- php-version: 8.1
47-
symfony-require: "6.3.*"
48-
doctrine-annotations: true
49-
- php-version: 8.3
50-
symfony-require: "6.3.*"
51-
doctrine-annotations: true
52-
- php-version: 8.2
53-
symfony-require: "7.0.*"
54-
doctrine-annotations: false
55-
- php-version: 8.3
56-
symfony-require: "7.0.*"
57-
doctrine-annotations: false
43+
- php: "8.1"
44+
symfony-require: "^7.0"
5845

5946
steps:
6047
- name: "Checkout"
@@ -86,14 +73,14 @@ jobs:
8673
composer require doctrine/annotations --no-update
8774
8875
- name: Remove packages not compatible symfony 7
89-
if: matrix.symfony-require == '7.0.*'
76+
if: matrix.symfony-require == '^7.0'
9077
run: |
9178
composer remove friendsofsymfony/rest-bundle sensio/framework-extra-bundle --no-update --dev
9279
9380
- name: "Install dependencies with composer"
81+
uses: "ramsey/composer-install@v2"
9482
env:
9583
SYMFONY_REQUIRE: "${{ matrix.symfony-require }}"
96-
run: composer update --no-interaction --no-progress ${{ matrix.composer-flags }}
9784

9885
- name: "PHPUnit Tests"
9986
run: vendor/bin/phpunit --configuration phpunit.xml.dist --coverage-text

.github/workflows/docs.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
name: CI
1+
name: docs
22

33
on:
4-
push: ~
5-
pull_request: ~
4+
pull_request:
5+
branches:
6+
- "*.x"
7+
- master
8+
push:
9+
branches:
10+
- "*.x"
11+
- master
612

713
jobs:
814
doctor-rst:
915
name: Lint (DOCtor-RST)
10-
1116
runs-on: ubuntu-latest
1217

1318
steps:

.github/workflows/static-analysis.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "static-analysis"
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "*.x"
7+
- master
8+
push:
9+
branches:
10+
- "*.x"
11+
- master
12+
13+
jobs:
14+
static-analysis:
15+
name: "PHPStan"
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: "Checkout"
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 2
23+
24+
- name: "Install PHP without coverage"
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: '8.1'
28+
29+
- name: "Cache dependencies"
30+
uses: actions/cache@v3
31+
with:
32+
path: ${{ steps.composercache.outputs.dir }}
33+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
34+
restore-keys: ${{ runner.os }}-composer-
35+
36+
- name: "Install dependencies with composer"
37+
uses: "ramsey/composer-install@v2"
38+
with:
39+
dependency-versions: 'highest'
40+
41+
- name: "PHPStan"
42+
run: composer phpstan
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
framework:
2+
annotations: true
3+
serializer:
4+
enable_annotations: true

Tests/Functional/Controller/MapQueryStringController.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,34 @@
1010
use Nelmio\ApiDocBundle\Tests\Functional\Entity\QueryModel\SortQueryModel;
1111
use Nelmio\ApiDocBundle\Tests\Functional\Entity\SymfonyConstraintsWithValidationGroups;
1212
use Nelmio\ApiDocBundle\Tests\Functional\Entity\SymfonyMapQueryString;
13+
use OpenApi\Attributes as OA;
1314
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
1415
use Symfony\Component\Routing\Annotation\Route;
1516

1617
class MapQueryStringController
1718
{
18-
#[Route('/article_map_query_string')]
19+
#[Route('/article_map_query_string', methods: ['GET'])]
1920
#[OA\Response(response: '200', description: '')]
2021
public function fetchArticleFromMapQueryString(
2122
#[MapQueryString] SymfonyMapQueryString $article81Query
2223
) {
2324
}
2425

25-
#[Route('/article_map_query_string_nullable')]
26+
#[Route('/article_map_query_string_nullable', methods: ['GET'])]
2627
#[OA\Response(response: '200', description: '')]
2728
public function fetchArticleFromMapQueryStringNullable(
2829
#[MapQueryString] ?SymfonyMapQueryString $article81Query
2930
) {
3031
}
3132

32-
#[Route('/article_map_query_string_passes_validation_groups')]
33+
#[Route('/article_map_query_string_passes_validation_groups', methods: ['GET'])]
3334
#[OA\Response(response: '200', description: '')]
3435
public function fetchArticleFromMapQueryStringHandlesValidationGroups(
3536
#[MapQueryString(validationGroups: ['test'])] SymfonyConstraintsWithValidationGroups $symfonyConstraintsWithValidationGroups,
3637
) {
3738
}
3839

39-
#[Route('/article_map_query_string_overwrite_parameters')]
40+
#[Route('/article_map_query_string_overwrite_parameters', methods: ['GET'])]
4041
#[OA\Parameter(
4142
name: 'id',
4243
in: 'query',
@@ -69,7 +70,7 @@ public function fetchArticleFromMapQueryStringOverwriteParameters(
6970
) {
7071
}
7172

72-
#[Route('/article_map_query_string_many_parameters')]
73+
#[Route('/article_map_query_string_many_parameters', methods: ['GET'])]
7374
#[OA\Response(response: '200', description: '')]
7475
public function fetchArticleWithManyParameters(
7576
#[MapQueryString] FilterQueryModel $filterQuery,
@@ -79,7 +80,7 @@ public function fetchArticleWithManyParameters(
7980
) {
8081
}
8182

82-
#[Route('/article_map_query_string_many_parameters_optional')]
83+
#[Route('/article_map_query_string_many_parameters_optional', methods: ['GET'])]
8384
#[OA\Response(response: '200', description: '')]
8485
public function fetchArticleWithManyOptionalParameters(
8586
#[MapQueryString] ?FilterQueryModel $filterQuery,

0 commit comments

Comments
 (0)