Skip to content

Test Symfony 7.3 #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: 1.4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
"phpstan/phpstan-strict-rules": "^1.5.1",
"phpunit/phpunit": "^8.5.29 || ^9.5",
"psr/container": "1.0 || 1.1.1",
"symfony/config": "^5.4 || ^6.1",
"symfony/console": "^5.4 || ^6.1",
"symfony/dependency-injection": "^5.4 || ^6.1",
"symfony/form": "^5.4 || ^6.1",
"symfony/framework-bundle": "^5.4 || ^6.1",
"symfony/http-foundation": "^5.4 || ^6.1",
"symfony/messenger": "^5.4",
"symfony/config": "^5.4 || ^6.1 || ^7.3",
"symfony/console": "^5.4 || ^6.1 || ^7.3",
"symfony/dependency-injection": "^5.4 || ^6.1 || ^7.3",
"symfony/form": "^5.4 || ^6.1 || ^7.3",
"symfony/framework-bundle": "^5.4 || ^6.1 || ^7.3",
"symfony/http-foundation": "^5.4 || ^6.1 || ^7.3",
"symfony/messenger": "^5.4 || ^6.4 || ^7.3",
"symfony/polyfill-php80": "^1.24",
"symfony/serializer": "^5.4",
"symfony/serializer": "^5.4 || ^6.4 || ^7.3",
"symfony/service-contracts": "^2.2.0"
},
"config": {
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/MessageMapFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use PHPStan\Reflection\ClassReflection;
use PHPStan\Reflection\ReflectionProvider;
use Symfony\Component\Messenger\Handler\MessageSubscriberInterface;
use function class_exists;
use function count;
use function is_array;
Expand Down Expand Up @@ -91,7 +90,7 @@ public function create(): MessageMap
/** @return iterable<string, array<string, string>> */
private function guessHandledMessages(ClassReflection $reflectionClass): iterable
{
if ($reflectionClass->implementsInterface(MessageSubscriberInterface::class)) {
if ($reflectionClass->implementsInterface('Symfony\\Component\\Messenger\\Handler\\MessageSubscriberInterface')) {
$className = $reflectionClass->getName();

foreach ($className::getHandledMessages() as $index => $value) {
Expand Down
6 changes: 6 additions & 0 deletions tests/Type/Symfony/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace PHPStan\Type\Symfony;

use PHPStan\Testing\TypeInferenceTestCase;
use ReflectionClass;
use ReflectionMethod;
use Symfony\Component\HttpFoundation\Request;
use function class_exists;
Expand Down Expand Up @@ -46,6 +47,11 @@ public function dataFileAsserts(): iterable

if (class_exists('Symfony\Bundle\FrameworkBundle\Controller\AbstractController')) {
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleAbstractController.php');

$ref = new ReflectionClass('Symfony\Bundle\FrameworkBundle\Controller\AbstractController');
if ($ref->hasMethod('get')) {
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleAbstractControllerServices.php');
}
}

yield from $this->gatherAssertTypes(__DIR__ . '/data/serializer.php');
Expand Down
17 changes: 0 additions & 17 deletions tests/Type/Symfony/data/ExampleAbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,6 @@
final class ExampleAbstractController extends AbstractController
{

public function services(): void
{
assertType('Foo', $this->get('foo'));
assertType('Foo', $this->get('parameterised_foo'));
assertType('Foo\Bar', $this->get('parameterised_bar'));
assertType('Synthetic', $this->get('synthetic'));
assertType('object', $this->get('bar'));
assertType('object', $this->get(doFoo()));
assertType('object', $this->get());

assertType('true', $this->has('foo'));
assertType('true', $this->has('synthetic'));
assertType('false', $this->has('bar'));
assertType('bool', $this->has(doFoo()));
assertType('bool', $this->has());
}

public function parameters(ContainerInterface $container, ParameterBagInterface $parameterBag): void
{
assertType('array|bool|float|int|string|null', $container->getParameter('unknown'));
Expand Down
28 changes: 28 additions & 0 deletions tests/Type/Symfony/data/ExampleAbstractControllerServices.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php declare(strict_types = 1);

namespace PHPStan\Type\Symfony;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use function PHPStan\Testing\assertType;

final class ExampleAbstractControllerServices extends AbstractController
{

public function services(): void
{
assertType('Foo', $this->get('foo'));
assertType('Foo', $this->get('parameterised_foo'));
assertType('Foo\Bar', $this->get('parameterised_bar'));
assertType('Synthetic', $this->get('synthetic'));
assertType('object', $this->get('bar'));
assertType('object', $this->get(doFoo()));
assertType('object', $this->get());

assertType('true', $this->has('foo'));
assertType('true', $this->has('synthetic'));
assertType('false', $this->has('bar'));
assertType('bool', $this->has(doFoo()));
assertType('bool', $this->has());
}

}
115 changes: 0 additions & 115 deletions tests/Type/Symfony/data/ExampleAbstractControllerWithoutContainer.php

This file was deleted.

115 changes: 0 additions & 115 deletions tests/Type/Symfony/data/ExampleControllerWithoutContainer.php

This file was deleted.

Loading