Skip to content

Commit 23e43bb

Browse files
authored
test(github): Enable PHP 8.2 testing (#1321)
1 parent 5c83c82 commit 23e43bb

File tree

6 files changed

+11
-28
lines changed

6 files changed

+11
-28
lines changed

.github/workflows/testing.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
php-versions: ['7.3', '7.4', '8.0']
16+
php-versions: ['7.3', '7.4', '8.0', '8.1']
1717
drupal-core: ['9.5.x']
1818
phpstan: ['0']
1919
include:
20-
# We only need to run PHPStan once on the latest PHP version.
21-
- php-versions: '8.1'
22-
drupal-core: '9.5.x'
23-
phpstan: '1'
24-
# Extra run to also test on latest Drupal 10 and PHP 8.1.
20+
# Extra runs to also test on latest Drupal 10.
2521
- php-versions: '8.1'
2622
drupal-core: '10.0.x'
2723
phpstan: '0'
24+
# We only need to run PHPStan once on the latest PHP version.
25+
- php-versions: '8.2'
26+
drupal-core: '10.0.x'
27+
phpstan: '1'
2828
steps:
2929
- name: Checkout Drupal core
3030
uses: actions/checkout@v3
@@ -110,7 +110,9 @@ jobs:
110110
SIMPLETEST_DB: "sqlite://localhost/:memory:"
111111

112112
- name: Run PHPStan
113-
run: if [[ ${{ matrix.phpstan }} == "1" ]]; then cd modules/graphql && ../../vendor/bin/phpstan analyse; fi
113+
# phpstan-drupal bug, so we remove 1 stub file
114+
# https://github.com/mglaman/phpstan-drupal/issues/509
115+
run: if [[ ${{ matrix.phpstan }} == "1" ]]; then rm vendor/mglaman/phpstan-drupal/stubs/Drupal/Core/Field/FieldItemList.stub && cd modules/graphql && ../../vendor/bin/phpstan analyse; fi
114116

115117
- name: Run PHPCS
116118
run: |

phpstan.neon

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,6 @@ parameters:
2424
# Drupal allows object property access to custom fields, so we cannot fix
2525
# that.
2626
- "#^Access to an undefined property Drupal\\\\#"
27-
# PHPUnit deprecation warnings in Drupal 9 that we don't care about.
28-
- "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch\\(\\) invoked with 2 parameters, 1 required\\.$#"
29-
# Drupal allows object property access to custom fields, so we cannot fix
30-
# that.
31-
- "#^Property Drupal\\\\.+ \\(Drupal\\\\Core\\\\Field\\\\FieldItemListInterface\\) does not accept .+\\.$#"
32-
# Incomplete type doc comments in Drupal core that we have to ignore.
33-
-
34-
message: "#^Method Drupal\\\\graphql\\\\Plugin\\\\LanguageNegotiation\\\\OperationLanguageNegotiation\\:\\:getLangcode\\(\\) should return string but returns false\\.$#"
35-
count: 1
36-
path: src/Plugin/LanguageNegotiation/OperationLanguageNegotiation.php
3727
# We forgot to use return type hints on some interfaces, cannot be changed
3828
# in stable 4.0.
3929
# @todo use return type hints everywhere for 5.0.

src/GraphQL/Execution/Executor.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -443,12 +443,7 @@ protected function cacheWrite($prefix, CacheableExecutionResult $result) {
443443
* @see \Drupal\Core\Cache\CacheBackendInterface::set()
444444
*/
445445
protected function maxAgeToExpire($maxAge) {
446-
/* @todo Can be removed when D9 support is dropped. In D9
447-
* \Drupal\Core\Http\RequestStack is used here for forward compatibility,
448-
* but phpstan thinks it's \Symfony\Component\HttpFoundation\RequestStack
449-
* which doesn't have getMainRequest(), but in Drupal10 (Symfony 6) it has.
450-
*/
451-
/* @phpstan-ignore-next-line */
446+
// @todo Can be removed when D9 support is dropped.
452447
$time = $this->requestStack->getMainRequest()->server->get('REQUEST_TIME');
453448
return ($maxAge === Cache::PERMANENT) ? Cache::PERMANENT : (int) $time + $maxAge;
454449
}

src/Plugin/GraphQL/DataProducer/DataProducerProxy.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ protected function cacheWrite($prefix, $value, FieldContext $field): void {
363363
* @see \Drupal\Core\Cache\CacheBackendInterface::set()
364364
*/
365365
protected function maxAgeToExpire($maxAge) {
366-
/* @phpstan-ignore-next-line */
367366
$time = $this->requestStack->getMainRequest()->server->get('REQUEST_TIME');
368367
return ($maxAge === Cache::PERMANENT) ? Cache::PERMANENT : (int) $time + $maxAge;
369368
}

src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ public function resolve(FileInterface $entity = NULL, $style, RefinableCacheable
101101
$width = $entity->width;
102102
$height = $entity->height;
103103

104-
// @todo Not sure why PHPStan complains here, this should be refactored to
105-
// check the entity properties first.
106-
// @phpstan-ignore-next-line
107104
if (empty($width) || empty($height)) {
108105
/** @var \Drupal\Core\Image\ImageInterface $image */
109106
$image = \Drupal::service('image.factory')->get($entity->getFileUri());

tests/src/Traits/QueryResultAssertionTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ private function assertResultErrors(ExecutionResult $result, array $expected): v
192192
while ($original_error->getPrevious() !== NULL) {
193193
$original_error = $original_error->getPrevious();
194194
}
195-
$unexpected[] = "Error message: ${error_message}\n Originated in: {$original_error->getFile()}:{$original_error->getLine()}";
195+
$unexpected[] = "Error message: {$error_message}\n Originated in: {$original_error->getFile()}:{$original_error->getLine()}";
196196
}
197197
}
198198

0 commit comments

Comments
 (0)