Skip to content

Commit 330ff14

Browse files
committed
Upgrading code to PHPStan 0.12
1 parent 43279ca commit 330ff14

File tree

7 files changed

+22
-10
lines changed

7 files changed

+22
-10
lines changed

Controller/GraphQL/InvalidUserPasswordException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class InvalidUserPasswordException extends GraphQLException
1010
{
11-
public static function create(Exception $previous = null)
11+
public static function create(Exception $previous = null): self
1212
{
1313
return new self('The provided user / password is incorrect.', 401, $previous, 'Security');
1414
}

Controller/GraphqliteController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ private function handlePsr7Request(ServerRequestInterface $request, Request $sym
114114
if ($result instanceof Promise) {
115115
throw new RuntimeException('Only SyncPromiseAdapter is supported');
116116
}
117+
/* @phpstan-ignore-next-line */
117118
throw new RuntimeException('Unexpected response from StandardServer::executePsrRequest'); // @codeCoverageIgnore
118119
}
119120
}

DependencyInjection/GraphqliteCompilerPass.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace TheCodingMachine\Graphqlite\Bundle\DependencyInjection;
55

6+
use ReflectionNamedType;
67
use Symfony\Component\Cache\Adapter\ApcuAdapter;
78
use Symfony\Component\Cache\Adapter\PhpFilesAdapter;
89
use Symfony\Component\Cache\Psr16Cache;
@@ -85,7 +86,7 @@ class GraphqliteCompilerPass implements CompilerPassInterface
8586
/**
8687
* You can modify the container here before it is dumped to PHP code.
8788
*/
88-
public function process(ContainerBuilder $container)
89+
public function process(ContainerBuilder $container): void
8990
{
9091
$reader = $this->getAnnotationReader();
9192
//$inputTypeUtils = new InputTypeUtils($reader, $namingStrategy);
@@ -175,6 +176,9 @@ public function process(ContainerBuilder $container)
175176
if ($definition->isAbstract() || $definition->getClass() === null) {
176177
continue;
177178
}
179+
/**
180+
* @var class-string $class
181+
*/
178182
$class = $definition->getClass();
179183
/* foreach ($controllersNamespaces as $controllersNamespace) {
180184
if (strpos($class, $controllersNamespace) === 0) {
@@ -287,6 +291,9 @@ private function mapAdderToTag(string $tag, string $methodName, ContainerBuilder
287291
}
288292
}
289293

294+
/**
295+
* @param ReflectionClass<object> $refClass
296+
*/
290297
private function makePublicInjectedServices(ReflectionClass $refClass, AnnotationReader $reader, ContainerBuilder $container, bool $isController): void
291298
{
292299
$services = $this->getCodeCache()->get($refClass, function() use ($refClass, $reader, $container, $isController) {
@@ -349,7 +356,7 @@ private function getListOfInjectedServices(ReflectionMethod $method, ContainerBu
349356
} else {
350357
$parameter = $parametersByName[$target];
351358
$type = $parameter->getType();
352-
if ($type !== null) {
359+
if ($type !== null && $type instanceof ReflectionNamedType) {
353360
$fqcn = $type->getName();
354361
if ($container->has($fqcn)) {
355362
$services[$fqcn] = $fqcn;
@@ -427,7 +434,7 @@ private function getCodeCache(): ClassBoundCacheContractInterface
427434
* Returns the array of globbed classes.
428435
* Only instantiable classes are returned.
429436
*
430-
* @return array<string,ReflectionClass> Key: fully qualified class name
437+
* @return array<string,ReflectionClass<object>> Key: fully qualified class name
431438
*/
432439
private function getClassList(string $namespace, int $globTtl = 2, bool $recursive = true): array
433440
{

DependencyInjection/GraphqliteExtension.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ class GraphqliteExtension extends Extension
2727
/**
2828
* Loads a specific configuration.
2929
*
30-
* @throws \InvalidArgumentException When provided tag is not defined in this extension
30+
* @param mixed[] $configs
31+
* @throws \Exception
3132
*/
32-
public function load(array $configs, ContainerBuilder $container)
33+
public function load(array $configs, ContainerBuilder $container): void
3334
{
3435
$configuration = new Configuration();
3536
$config = $this->processConfiguration($configuration, $configs);
@@ -94,6 +95,10 @@ private function getNamespaceDir(string $namespace): string
9495
return substr($possibleFileNames[0], 0, -8);
9596
}
9697

98+
/**
99+
* @param array<string, int> $debug
100+
* @return int
101+
*/
97102
private function toDebugCode(array $debug): int
98103
{
99104
$code = 0;

DependencyInjection/OverblogGraphiQLEndpointWiringPass.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@
1313
final class OverblogGraphiQLEndpointWiringPass implements CompilerPassInterface
1414
{
1515
//@todo https://github.com/symfony/symfony/blob/master/src/Symfony/Component/DependencyInjection/Tests/Compiler/RemoveUnusedDefinitionsPassTest.php
16-
public function process(ContainerBuilder $container)
16+
public function process(ContainerBuilder $container): void
1717
{
1818
$endPointDefinition = new Definition(EndpointResolver::class);
1919
$endPointDefinition->addArgument(new Reference('request_stack'));
2020

2121
$container->setDefinition('overblog_graphiql.controller.graphql.endpoint', $endPointDefinition);
22-
2322
}
2423
}

GraphqliteBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class GraphqliteBundle extends Bundle
1313
{
14-
public function build(ContainerBuilder $container)
14+
public function build(ContainerBuilder $container): void
1515
{
1616
parent::build($container);
1717

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"symfony/security-bundle": "^4.1.9 | ^5",
3535
"symfony/yaml": "^4.1.9 | ^5",
3636
"phpunit/phpunit": "^7.5.1",
37-
"phpstan/phpstan-shim": "^0.11.19",
37+
"phpstan/phpstan": "^0.12.25",
3838
"beberlei/porpaginas": "^1.2",
3939
"php-coveralls/php-coveralls": "^2.1.0"
4040
},

0 commit comments

Comments
 (0)