Skip to content

Commit 515f86f

Browse files
committed
Fix PHPStan errors
1 parent 47fd027 commit 515f86f

File tree

8 files changed

+46
-264
lines changed

8 files changed

+46
-264
lines changed

phpstan-baseline.neon

+24-244
Large diffs are not rendered by default.

src/Definition/Resolver/AliasedInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface AliasedInterface
1212
* For instance:
1313
* array('myMethod' => 'myAlias')
1414
*
15-
* @return array<string,string>
15+
* @return array<string|int,string>
1616
*/
1717
public static function getAliases(): array;
1818
}

src/Error/UserErrors.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Overblog\GraphQLBundle\Error;
66

77
use Exception;
8+
use GraphQL\Error\UserError as WebonyxUserError;
89
use InvalidArgumentException;
910
use RuntimeException;
1011
use function is_object;
@@ -13,9 +14,12 @@
1314

1415
class UserErrors extends RuntimeException
1516
{
16-
/** @var UserError[] */
17+
/** @var WebonyxUserError[] */
1718
private array $errors = [];
1819

20+
/**
21+
* @param array<WebonyxUserError|string> $errors
22+
*/
1923
public function __construct(
2024
array $errors,
2125
string $message = '',
@@ -27,7 +31,7 @@ public function __construct(
2731
}
2832

2933
/**
30-
* @param UserError[]|string[] $errors
34+
* @param WebonyxUserError[]|string[] $errors
3135
*/
3236
public function setErrors(array $errors): void
3337
{
@@ -37,14 +41,14 @@ public function setErrors(array $errors): void
3741
}
3842

3943
/**
40-
* @param string|\GraphQL\Error\UserError $error
44+
* @param string|WebonyxUserError $error
4145
*/
4246
public function addError($error): self
4347
{
4448
if (is_string($error)) {
4549
$error = new UserError($error);
46-
} elseif (!is_object($error) || !$error instanceof \GraphQL\Error\UserError) {
47-
throw new InvalidArgumentException(sprintf('Error must be string or instance of %s.', \GraphQL\Error\UserError::class));
50+
} elseif (!is_object($error) || !$error instanceof WebonyxUserError) {
51+
throw new InvalidArgumentException(sprintf('Error must be string or instance of %s.', WebonyxUserError::class));
4852
}
4953

5054
$this->errors[] = $error;
@@ -53,7 +57,7 @@ public function addError($error): self
5357
}
5458

5559
/**
56-
* @return UserError[]
60+
* @return WebonyxUserError[]
5761
*/
5862
public function getErrors(): array
5963
{

src/Generator/ConfigBuilder/FieldsBuilder.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use GraphQL\Type\Definition\Type;
1111
use Murtukov\PHPCodeGenerator\ArrowFunction;
1212
use Murtukov\PHPCodeGenerator\Closure;
13-
use Murtukov\PHPCodeGenerator\Collection as MurtucovCollection;
1413
use Murtukov\PHPCodeGenerator\GeneratorInterface;
1514
use Murtukov\PHPCodeGenerator\Literal;
1615
use Murtukov\PHPCodeGenerator\PhpFile;
@@ -24,6 +23,9 @@
2423
use Overblog\GraphQLBundle\Generator\ResolveInstructionBuilder;
2524
use Overblog\GraphQLBundle\Generator\TypeGenerator;
2625
use Overblog\GraphQLBundle\Generator\ValidationRulesBuilder;
26+
use function array_key_exists;
27+
use function in_array;
28+
use function is_string;
2729

2830
class FieldsBuilder implements ConfigBuilderInterface
2931
{
@@ -71,15 +73,13 @@ public function build(TypeConfig $typeConfig, Collection $builder, PhpFile $phpF
7173
* 'resolve' => {@see \Overblog\GraphQLBundle\Generator\ResolveInstructionBuilder::build()},
7274
* 'complexity' => {@see buildComplexity},
7375
* ]
74-
* </code>
75-
*
76-
* @return GeneratorInterface|Collection|string
76+
* </code>.
7777
*
7878
* @throws GeneratorException
7979
*
8080
* @internal
8181
*/
82-
protected function buildField(FieldConfig $fieldConfig, TypeConfig $typeConfig, PhpFile $phpFile): MurtucovCollection
82+
protected function buildField(FieldConfig $fieldConfig, TypeConfig $typeConfig, PhpFile $phpFile): Collection
8383
{
8484
// TODO(any): modify `InputValidator` and `TypeDecoratorListener` to support it before re-enabling this
8585
// see https://github.com/overblog/GraphQLBundle/issues/973
@@ -179,7 +179,7 @@ protected function buildAccess($access)
179179
* 'description' => 'Some fancy description.',
180180
* 'defaultValue' => 'admin',
181181
* ]
182-
* </code>
182+
* </code>.
183183
*
184184
* @throws GeneratorException
185185
*

src/Validator/Mapping/ObjectMetadata.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ public function __construct(ValidationNode $object)
1717
}
1818

1919
/**
20-
* @param string $property
21-
*
2220
* @return $this|ObjectMetadata
2321
*/
24-
public function addPropertyConstraint($property, Constraint $constraint): self
22+
public function addPropertyConstraint(string $property, Constraint $constraint): self
2523
{
2624
if (!isset($this->properties[$property])) {
2725
$this->properties[$property] = new PropertyMetadata($property);

tests/Config/Parser/TestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
abstract class TestCase extends WebTestCase
1414
{
15-
/** @var ContainerBuilder|MockObject */
15+
/** @var ContainerBuilder & MockObject */
1616
protected $containerBuilder;
1717

1818
public function setUp(): void

tests/DependencyInjection/Compiler/GraphQLServicesPassTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class GraphQLServicesPassTest extends TestCase
2020
*/
2121
public function testInvalidAlias($invalidAlias): void
2222
{
23-
/** @var ContainerBuilder|MockObject $container */
23+
/** @var ContainerBuilder & MockObject $container */
2424
$container = $this->getMockBuilder(ContainerBuilder::class)
2525
->onlyMethods(['findTaggedServiceIds', 'findDefinition'])
2626
->getMock();

tests/EventListener/TypeDecoratorListenerTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,9 @@ private function decorate(array $types, array $map): void
285285
}
286286

287287
/**
288-
* @return \PHPUnit\Framework\MockObject\MockObject|ResolverMap
288+
* @return \PHPUnit\Framework\MockObject\MockObject & ResolverMap
289289
*/
290-
private function createResolverMapMock(array $map = [])
290+
private function createResolverMapMock(array $map = []): ResolverMap
291291
{
292292
$resolverMap = $this->getMockBuilder(ResolverMap::class)->setMethods(['map'])->getMock();
293293
$resolverMap->expects($this->any())->method('map')->willReturn($map);

0 commit comments

Comments
 (0)