Skip to content

Commit

Permalink
[v5] PHP 8.1, Symfony 6.4, phpstan (#2216)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
DjordyKoert authored Feb 15, 2024
1 parent 61c08f1 commit 33c3cdd
Show file tree
Hide file tree
Showing 16 changed files with 2,413 additions and 12,926 deletions.
53 changes: 20 additions & 33 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,29 @@ env:
jobs:
phpunit:
name: "PHPUnit"
runs-on: "ubuntu-22.04"
runs-on: "ubuntu-latest"

strategy:
fail-fast: false
matrix:
include:
- php-version: 7.2
composer-flags: "--prefer-lowest"
php:
- "8.1"
- "8.2"
- "8.3"
symfony-require:
- "^6.4"
- "^7.0"
dependencies:
- "lowest"
- "highest"
doctrine-annotations:
- true
- false
exclude:
- symfony-require: "^7.0"
doctrine-annotations: true
- php-version: 7.3
symfony-require: "5.4.*"
doctrine-annotations: true
- php-version: 7.4
symfony-require: "5.4.*"
doctrine-annotations: true
- php-version: 8.0
symfony-require: "5.4.*"
doctrine-annotations: true
- php-version: 8.1
symfony-require: "5.4.*"
doctrine-annotations: true
- php-version: 8.3
symfony-require: "5.4.*"
doctrine-annotations: true
- php-version: 8.1
symfony-require: "6.3.*"
doctrine-annotations: true
- php-version: 8.3
symfony-require: "6.3.*"
doctrine-annotations: true
- php-version: 8.2
symfony-require: "7.0.*"
doctrine-annotations: false
- php-version: 8.3
symfony-require: "7.0.*"
doctrine-annotations: false
- php: "8.1"
symfony-require: "^7.0"

steps:
- name: "Checkout"
Expand Down Expand Up @@ -86,14 +73,14 @@ jobs:
composer require doctrine/annotations --no-update
- name: Remove packages not compatible symfony 7
if: matrix.symfony-require == '7.0.*'
if: matrix.symfony-require == '^7.0'
run: |
composer remove friendsofsymfony/rest-bundle sensio/framework-extra-bundle --no-update --dev
- name: "Install dependencies with composer"
uses: "ramsey/composer-install@v2"
env:
SYMFONY_REQUIRE: "${{ matrix.symfony-require }}"
run: composer update --no-interaction --no-progress ${{ matrix.composer-flags }}

- name: "PHPUnit Tests"
run: vendor/bin/phpunit --configuration phpunit.xml.dist --coverage-text
13 changes: 9 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
name: CI
name: docs

on:
push: ~
pull_request: ~
pull_request:
branches:
- "*.x"
- master
push:
branches:
- "*.x"
- master

jobs:
doctor-rst:
name: Lint (DOCtor-RST)

runs-on: ubuntu-latest

steps:
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "static-analysis"

on:
pull_request:
branches:
- "*.x"
- master
push:
branches:
- "*.x"
- master

jobs:
static-analysis:
name: "PHPStan"
runs-on: ubuntu-latest

steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: "Install PHP without coverage"
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- name: "Cache dependencies"
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

- name: "Install dependencies with composer"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: 'highest'

- name: "PHPStan"
run: composer phpstan
4 changes: 4 additions & 0 deletions Tests/Functional/Configs/annotations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
framework:
annotations: true
serializer:
enable_annotations: true
13 changes: 7 additions & 6 deletions Tests/Functional/Controller/MapQueryStringController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,34 @@
use Nelmio\ApiDocBundle\Tests\Functional\Entity\QueryModel\SortQueryModel;
use Nelmio\ApiDocBundle\Tests\Functional\Entity\SymfonyConstraintsWithValidationGroups;
use Nelmio\ApiDocBundle\Tests\Functional\Entity\SymfonyMapQueryString;
use OpenApi\Attributes as OA;
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
use Symfony\Component\Routing\Annotation\Route;

class MapQueryStringController
{
#[Route('/article_map_query_string')]
#[Route('/article_map_query_string', methods: ['GET'])]
#[OA\Response(response: '200', description: '')]
public function fetchArticleFromMapQueryString(
#[MapQueryString] SymfonyMapQueryString $article81Query
) {
}

#[Route('/article_map_query_string_nullable')]
#[Route('/article_map_query_string_nullable', methods: ['GET'])]
#[OA\Response(response: '200', description: '')]
public function fetchArticleFromMapQueryStringNullable(
#[MapQueryString] ?SymfonyMapQueryString $article81Query
) {
}

#[Route('/article_map_query_string_passes_validation_groups')]
#[Route('/article_map_query_string_passes_validation_groups', methods: ['GET'])]
#[OA\Response(response: '200', description: '')]
public function fetchArticleFromMapQueryStringHandlesValidationGroups(
#[MapQueryString(validationGroups: ['test'])] SymfonyConstraintsWithValidationGroups $symfonyConstraintsWithValidationGroups,
) {
}

#[Route('/article_map_query_string_overwrite_parameters')]
#[Route('/article_map_query_string_overwrite_parameters', methods: ['GET'])]
#[OA\Parameter(
name: 'id',
in: 'query',
Expand Down Expand Up @@ -69,7 +70,7 @@ public function fetchArticleFromMapQueryStringOverwriteParameters(
) {
}

#[Route('/article_map_query_string_many_parameters')]
#[Route('/article_map_query_string_many_parameters', methods: ['GET'])]
#[OA\Response(response: '200', description: '')]
public function fetchArticleWithManyParameters(
#[MapQueryString] FilterQueryModel $filterQuery,
Expand All @@ -79,7 +80,7 @@ public function fetchArticleWithManyParameters(
) {
}

#[Route('/article_map_query_string_many_parameters_optional')]
#[Route('/article_map_query_string_many_parameters_optional', methods: ['GET'])]
#[OA\Response(response: '200', description: '')]
public function fetchArticleWithManyOptionalParameters(
#[MapQueryString] ?FilterQueryModel $filterQuery,
Expand Down
Loading

0 comments on commit 33c3cdd

Please sign in to comment.