Skip to content

Commit 5181d8c

Browse files
committed
Fix build
1 parent fd9a06f commit 5181d8c

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

tests/Type/Symfony/ExtensionTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
namespace PHPStan\Type\Symfony;
44

55
use PHPStan\Testing\TypeInferenceTestCase;
6+
use ReflectionClass;
67
use ReflectionMethod;
78
use Symfony\Component\HttpFoundation\Request;
89
use function class_exists;
10+
use function method_exists;
911
use function strpos;
1012

1113
class ExtensionTest extends TypeInferenceTestCase
@@ -46,6 +48,11 @@ public function dataFileAsserts(): iterable
4648

4749
if (class_exists('Symfony\Bundle\FrameworkBundle\Controller\AbstractController')) {
4850
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleAbstractController.php');
51+
52+
$ref = new ReflectionClass('Symfony\Bundle\FrameworkBundle\Controller\AbstractController');
53+
if ($ref->hasMethod('get')) {
54+
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleAbstractControllerServices.php');
55+
}
4956
}
5057

5158
yield from $this->gatherAssertTypes(__DIR__ . '/data/serializer.php');

tests/Type/Symfony/data/ExampleAbstractController.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,6 @@
1010
final class ExampleAbstractController extends AbstractController
1111
{
1212

13-
public function services(): void
14-
{
15-
assertType('Foo', $this->get('foo'));
16-
assertType('Foo', $this->get('parameterised_foo'));
17-
assertType('Foo\Bar', $this->get('parameterised_bar'));
18-
assertType('Synthetic', $this->get('synthetic'));
19-
assertType('object', $this->get('bar'));
20-
assertType('object', $this->get(doFoo()));
21-
assertType('object', $this->get());
22-
23-
assertType('true', $this->has('foo'));
24-
assertType('true', $this->has('synthetic'));
25-
assertType('false', $this->has('bar'));
26-
assertType('bool', $this->has(doFoo()));
27-
assertType('bool', $this->has());
28-
}
29-
3013
public function parameters(ContainerInterface $container, ParameterBagInterface $parameterBag): void
3114
{
3215
assertType('array|bool|float|int|string|null', $container->getParameter('unknown'));
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Type\Symfony;
4+
5+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
6+
use function PHPStan\Testing\assertType;
7+
8+
final class ExampleAbstractControllerServices extends AbstractController
9+
{
10+
11+
public function services(): void
12+
{
13+
assertType('Foo', $this->get('foo'));
14+
assertType('Foo', $this->get('parameterised_foo'));
15+
assertType('Foo\Bar', $this->get('parameterised_bar'));
16+
assertType('Synthetic', $this->get('synthetic'));
17+
assertType('object', $this->get('bar'));
18+
assertType('object', $this->get(doFoo()));
19+
assertType('object', $this->get());
20+
21+
assertType('true', $this->has('foo'));
22+
assertType('true', $this->has('synthetic'));
23+
assertType('false', $this->has('bar'));
24+
assertType('bool', $this->has(doFoo()));
25+
assertType('bool', $this->has());
26+
}
27+
28+
}

0 commit comments

Comments
 (0)