Skip to content

Commit a104b7f

Browse files
committed
Add support for Symfony 8
1 parent 9840ac0 commit a104b7f

File tree

11 files changed

+30
-70
lines changed

11 files changed

+30
-70
lines changed

composer.json

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,43 @@
2020
],
2121
"homepage": "https://docs.sonata-project.org/projects/SonataBlockBundle",
2222
"require": {
23-
"php": "^8.1",
23+
"php": "^8.2",
2424
"doctrine/collections": "^1.8 || ^2.0",
2525
"doctrine/common": "^3.0",
2626
"psr/container": "^1.0 || ^2.0",
2727
"psr/log": "^2.0 || ^3.0",
2828
"sonata-project/form-extensions": "^2.0",
29-
"symfony/asset": "^6.4 || ^7.1",
30-
"symfony/config": "^6.4 || ^7.1",
31-
"symfony/console": "^6.4 || ^7.1",
32-
"symfony/dependency-injection": "^6.4 || ^7.1",
33-
"symfony/event-dispatcher": "^6.4 || ^7.1",
29+
"symfony/asset": "^6.4 || ^7.3 || ^8.0",
30+
"symfony/config": "^6.4 || ^7.3 || ^8.0",
31+
"symfony/console": "^6.4 || ^7.3 || ^8.0",
32+
"symfony/dependency-injection": "^6.4 || ^7.3 || ^8.0",
33+
"symfony/event-dispatcher": "^6.4 || ^7.3 || ^8.0",
3434
"symfony/event-dispatcher-contracts": "^2.0 || ^3.0",
35-
"symfony/form": "^6.4 || ^7.1",
36-
"symfony/framework-bundle": "^6.4 || ^7.1",
37-
"symfony/http-foundation": "^6.4 || ^7.1",
38-
"symfony/http-kernel": "^6.4 || ^7.1",
39-
"symfony/options-resolver": "^6.4 || ^7.1",
40-
"symfony/twig-bundle": "^6.4 || ^7.1",
41-
"symfony/validator": "^6.4 || ^7.1",
35+
"symfony/form": "^6.4 || ^7.3 || ^8.0",
36+
"symfony/framework-bundle": "^6.4 || ^7.3 || ^8.0",
37+
"symfony/http-foundation": "^6.4 || ^7.3 || ^8.0",
38+
"symfony/http-kernel": "^6.4 || ^7.3 || ^8.0",
39+
"symfony/options-resolver": "^6.4 || ^7.3 || ^8.0",
40+
"symfony/twig-bundle": "^6.4 || ^7.3 || ^8.0",
41+
"symfony/validator": "^6.4 || ^7.3 || ^8.0",
4242
"twig/twig": "^3.0"
4343
},
4444
"require-dev": {
4545
"friendsofphp/php-cs-fixer": "^3.4",
4646
"knplabs/knp-menu": "^3.1",
4747
"knplabs/knp-menu-bundle": "^3.0",
4848
"matthiasnoback/symfony-config-test": "^6.1",
49-
"matthiasnoback/symfony-dependency-injection-test": "^6.1",
49+
"matthiasnoback/symfony-dependency-injection-test": "^6.2.0",
5050
"phpstan/extension-installer": "^1.0",
5151
"phpstan/phpstan": "^1.0 || ^2.0",
5252
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
5353
"phpstan/phpstan-strict-rules": "^1.0 || ^2.0",
5454
"phpstan/phpstan-symfony": "^1.0 || ^2.0",
55-
"phpunit/phpunit": "^10.5.54 || ^11.5.38 || ^12.3.10",
56-
"psalm/plugin-phpunit": "^0.18 || ^0.19",
57-
"psalm/plugin-symfony": "^5.0",
55+
"phpunit/phpunit": "^11.5.38 || ^12.3.10",
5856
"rector/rector": "^1.1 || ^2.0",
59-
"symfony/browser-kit": "^6.4 || ^7.1",
60-
"symfony/error-handler": "^6.4 || ^7.1",
61-
"symfony/stopwatch": "^6.4 || ^7.1",
62-
"vimeo/psalm": "^5.8 || ^6.10"
57+
"symfony/browser-kit": "^6.4 || ^7.3 || ^8.0",
58+
"symfony/error-handler": "^6.4 || ^7.3 || ^8.0",
59+
"symfony/stopwatch": "^6.4 || ^7.3 || ^8.0"
6360
},
6461
"conflict": {
6562
"knplabs/knp-menu-bundle": "<3.0"

psalm.xml

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ public function __construct(private array $defaultContainerTemplates)
3232
}
3333

3434
/**
35-
* @psalm-suppress UndefinedMethod
36-
*
37-
* @see https://github.com/psalm/psalm-plugin-symfony/issues/174
35+
* @return TreeBuilder<'array'>
3836
*/
3937
public function getConfigTreeBuilder(): TreeBuilder
4038
{

src/Exception/Strategy/StrategyManager.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ final class StrategyManager implements StrategyManagerInterface
3232
private ?string $defaultRenderer = null;
3333

3434
/**
35-
* @psalm-suppress ContainerDependency
36-
*
3735
* @param ContainerInterface $container Dependency injection container
3836
* @param array<string, string> $filters Filter definitions
3937
* @param array<string, string> $renderers Renderer definitions
@@ -88,7 +86,6 @@ public function handleException(\Throwable $exception, BlockInterface $block, ?R
8886

8987
// Convert throwable to exception
9088
if (!$exception instanceof \Exception) {
91-
/** @psalm-suppress PossiblyInvalidArgument */
9289
$exception = new \Exception($exception->getMessage(), $exception->getCode(), $exception);
9390
}
9491

@@ -106,8 +103,7 @@ public function handleException(\Throwable $exception, BlockInterface $block, ?R
106103
*/
107104
public function getBlockRenderer(BlockInterface $block): RendererInterface
108105
{
109-
$type = $block->getType();
110-
$name = $this->blockRenderers[$type] ?? $this->defaultRenderer;
106+
$name = $this->blockRenderers[(string) $block->getType()] ?? $this->defaultRenderer;
111107
if (null === $name) {
112108
throw new \RuntimeException('No default renderer was set.');
113109
}
@@ -132,8 +128,7 @@ public function getBlockRenderer(BlockInterface $block): RendererInterface
132128
*/
133129
public function getBlockFilter(BlockInterface $block): FilterInterface
134130
{
135-
$type = $block->getType();
136-
$name = $this->blockFilters[$type] ?? $this->defaultFilter;
131+
$name = $this->blockFilters[(string) $block->getType()] ?? $this->defaultFilter;
137132
if (null === $name) {
138133
throw new \RuntimeException('No default filter was set.');
139134
}

src/Form/Type/ContainerTemplateType.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
/**
2121
* @author Hugo Briand <briand@ekino.com>
22-
*
23-
* @psalm-suppress MissingTemplateParam https://github.com/phpstan/phpstan-symfony/issues/320
2422
*/
2523
final class ContainerTemplateType extends AbstractType
2624
{

src/Form/Type/ServiceListType.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
use Symfony\Component\OptionsResolver\Options;
2121
use Symfony\Component\OptionsResolver\OptionsResolver;
2222

23-
/**
24-
* @psalm-suppress MissingTemplateParam https://github.com/phpstan/phpstan-symfony/issues/320
25-
*/
2623
final class ServiceListType extends AbstractType
2724
{
2825
public function __construct(private BlockServiceManagerInterface $manager)

tests/App/AppKernel.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
use Symfony\Component\HttpKernel\Kernel;
2424
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
2525

26-
/**
27-
* @psalm-suppress PropertyNotSetInConstructor
28-
*
29-
* @see https://github.com/psalm/psalm-plugin-symfony/pull/220
30-
*/
3126
final class AppKernel extends Kernel
3227
{
3328
use MicroKernelTrait;

tests/App/Controller/DemoController.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,10 @@
1515

1616
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
1717
use Symfony\Component\HttpFoundation\Response;
18-
use Symfony\Component\Routing\Annotation\Route;
18+
use Symfony\Component\Routing\Attribute\Route;
1919

2020
final class DemoController extends AbstractController
2121
{
22-
/**
23-
* @Route("/", name="home")
24-
*/
2522
#[Route('/', name: 'home')]
2623
public function index(): Response
2724
{

tests/Command/DebugBlocksCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected function setUp(): void
4646
->method('getServices')
4747
->willReturn([]);
4848

49-
/** @phpstan-ignore function.impossibleType */
49+
/** @phpstan-ignore function.alreadyNarrowedType */
5050
$method = method_exists($this->application, 'addCommand') ? 'addCommand' : 'add';
5151
/* @phpstan-ignore method.notFound,method.dynamicName */
5252
$this->application->{$method}(new DebugBlocksCommand($blockManager));
@@ -113,7 +113,7 @@ public function getMetadata(): MetadataInterface
113113
},
114114
]);
115115

116-
/** @phpstan-ignore function.impossibleType */
116+
/** @phpstan-ignore function.alreadyNarrowedType */
117117
$method = method_exists($this->application, 'addCommand') ? 'addCommand' : 'add';
118118
/* @phpstan-ignore method.notFound,method.dynamicName */
119119
$this->application->{$method}(new DebugBlocksCommand($blockManager));

tests/Functional/FunctionalTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,17 @@
1717

1818
final class FunctionalTest extends WebTestCase
1919
{
20+
protected function tearDown(): void
21+
{
22+
parent::tearDown();
23+
restore_exception_handler();
24+
}
25+
2026
public function testRenderBlock(): void
2127
{
2228
$client = static::createClient();
2329
$client->request('GET', '/');
2430

2531
static::assertSame(200, $client->getResponse()->getStatusCode());
26-
27-
restore_exception_handler();
2832
}
2933
}

0 commit comments

Comments
 (0)