Skip to content

Commit

Permalink
Adjusting phpstan warning for D11 only.
Browse files Browse the repository at this point in the history
  • Loading branch information
apathak18 committed Jul 25, 2024
1 parent 8803a2c commit c8ae8b8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ jobs:
drupal-core: '10.2.x'
phpstan: '0'
# We only need to run PHPStan once on the latest PHP version.
- php-versions: '8.3'
drupal-core: '10.3.x'
phpstan: '1'
- php-versions: '8.3'
drupal-core: '11.0.x'
phpstan: '1'
Expand Down
2 changes: 0 additions & 2 deletions src/Entity/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,6 @@ protected function getPersistedQueryLoader() {
protected function getValidationRules() {
return function (OperationParams $params, DocumentNode $document, $operation) {
// queryId is not documented properly in the library, it can be NULL.
// @phpstan-ignore-next-line
if (isset($params->queryId)) {

Check failure on line 521 in src/Entity/Server.php

View workflow job for this annotation

GitHub Actions / Drupal 11.0.x (PHP 8.3)

Property GraphQL\Server\OperationParams::$queryId (string) in isset() is not nullable.
// Assume that pre-parsed documents are already validated. This allows
// us to store pre-validated query documents e.g. for persisted queries
Expand All @@ -528,7 +527,6 @@ protected function getValidationRules() {

// PHPStan thinks this is unreachable code because of the wrongly
// documented $params->queryId.
// @phpstan-ignore-next-line
$rules = array_values(DocumentValidator::defaultRules());

Check failure on line 530 in src/Entity/Server.php

View workflow job for this annotation

GitHub Actions / Drupal 11.0.x (PHP 8.3)

Unreachable statement - code above always terminates.
if ($this->getDisableIntrospection()) {
$rules[] = new DisableIntrospection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,16 @@ public function resolve(FileInterface $entity = NULL, $style, RefinableCacheable
$access = $entity->access('view', NULL, TRUE);
$metadata->addCacheableDependency($access);
if ($access->isAllowed() && $image_style = ImageStyle::load($style)) {

/** @var \Drupal\Core\Image\ImageInterface $image */
$image = \Drupal::service('image.factory')->get($entity->getFileUri());
if ($image->isValid()) {
$width = $image->getWidth();
$height = $image->getHeight();
$width = $entity->width;

Check failure on line 100 in src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php

View workflow job for this annotation

GitHub Actions / Drupal 11.0.x (PHP 8.3)

Access to an undefined property Drupal\file\FileInterface::$width.
$height = $entity->height;

Check failure on line 101 in src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php

View workflow job for this annotation

GitHub Actions / Drupal 11.0.x (PHP 8.3)

Access to an undefined property Drupal\file\FileInterface::$height.

if (!isset($width) || !isset($height)) {
/** @var \Drupal\Core\Image\ImageInterface $image */
$image = \Drupal::service('image.factory')->get($entity->getFileUri());
if ($image->isValid()) {
$width = $image->getWidth();
$height = $image->getHeight();
}
}

// Determine the dimensions of the styled image.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public function setUp(): void {

$this->file->method('getFileUri')->willReturn($this->fileUri);
$this->file->method('access')->willReturn((new AccessResultAllowed())->addCacheTags(['test_tag']));
// @todo Remove hard-coded properties and only rely on image factory.
@$this->file->width = 600;

Check failure on line 66 in tests/src/Kernel/DataProducer/Entity/Fields/Image/ImageDerivativeTest.php

View workflow job for this annotation

GitHub Actions / Drupal 11.0.x (PHP 8.3)

Access to an undefined property Drupal\file\FileInterface&PHPUnit\Framework\MockObject\MockObject::$width.
@$this->file->height = 400;

Check failure on line 67 in tests/src/Kernel/DataProducer/Entity/Fields/Image/ImageDerivativeTest.php

View workflow job for this annotation

GitHub Actions / Drupal 11.0.x (PHP 8.3)

Access to an undefined property Drupal\file\FileInterface&PHPUnit\Framework\MockObject\MockObject::$height.

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

0 comments on commit c8ae8b8

Please sign in to comment.