Skip to content

Commit 0613dbb

Browse files
committed
Adjusting phpstan warning for D11 only.
1 parent 8803a2c commit 0613dbb

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

.github/workflows/testing.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ jobs:
2222
drupal-core: '10.2.x'
2323
phpstan: '0'
2424
# We only need to run PHPStan once on the latest PHP version.
25-
- php-versions: '8.3'
26-
drupal-core: '10.3.x'
27-
phpstan: '1'
2825
- php-versions: '8.3'
2926
drupal-core: '11.0.x'
3027
phpstan: '1'

src/GraphQL/Utility/FileUpload.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ protected function prepareFilename(string $filename, array &$validators): string
514514
// If the file will be rejected anyway due to a disallowed extension, it
515515
// should not be renamed; rather, we'll let fileValidator service
516516
// to validate FileExtension reject it below.
517-
518517
$passes_validation = FALSE;
519518
if (!empty($validators['FileExtension']['extensions'])) {
520519
/** @var \Drupal\file\FileInterface $file */

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,18 @@ public function resolve(FileInterface $entity = NULL, $style, RefinableCacheable
9898
$metadata->addCacheableDependency($access);
9999
if ($access->isAllowed() && $image_style = ImageStyle::load($style)) {
100100

101-
/** @var \Drupal\Core\Image\ImageInterface $image */
102-
$image = \Drupal::service('image.factory')->get($entity->getFileUri());
103-
if ($image->isValid()) {
104-
$width = $image->getWidth();
105-
$height = $image->getHeight();
101+
// @phpstan-ignore-next-line
102+
$width = $entity->width;
103+
// @phpstan-ignore-next-line
104+
$height = $entity->height;
105+
106+
if (!isset($width) || !isset($height)) {
107+
/** @var \Drupal\Core\Image\ImageInterface $image */
108+
$image = \Drupal::service('image.factory')->get($entity->getFileUri());
109+
if ($image->isValid()) {
110+
$width = $image->getWidth();
111+
$height = $image->getHeight();
112+
}
106113
}
107114

108115
// Determine the dimensions of the styled image.

src/Routing/QueryRouteEnhancer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ protected function assertValidPostRequestHeaders(Request $request) : void {
9292
return;
9393
}
9494

95+
// @phpstan-ignore-next-line
9596
$content_format = method_exists($request, 'getContentTypeFormat') ? $request->getContentTypeFormat() : $request->getContentType();
9697
if ($content_format === NULL) {
9798
// Symfony before 5.4 does not detect "multipart/form-data", check for it

tests/src/Kernel/DataProducer/Entity/Fields/Image/ImageDerivativeTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public function setUp(): void {
6262

6363
$this->file->method('getFileUri')->willReturn($this->fileUri);
6464
$this->file->method('access')->willReturn((new AccessResultAllowed())->addCacheTags(['test_tag']));
65+
// @todo Remove hard-coded properties and only rely on image factory.
66+
// @phpstan-ignore-next-line
67+
@$this->file->width = 600;
68+
// @phpstan-ignore-next-line
69+
@$this->file->height = 400;
6570

6671
$this->style = ImageStyle::create(['name' => 'test_style']);
6772
$effect = [

tests/src/Kernel/DataProducer/EntityReferenceTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
use Drupal\Core\Field\FieldStorageDefinitionInterface;
66
use Drupal\node\Entity\Node;
77
use Drupal\node\Entity\NodeType;
8-
use Drupal\Tests\graphql\Kernel\GraphQLTestBase;
98
use Drupal\Tests\field\Traits\EntityReferenceFieldCreationTrait;
10-
9+
use Drupal\Tests\graphql\Kernel\GraphQLTestBase;
1110

1211
/**
1312
* Tests the entity_reference data producers.

0 commit comments

Comments
 (0)