Skip to content

Commit 710cc63

Browse files
committed
Fix tests
1 parent 2313443 commit 710cc63

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
"phpstan/phpstan-strict-rules": "^0.12",
3939
"slevomat/coding-standard": "^4.5.2",
4040
"phpstan/phpstan-phpunit": "^0.12",
41-
"symfony/framework-bundle": "^3.0 || ^4.0",
41+
"symfony/framework-bundle": "^4.0",
4242
"squizlabs/php_codesniffer": "^3.3.2",
43-
"symfony/serializer": "^3.0 || ^4.0",
43+
"symfony/serializer": "^4.0",
4444
"symfony/messenger": "^4.2",
45-
"symfony/console": "^3.0 || ^4.0",
46-
"symfony/http-foundation": "^3.0 || ^4.0"
45+
"symfony/console": "^4.0",
46+
"symfony/http-foundation": "^4.0"
4747
},
4848
"conflict": {
4949
"symfony/framework-bundle": "<3.0"

tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleTest.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,6 @@ public function testGetPrivateService(): void
3232
);
3333
}
3434

35-
public function testGetPrivateServiceInAbstractController(): void
36-
{
37-
$this->analyse(
38-
[
39-
__DIR__ . '/ExampleAbstractController.php',
40-
],
41-
[
42-
[
43-
'Service "private" is private.',
44-
12,
45-
],
46-
]
47-
);
48-
}
49-
5035
public function testGetPrivateServiceInLegacyServiceSubscriber(): void
5136
{
5237
if (!interface_exists('Symfony\\Component\\DependencyInjection\\ServiceSubscriberInterface')) {

tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PHPStan\Symfony\XmlServiceMapFactory;
88
use PHPStan\Testing\RuleTestCase;
99
use PHPStan\Type\Symfony\ServiceTypeSpecifyingExtension;
10+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1011
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
1112

1213
/**
@@ -27,6 +28,7 @@ protected function getMethodTypeSpecifyingExtensions(): array
2728
{
2829
return [
2930
new ServiceTypeSpecifyingExtension(Controller::class, new Standard()),
31+
new ServiceTypeSpecifyingExtension(AbstractController::class, new Standard()),
3032
];
3133
}
3234

tests/Symfony/NeonTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public function testExtensionNeon(): void
3030
], $parameters['symfony']);
3131

3232
self::assertCount(6, $container->getServicesByTag('phpstan.rules.rule'));
33-
self::assertCount(15, $container->getServicesByTag('phpstan.broker.dynamicMethodReturnTypeExtension'));
34-
self::assertCount(6, $container->getServicesByTag('phpstan.typeSpecifier.methodTypeSpecifyingExtension'));
33+
self::assertCount(16, $container->getServicesByTag('phpstan.broker.dynamicMethodReturnTypeExtension'));
34+
self::assertCount(7, $container->getServicesByTag('phpstan.typeSpecifier.methodTypeSpecifyingExtension'));
3535
self::assertInstanceOf(ServiceMap::class, $container->getByType(ServiceMap::class));
3636
}
3737

tests/Type/Symfony/RequestTypeSpecifyingExtensionTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
use PHPStan\Rules\Rule;
66
use PHPStan\Testing\RuleTestCase;
77
use PHPStan\Type\MethodTypeSpecifyingExtension;
8+
use ReflectionMethod;
9+
use Symfony\Component\HttpFoundation\Request;
810
use Symfony\Component\HttpFoundation\Session\SessionInterface;
11+
use function strpos;
912

1013
/**
1114
* @extends RuleTestCase<VariableTypeReportingRule>
@@ -28,9 +31,17 @@ protected function getMethodTypeSpecifyingExtensions(): array
2831

2932
public function testGetSession(): void
3033
{
34+
$ref = new ReflectionMethod(Request::class, 'getSession');
35+
$doc = (string) $ref->getDocComment();
36+
37+
$checkedTypeString = SessionInterface::class;
38+
if (strpos($doc, '@return SessionInterface|null') !== false) {
39+
$checkedTypeString .= '|null';
40+
}
41+
3142
$this->analyse([__DIR__ . '/request_get_session.php'], [
3243
[
33-
'Variable $session1 is: ' . SessionInterface::class . '|null',
44+
'Variable $session1 is: ' . $checkedTypeString,
3445
7,
3546
],
3647
[

0 commit comments

Comments
 (0)