Skip to content

Commit

Permalink
Fixing phpstan issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
apathak18 committed Jul 25, 2024
1 parent a6a6233 commit bf6444f
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/EventSubscriber/ApqSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function onBeforeOperation(OperationEvent $event): void {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
return [
OperationEvent::GRAPHQL_OPERATION_BEFORE => 'onBeforeOperation',
];
Expand Down
2 changes: 1 addition & 1 deletion src/EventSubscriber/OperationSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function onAfterOperation(OperationEvent $event): void {
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
public static function getSubscribedEvents(): array {
return [
OperationEvent::GRAPHQL_OPERATION_BEFORE => 'onBeforeOperation',
OperationEvent::GRAPHQL_OPERATION_AFTER => 'onAfterOperation',
Expand Down
2 changes: 2 additions & 0 deletions src/GraphQL/Response/ResponseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Drupal\graphql\GraphQL\Response;

use Symfony\Component\Validator\ConstraintViolationListInterface;

/**
* Response interface used for GraphQL responses.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/GraphQL/Utility/FileUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,9 @@ protected function prepareFilename(string $filename, array &$validators): string
/** @var \Drupal\file\FileInterface $file */
$file = $this->fileStorage->create([]);
$file->setFilename($filename);
$passes_validation = empty($this->fileValidator->validate($file, $validators['FileExtension']['extensions']));
$passes_validation = count($this->fileValidator->validate($file, $validators['FileExtension']['extensions']));
}
if (empty($validators['FileExtension']['extensions']) || $passes_validation) {
if (empty($validators['FileExtension']['extensions']) || ($passes_validation > 0)) {
if ((substr($filename, -4) != '.txt')) {
// The destination filename will also later be used to create the
// URI.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,9 @@ public function resolve(FileInterface $entity = NULL, $style, RefinableCacheable
$metadata->addCacheableDependency($access);
if ($access->isAllowed() && $image_style = ImageStyle::load($style)) {

// @phpstan-ignore-next-line
$width = $entity->width;

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::$width.
// @phpstan-ignore-next-line
$height = $entity->height;

Check failure on line 102 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 (empty($width) || empty($height)) {
if (!isset($width) || !isset($height)) {

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

View workflow job for this annotation

GitHub Actions / Drupal 10.3.x (PHP 8.3)

Result of || is always false.

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

View workflow job for this annotation

GitHub Actions / Drupal 10.3.x (PHP 8.3)

Variable $height in isset() always exists and is not nullable.

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

View workflow job for this annotation

GitHub Actions / Drupal 10.3.x (PHP 8.3)

Variable $width in isset() always exists and is not nullable.
/** @var \Drupal\Core\Image\ImageInterface $image */
$image = \Drupal::service('image.factory')->get($entity->getFileUri());
if ($image->isValid()) {
Expand Down
7 changes: 0 additions & 7 deletions tests/src/Kernel/Framework/UploadFileServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@ class UploadFileServiceTest extends GraphQLTestBase {
*/
protected $uploadService;

/**
* Modules to enable.
*
* @var array
*/
protected static $modules = ['file'];

/**
* Gets the file path of the source file.
*
Expand Down

0 comments on commit bf6444f

Please sign in to comment.