Skip to content

Commit c0d26ed

Browse files
committed
[Turbo] Fix Turbo CI (PHPStan & Functional tests)
1 parent 53515c6 commit c0d26ed

File tree

9 files changed

+26
-23
lines changed

9 files changed

+26
-23
lines changed

.github/workflows/code-quality.yaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,27 @@ jobs:
3535
strategy:
3636
fail-fast: false
3737
matrix:
38-
package: ${{ fromJson(needs.php-packages-matrix.outputs.packages) }}
38+
php-version: [ '8.1', '8.2', '8.3', '8.4']
39+
dependency-version: ['']
40+
symfony-version: ['']
41+
minimum-stability: ['stable']
42+
include:
43+
# lowest deps
44+
- php-version: '8.1'
45+
dependency-version: 'lowest'
46+
# LTS version of Symfony
47+
- php-version: '8.1'
48+
symfony-version: '6.4.*'
3949
steps:
4050
- name: Checkout
4151
uses: actions/checkout@v4
4252

4353
- name: Configure environment
4454
run: |
4555
echo COLUMNS=120 >> $GITHUB_ENV
46-
echo COMPOSER_MIN_STAB='composer config minimum-stability stable --ansi' >> $GITHUB_ENV
47-
echo COMPOSER_UP='composer update --no-progress --no-interaction --ansi' >> $GITHUB_ENV
56+
echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.minimum-stability || 'stable' }} --ansi' >> $GITHUB_ENV
57+
echo COMPOSER_UP='composer update ${{ matrix.dependency-version == 'lowest' && '--prefer-lowest' || '' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV
58+
echo PHPUNIT_INSTALL='vendor/bin/simple-phpunit install' >> $GITHUB_ENV
4859
echo PHPSTAN='vendor/bin/phpstan' >> $GITHUB_ENV
4960
5061
# TODO: Only Turbo has PHPStan configuration, let's improve this later :)
@@ -69,4 +80,4 @@ jobs:
6980
run: |
7081
source .github/workflows/.utils.sh
7182
72-
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPSTAN)'"
83+
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPUNIT_INSTALL && $PHPSTAN)'"

.github/workflows/functional-tests.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ name: Functional Tests
33
on:
44
push:
55
paths:
6+
- '.github/workflows/functional-tests.yml'
67
- 'src/Turbo/**'
78
pull_request:
89
paths:
10+
- '.github/workflows/functional-tests.yml'
911
- 'src/Turbo/**'
1012

1113
jobs:
@@ -30,7 +32,7 @@ jobs:
3032
symfony-version: '6.4.*'
3133

3234
env:
33-
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
35+
SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=5.4' }}
3436
services:
3537
mercure:
3638
image: dunglas/mercure

.github/workflows/unit-tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
symfony-version: '6.4.*'
3939

4040
env:
41-
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
41+
SYMFONY_REQUIRE: ${{ matrix.symfony-version || '>=5.4' }}
4242
steps:
4343
- uses: actions/checkout@v4
4444

src/Turbo/.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/.git* export-ignore
22
/.symfony.bundle.yaml export-ignore
33
/phpunit.xml.dist export-ignore
4-
/phpstan.neon.dist export-ignore
4+
/phpstan.dist.neon export-ignore
55
/assets/src export-ignore
66
/assets/test export-ignore
77
/assets/vitest.config.js export-ignore

src/Turbo/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"require-dev": {
4141
"doctrine/doctrine-bundle": "^2.4.3",
4242
"doctrine/orm": "^2.8 | 3.0",
43-
"phpstan/phpstan": "^1.10",
43+
"phpstan/phpstan": "^2.1.17",
4444
"symfony/asset-mapper": "^6.4|^7.0",
4545
"symfony/debug-bundle": "^5.4|^6.0|^7.0",
4646
"symfony/form": "^5.4|^6.0|^7.0",

src/Turbo/phpstan.neon.dist renamed to src/Turbo/phpstan.dist.neon

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ parameters:
77
- tests/app/var/*
88
# The Symfony Configuration API isn't good enough to be analysed
99
- src/DependencyInjection/Configuration.php
10+
# to allow installing with various phsptan versions without reporting old errors here
11+
reportUnmatchedIgnoredErrors: false
1012
inferPrivatePropertyTypeFromConstructor: true
1113
bootstrapFiles:
1214
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
@@ -36,16 +38,6 @@ parameters:
3638
count: 1
3739
path: src/Bridge/Mercure/TurboStreamListenRenderer.php
3840

39-
-
40-
message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Event\\\\OnFlushEventArgs\\:\\:getEntityManager\\(\\)\\.$#"
41-
count: 1
42-
path: src/Doctrine/BroadcastListener.php
43-
44-
-
45-
message: "#^Call to an undefined method Doctrine\\\\ORM\\\\Event\\\\PostFlushEventArgs\\:\\:getEntityManager\\(\\)\\.$#"
46-
count: 1
47-
path: src/Doctrine/BroadcastListener.php
48-
4941
-
5042
message: "#^Method Symfony\\\\UX\\\\Turbo\\\\TurboStreamResponse::__construct\\(\\) has parameter \\$headers with no value type specified in iterable type array\\.$#"
5143
count: 1

src/Turbo/src/Attribute/Broadcast.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ final class Broadcast
4242
*/
4343
public function __construct(...$options)
4444
{
45+
// @phpstan-ignore function.alreadyNarrowedType
4546
if ([0] === array_keys($options) && \is_array($options[0]) && \is_string(key($options[0]))) {
4647
$options = $options[0];
4748
}

src/Turbo/src/Bridge/Mercure/Broadcaster.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ public function broadcast(object $entity, string $action, array $options): void
6868
$topics = [];
6969

7070
foreach ((array) ($options['topics'] ?? []) as $topic) {
71-
if (!\is_string($topic)) {
72-
$topics[] = $topic;
73-
continue;
74-
}
75-
7671
if (!str_starts_with($topic, '@=')) {
7772
$topics[] = $topic;
7873
continue;

src/Turbo/src/Doctrine/BroadcastListener.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function onFlush(EventArgs $eventArgs): void
6161
return;
6262
}
6363

64+
// @phpstan-ignore function.alreadyNarrowedType, method.notFound (`getEntityManager()` has been removed in Doctrine 3.0)
6465
$em = method_exists($eventArgs, 'getObjectManager') ? $eventArgs->getObjectManager() : $eventArgs->getEntityManager();
6566
$uow = $em->getUnitOfWork();
6667
foreach ($uow->getScheduledEntityInsertions() as $entity) {
@@ -85,6 +86,7 @@ public function postFlush(EventArgs $eventArgs): void
8586
return;
8687
}
8788

89+
// @phpstan-ignore function.alreadyNarrowedType, method.notFound (`getEntityManager()` has been removed in Doctrine 3.0)
8890
$em = method_exists($eventArgs, 'getObjectManager') ? $eventArgs->getObjectManager() : $eventArgs->getEntityManager();
8991

9092
try {

0 commit comments

Comments
 (0)