Skip to content

Commit 4c370af

Browse files
committed
Fix PhpStorm inspections
1 parent 9642833 commit 4c370af

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

src/Attribute/Filter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace GraphQL\Doctrine\Attribute;
66

77
use Attribute;
8+
use GraphQL\Doctrine\Definition\Operator\AbstractOperator;
89

910
/**
1011
* Attribute used to define custom filter.
@@ -17,7 +18,7 @@ final class Filter implements ApiAttribute
1718
*
1819
* The field may or may not actually exist in the entity. It is merely used
1920
* to organize the filter correctly in the API.
20-
* @param string $operator key referring to the type instance of PHP class implementing the GraphQL type
21+
* @param class-string<AbstractOperator> $operator FQCN to the PHP class implementing the GraphQL operator
2122
* @param string $type GraphQL leaf type name of the type of the field
2223
*/
2324
public function __construct(

src/Definition/EntityIDType.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function serialize($value): string
4747
/**
4848
* Parses an externally provided value (query variable) to use as an input.
4949
*/
50-
public function parseValue(mixed $value, ?array $variables = null): EntityID
50+
public function parseValue(mixed $value): EntityID
5151
{
5252
if (!is_string($value) && !is_int($value)) {
5353
throw new Error('EntityID cannot represent value: ' . \GraphQL\Utils\Utils::printSafe($value));
@@ -58,10 +58,8 @@ public function parseValue(mixed $value, ?array $variables = null): EntityID
5858

5959
/**
6060
* Parses an externally provided literal value (hardcoded in GraphQL query) to use as an input.
61-
*
62-
* @param Node $valueNode
6361
*/
64-
public function parseLiteral($valueNode, ?array $variables = null): EntityID
62+
public function parseLiteral(Node $valueNode, ?array $variables = null): EntityID
6563
{
6664
if ($valueNode instanceof StringValueNode || $valueNode instanceof IntValueNode) {
6765
return $this->createEntityID((string) $valueNode->value);

src/Factory/Type/FilterGroupConditionTypeFactory.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ public function create(string $className, string $typeName): Type
9090
foreach ($customOperators as $customOperator) {
9191
/** @var LeafType $leafType */
9292
$leafType = $this->types->get($customOperator->type);
93-
/** @var class-string $operator */
9493
$operator = $customOperator->operator;
9594
$operators[$operator] = $leafType;
9695
}
@@ -176,7 +175,7 @@ private function readCustomOperatorsFromAttribute(ReflectionClass $class): void
176175
/**
177176
* Get configuration for field.
178177
*
179-
* @param array<class-string, LeafType> $operators
178+
* @param array<class-string<AbstractOperator>, LeafType> $operators
180179
*/
181180
private function getFieldConfiguration(string $typeName, string $fieldName, array $operators): array
182181
{
@@ -189,7 +188,7 @@ private function getFieldConfiguration(string $typeName, string $fieldName, arra
189188
/**
190189
* Return a map of operator class name and their leaf type, including custom operator for the given fieldName.
191190
*
192-
* @return array<class-string, LeafType> indexed by operator class name
191+
* @return array<class-string<AbstractOperator>, LeafType> indexed by operator class name
193192
*/
194193
private function getOperators(string $fieldName, LeafType $leafType, bool $isAssociation, bool $isCollection): array
195194
{
@@ -231,7 +230,6 @@ private function getOperators(string $fieldName, LeafType $leafType, bool $isAss
231230
foreach ($this->customOperators[$fieldName] as $filter) {
232231
/** @var LeafType $leafType */
233232
$leafType = $this->types->get($filter->type);
234-
/** @var class-string $operator */
235233
$operator = $filter->operator;
236234
$operators[$operator] = $leafType;
237235
}
@@ -245,7 +243,7 @@ private function getOperators(string $fieldName, LeafType $leafType, bool $isAss
245243
/**
246244
* Get the type for a specific field.
247245
*
248-
* @param array<class-string, LeafType> $operators
246+
* @param array<class-string<AbstractOperator>, LeafType> $operators
249247
*/
250248
private function getFieldType(string $typeName, string $fieldName, array $operators): InputObjectType
251249
{
@@ -263,7 +261,7 @@ private function getFieldType(string $typeName, string $fieldName, array $operat
263261
/**
264262
* Get operators configuration for a specific leaf type.
265263
*
266-
* @param array<class-string, LeafType> $operators
264+
* @param array<class-string<AbstractOperator>, LeafType> $operators
267265
*/
268266
private function getOperatorConfiguration(array $operators): array
269267
{

src/Types.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public function getId(string $className): EntityIDType
215215
*
216216
* This is for internal use only.
217217
*
218-
* @param class-string $className the class name of an operator (`EqualOperatorType::class`)
218+
* @param class-string<AbstractOperator> $className the class name of an operator (`EqualOperatorType::class`)
219219
*/
220220
public function getOperator(string $className, LeafType $type): AbstractOperator
221221
{

tests/Blog/Model/Special/InvalidFilter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use GraphQLTests\Doctrine\Blog\Model\AbstractModel;
1010

1111
#[ORM\Entity]
12+
/** @phpstan-ignore-next-line */
1213
#[API\Filter(field: 'custom', operator: 'invalid_class_name', type: 'string')]
1314
final class InvalidFilter extends AbstractModel
1415
{

tests/Blog/Types/DateTimeType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function parseLiteral($valueNode, ?array $variables = null)
2424
return $valueNode->value;
2525
}
2626

27-
public function parseValue($value, ?array $variables = null)
27+
public function parseValue(mixed $value): DateTimeImmutable
2828
{
2929
if (!is_string($value)) {
3030
throw new UnexpectedValueException('Cannot represent value as DateTime date: ' . Utils::printSafe($value));
@@ -33,7 +33,7 @@ public function parseValue($value, ?array $variables = null)
3333
return new DateTimeImmutable($value);
3434
}
3535

36-
public function serialize($value)
36+
public function serialize(mixed $value): mixed
3737
{
3838
if ($value instanceof DateTimeImmutable) {
3939
return $value->format('c');

tests/EntityManagerTrait.php

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

55
namespace GraphQLTests\Doctrine;
66

7+
use Doctrine\DBAL\DriverManager;
78
use Doctrine\ORM\EntityManager;
8-
use Doctrine\ORM\Tools\Setup;
9+
use Doctrine\ORM\ORMSetup;
910

1011
/**
1112
* Trait to easily set up a dummy entity manager.
@@ -16,8 +17,9 @@ trait EntityManagerTrait
1617

1718
private function setUpEntityManager(): void
1819
{
19-
$config = Setup::createAttributeMetadataConfiguration([__DIR__ . '/Blog/Model'], true);
20-
$conn = ['url' => 'sqlite:///:memory:'];
21-
$this->entityManager = EntityManager::create($conn, $config);
20+
$config = ORMSetup::createAttributeMetadataConfiguration([__DIR__ . '/Blog/Model'], true);
21+
$connection = DriverManager::getConnection(['url' => 'sqlite:///:memory:']);
22+
23+
$this->entityManager = new EntityManager($connection, $config);
2224
}
2325
}

0 commit comments

Comments
 (0)