Skip to content

Commit 188c0e0

Browse files
committed
Fix few warnings as found by PhpStorm
1 parent e0da03f commit 188c0e0

16 files changed

+39
-30
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
A library to declare GraphQL types from Doctrine entities, PHP 7.1 type hinting,
1212
and annotations, and to be used with [webonyx/graphql-php](https://github.com/webonyx/graphql-php).
1313

14-
It reads most informations from type hints, complete some things from existing
14+
It reads most information from type hints, complete some things from existing
1515
Doctrine annotations and allow further customizations with specialized annotations.
1616
It will then create [`ObjectType`](https://webonyx.github.io/graphql-php/type-system/object-types/#object-type-definition) and
1717
[`InputObjectType`](https://webonyx.github.io/graphql-php/type-system/input-types/#input-object-type)

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"check": [
77
"php-cs-fixer fix --ansi --dry-run --diff",
88
"phpunit --color=always"
9+
],
10+
"fix": [
11+
"php-cs-fixer fix --ansi"
912
]
1013
},
1114
"autoload": {

src/Definition/EntityID.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public function __construct(EntityManager $entityManager, string $className, ?st
4141
/**
4242
* Get the entity from DB
4343
*
44+
* @throws Error
45+
*
4446
* @return mixed entity
4547
*/
4648
public function getEntity()

src/Definition/EntityIDType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ public function parseLiteral($valueNode)
8080
/**
8181
* Create EntityID to retrieve entity from DB later on
8282
*
83+
* @param string $id
84+
*
8385
* @return mixed entity
8486
*/
8587
private function createEntityID(string $id)

src/Factory/AbstractFieldsConfigurationFactory.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ protected function getTypeFromReturnTypeHint(ReflectionMethod $method, string $f
228228
return $type;
229229
}
230230

231-
return $this->refelectionTypeToType($returnType);
231+
return $this->reflectionTypeToType($returnType);
232232
}
233233

234234
/**
@@ -239,7 +239,7 @@ protected function getTypeFromReturnTypeHint(ReflectionMethod $method, string $f
239239
*
240240
* @return Type
241241
*/
242-
protected function refelectionTypeToType(ReflectionType $reflectionType, bool $isEntityId = false): Type
242+
protected function reflectionTypeToType(ReflectionType $reflectionType, bool $isEntityId = false): Type
243243
{
244244
$type = $this->getTypeFromRegistry((string) $reflectionType, $isEntityId);
245245
if (!$reflectionType->allowsNull()) {
@@ -287,7 +287,7 @@ protected function getMethodFullName(ReflectionMethod $method): string
287287
protected function throwIfArray(ReflectionParameter $param, ?string $type): void
288288
{
289289
if ($type === 'array') {
290-
throw new Exception('The parameter `$' . $param->getName() . '` on method ' . $this->getMethodFullName($param->getDeclaringFunction()) . ' is type hinted as `array` and is not overriden via `@API\Argument` annotation. Either change the type hint or specify the type with `@API\Argument` annotation.');
290+
throw new Exception('The parameter `$' . $param->getName() . '` on method ' . $this->getMethodFullName($param->getDeclaringFunction()) . ' is type hinted as `array` and is not overridden via `@API\Argument` annotation. Either change the type hint or specify the type with `@API\Argument` annotation.');
291291
}
292292
}
293293

@@ -319,13 +319,13 @@ private function getTargetEntity(string $fieldName): ?string
319319
* Returns a type from our registry
320320
*
321321
* @param string $type
322-
* @param bool $isEntityid
322+
* @param bool $isEntityId
323323
*
324324
* @return Type
325325
*/
326-
private function getTypeFromRegistry(string $type, bool $isEntityid): Type
326+
private function getTypeFromRegistry(string $type, bool $isEntityId): Type
327327
{
328-
if (!$this->types->isEntity($type) || !$isEntityid) {
328+
if (!$this->types->isEntity($type) || !$isEntityId) {
329329
return $this->types->get($type);
330330
}
331331

@@ -354,6 +354,7 @@ protected function nonNullIfHasDefault(ReflectionParameter $param, ?Type $type):
354354
*
355355
* @param ReflectionParameter $param
356356
* @param Type $type
357+
* @param string $annotation
357358
*
358359
* @throws Exception
359360
*/

src/Factory/AbstractTypeFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(Types $types, EntityManager $entityManager)
3434
*
3535
* @param string $className class name of Doctrine entity
3636
*
37-
* @return ObjectType
37+
* @return Type
3838
*/
3939
abstract public function create(string $className): Type;
4040

src/Factory/InputFieldsConfigurationFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private function completeField(ReflectionMethod $method, ReflectionParameter $pa
9292
$type = $param->getType();
9393
if (!$field->type && $type) {
9494
$this->throwIfArray($param, (string) $type);
95-
$field->type = $this->refelectionTypeToType($type, true);
95+
$field->type = $this->reflectionTypeToType($type, true);
9696
}
9797

9898
$field->type = $this->nonNullIfHasDefault($param, $field->type);

src/Factory/OutputFieldsConfigurationFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ private function completeField(ReflectionMethod $method, Field $field): void
107107
*
108108
* @param ReflectionMethod $method
109109
* @param Argument[] $argsFromAnnotations
110+
* @param DocBlockReader $docBlock
110111
*
111112
* @throws Exception
112113
*
@@ -161,7 +162,7 @@ private function completeArgumentFromTypeHint(ReflectionMethod $method, Reflecti
161162
$type = $param->getType();
162163
if (!$arg->type && $type) {
163164
$this->throwIfArray($param, (string) $type);
164-
$arg->type = $this->refelectionTypeToType($type, true);
165+
$arg->type = $this->reflectionTypeToType($type, true);
165166
}
166167

167168
$arg->type = $this->nonNullIfHasDefault($param, $arg->type);

src/Types.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ private function createInstance(string $className): Type
160160
/**
161161
* Checks if a className is a valid doctrine entity
162162
*
163+
* @param string $className
164+
*
163165
* @return bool
164166
*/
165167
public function isEntity(string $className): bool

tests/Blog/Model/Post.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Post extends AbstractModel
4040
private $publicationDate;
4141

4242
/**
43-
* @var bool
43+
* @var string
4444
*
4545
* @ORM\Column(type="string", options={"default" = Post::STATUS_PRIVATE})
4646
*/
@@ -57,8 +57,6 @@ class Post extends AbstractModel
5757
* Set title
5858
*
5959
* @param string $title
60-
*
61-
* @return User
6260
*/
6361
public function setTitle(string $title): void
6462
{
@@ -79,8 +77,6 @@ public function getTitle(): string
7977
* Set the body
8078
*
8179
* @param string $body
82-
*
83-
* @return User
8480
*/
8581
public function setBody(string $body): void
8682
{
@@ -105,8 +101,6 @@ public function getBody(): string
105101
* @API\Input(type="GraphQLTests\Doctrine\Blog\Types\PostStatusType")
106102
*
107103
* @param string $status
108-
*
109-
* @return User
110104
*/
111105
public function setStatus(string $status = self::STATUS_PUBLIC): void
112106
{

0 commit comments

Comments
 (0)