Skip to content

Commit bf6444f

Browse files
committed
Fixing phpstan issues.
1 parent a6a6233 commit bf6444f

File tree

6 files changed

+7
-15
lines changed

6 files changed

+7
-15
lines changed

src/EventSubscriber/ApqSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function onBeforeOperation(OperationEvent $event): void {
6565
/**
6666
* {@inheritdoc}
6767
*/
68-
public static function getSubscribedEvents() {
68+
public static function getSubscribedEvents(): array {
6969
return [
7070
OperationEvent::GRAPHQL_OPERATION_BEFORE => 'onBeforeOperation',
7171
];

src/EventSubscriber/OperationSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function onAfterOperation(OperationEvent $event): void {
7373
/**
7474
* {@inheritdoc}
7575
*/
76-
public static function getSubscribedEvents() {
76+
public static function getSubscribedEvents(): array {
7777
return [
7878
OperationEvent::GRAPHQL_OPERATION_BEFORE => 'onBeforeOperation',
7979
OperationEvent::GRAPHQL_OPERATION_AFTER => 'onAfterOperation',

src/GraphQL/Response/ResponseInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace Drupal\graphql\GraphQL\Response;
66

7+
use Symfony\Component\Validator\ConstraintViolationListInterface;
8+
79
/**
810
* Response interface used for GraphQL responses.
911
*/

src/GraphQL/Utility/FileUpload.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,9 @@ protected function prepareFilename(string $filename, array &$validators): string
520520
/** @var \Drupal\file\FileInterface $file */
521521
$file = $this->fileStorage->create([]);
522522
$file->setFilename($filename);
523-
$passes_validation = empty($this->fileValidator->validate($file, $validators['FileExtension']['extensions']));
523+
$passes_validation = count($this->fileValidator->validate($file, $validators['FileExtension']['extensions']));
524524
}
525-
if (empty($validators['FileExtension']['extensions']) || $passes_validation) {
525+
if (empty($validators['FileExtension']['extensions']) || ($passes_validation > 0)) {
526526
if ((substr($filename, -4) != '.txt')) {
527527
// The destination filename will also later be used to create the
528528
// URI.

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

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

101-
// @phpstan-ignore-next-line
102101
$width = $entity->width;
103-
// @phpstan-ignore-next-line
104102
$height = $entity->height;
105-
106-
if (empty($width) || empty($height)) {
103+
if (!isset($width) || !isset($height)) {
107104
/** @var \Drupal\Core\Image\ImageInterface $image */
108105
$image = \Drupal::service('image.factory')->get($entity->getFileUri());
109106
if ($image->isValid()) {

tests/src/Kernel/Framework/UploadFileServiceTest.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ class UploadFileServiceTest extends GraphQLTestBase {
2222
*/
2323
protected $uploadService;
2424

25-
/**
26-
* Modules to enable.
27-
*
28-
* @var array
29-
*/
30-
protected static $modules = ['file'];
31-
3225
/**
3326
* Gets the file path of the source file.
3427
*

0 commit comments

Comments
 (0)