Skip to content

Commit 0b28aee

Browse files
authored
DevKit updates for 4.x branch (#1658)
1 parent ab8c8f2 commit 0b28aee

File tree

73 files changed

+298
-696
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+298
-696
lines changed

.github/workflows/lint.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
- name: Install PHP with extensions
5555
uses: shivammathur/setup-php@v2
5656
with:
57-
php-version: '8.1'
57+
php-version: '8.2'
5858
coverage: none
5959
tools: composer:v2, composer-normalize:2
6060
env:

.github/workflows/qa.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install PHP with extensions
3030
uses: shivammathur/setup-php@v2
3131
with:
32-
php-version: '8.1'
32+
php-version: '8.2'
3333
coverage: none
3434
tools: composer:v2
3535

@@ -54,7 +54,7 @@ jobs:
5454
- name: Install PHP with extensions
5555
uses: shivammathur/setup-php@v2
5656
with:
57-
php-version: '8.1'
57+
php-version: '8.2'
5858
coverage: none
5959
tools: composer:v2
6060

@@ -65,7 +65,7 @@ jobs:
6565
composer-options: --prefer-dist --prefer-stable
6666

6767
- name: Psalm
68-
run: vendor/bin/psalm --no-progress --show-info=false --stats --output-format=github --threads=$(nproc) --shepherd --php-version=8.1
68+
run: vendor/bin/psalm --no-progress --show-info=false --stats --output-format=github --threads=$(nproc) --shepherd --php-version=8.2
6969

7070
rector:
7171
name: Rector
@@ -79,7 +79,7 @@ jobs:
7979
- name: Install PHP with extensions
8080
uses: shivammathur/setup-php@v2
8181
with:
82-
php-version: '8.1'
82+
php-version: '8.2'
8383
coverage: none
8484
tools: composer:v2
8585

.github/workflows/symfony-lint.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Install PHP with extensions
3030
uses: shivammathur/setup-php@v2
3131
with:
32-
php-version: '8.1'
32+
php-version: '8.2'
3333
coverage: none
3434
tools: composer:v2
3535

@@ -54,7 +54,7 @@ jobs:
5454
- name: Install PHP with extensions
5555
uses: shivammathur/setup-php@v2
5656
with:
57-
php-version: '8.1'
57+
php-version: '8.2'
5858
coverage: none
5959
tools: composer:v2
6060

@@ -79,7 +79,7 @@ jobs:
7979
- name: Install PHP with extensions
8080
uses: shivammathur/setup-php@v2
8181
with:
82-
php-version: '8.1'
82+
php-version: '8.2'
8383
coverage: none
8484
tools: composer:v2
8585

@@ -104,7 +104,7 @@ jobs:
104104
- name: Install PHP with extensions
105105
uses: shivammathur/setup-php@v2
106106
with:
107-
php-version: '8.1'
107+
php-version: '8.2'
108108
coverage: none
109109
tools: composer:v2
110110

.github/workflows/test.yaml

+6-17
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030
strategy:
3131
matrix:
3232
php-version:
33-
- '7.4'
3433
- '8.0'
3534
- '8.1'
3635
- '8.2'
@@ -39,31 +38,21 @@ jobs:
3938
symfony-require: ['']
4039
variant: [normal]
4140
include:
42-
- php-version: '7.4'
41+
- php-version: '8.0'
4342
dependencies: lowest
4443
allowed-to-fail: false
4544
variant: normal
46-
- php-version: '8.1'
45+
- php-version: '8.2'
4746
dependencies: highest
4847
allowed-to-fail: false
4948
symfony-require: 4.4.*
5049
variant: symfony/symfony:"4.4.*"
51-
- php-version: '8.1'
50+
- php-version: '8.2'
5251
dependencies: highest
5352
allowed-to-fail: false
5453
symfony-require: 5.4.*
5554
variant: symfony/symfony:"5.4.*"
56-
- php-version: '8.1'
57-
dependencies: highest
58-
allowed-to-fail: false
59-
symfony-require: 6.0.*
60-
variant: symfony/symfony:"6.0.*"
61-
- php-version: '8.1'
62-
dependencies: highest
63-
allowed-to-fail: false
64-
symfony-require: 6.1.*
65-
variant: symfony/symfony:"6.1.*"
66-
- php-version: '8.1'
55+
- php-version: '8.2'
6756
dependencies: highest
6857
allowed-to-fail: false
6958
symfony-require: 6.2.*
@@ -103,6 +92,6 @@ jobs:
10392
run: make coverage
10493

10594
- name: Send coverage to Codecov
106-
uses: codecov/codecov-action@v2
95+
uses: codecov/codecov-action@v3
10796
with:
108-
file: build/logs/clover.xml
97+
files: build/logs/clover.xml

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ phpstan:
117117
.PHONY: phpstan
118118

119119
psalm:
120-
vendor/bin/psalm --php-version=8.1
120+
vendor/bin/psalm --php-version=8.2
121121
.PHONY: psalm
122122

123123
rector:

composer.json

+28-27
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
],
2222
"homepage": "https://docs.sonata-project.org/projects/SonataPageBundle",
2323
"require": {
24-
"php": "^7.4 || ^8.0",
24+
"php": "^8.0",
2525
"cocur/slugify": "^4.0",
26-
"doctrine/doctrine-bundle": "^2.5",
27-
"doctrine/persistence": "^2.1 || ^3.0",
26+
"doctrine/doctrine-bundle": "^2.7",
27+
"doctrine/persistence": "^3.0.2",
2828
"sonata-project/admin-bundle": "^4.19",
2929
"sonata-project/block-bundle": "^4.18",
3030
"sonata-project/doctrine-extensions": "^1.18 || ^2.1",
@@ -33,27 +33,26 @@
3333
"sonata-project/seo-bundle": "^3.4",
3434
"sonata-project/twig-extensions": "^1.3 || ^2.0",
3535
"symfony-cmf/routing-bundle": "^2.1 || ^3.0",
36-
"symfony/config": "^4.4 || ^5.4 || ^6.0",
37-
"symfony/console": "^4.4 || ^5.4 || ^6.0",
38-
"symfony/dependency-injection": "^4.4.3 || ^5.4 || ^6.0",
39-
"symfony/form": "^4.4 || ^5.4 || ^6.0",
40-
"symfony/framework-bundle": "^4.4 || ^5.4 || ^6.0",
41-
"symfony/http-foundation": "^4.4 || ^5.4 || ^6.0",
42-
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.0",
43-
"symfony/intl": "^4.4 || ^5.4 || ^6.0",
44-
"symfony/options-resolver": "^4.4 || ^5.4 || ^6.0",
45-
"symfony/process": "^4.4 || ^5.4 || ^6.0",
46-
"symfony/routing": "^4.4 || ^5.4 || ^6.0",
47-
"symfony/security-core": "^4.4 || ^5.4 || ^6.0",
48-
"symfony/security-http": "^4.4 || ^5.4 || ^6.0",
49-
"symfony/serializer": "^4.4 || ^5.4 || ^6.0",
50-
"symfony/validator": "^4.4 || ^5.4 || ^6.0",
36+
"symfony/config": "^4.4 || ^5.4 || ^6.2",
37+
"symfony/console": "^4.4 || ^5.4 || ^6.2",
38+
"symfony/dependency-injection": "^4.4.3 || ^5.4 || ^6.2",
39+
"symfony/form": "^4.4 || ^5.4 || ^6.2",
40+
"symfony/framework-bundle": "^4.4 || ^5.4 || ^6.2",
41+
"symfony/http-foundation": "^4.4 || ^5.4 || ^6.2",
42+
"symfony/http-kernel": "^4.4 || ^5.4 || ^6.2",
43+
"symfony/intl": "^4.4 || ^5.4 || ^6.2",
44+
"symfony/options-resolver": "^4.4 || ^5.4 || ^6.2",
45+
"symfony/process": "^4.4 || ^5.4 || ^6.2",
46+
"symfony/routing": "^4.4 || ^5.4 || ^6.2",
47+
"symfony/security-core": "^4.4 || ^5.4 || ^6.2",
48+
"symfony/security-http": "^4.4 || ^5.4 || ^6.2",
49+
"symfony/serializer": "^4.4 || ^5.4 || ^6.2",
50+
"symfony/validator": "^4.4 || ^5.4 || ^6.2",
5151
"twig/string-extra": "^3.0",
5252
"twig/twig": "^2.12.1 || ^3.0"
5353
},
5454
"require-dev": {
5555
"dama/doctrine-test-bundle": "^6.7",
56-
"doctrine/annotations": "^1.13.3",
5756
"friendsofphp/php-cs-fixer": "^3.4",
5857
"masterminds/html5": "^2.7",
5958
"matthiasnoback/symfony-dependency-injection-test": "^4.1.1",
@@ -63,18 +62,20 @@
6362
"phpstan/phpstan-strict-rules": "^1.3",
6463
"phpstan/phpstan-symfony": "^1.0",
6564
"phpunit/phpunit": "^9.5",
66-
"psalm/plugin-phpunit": "^0.17",
67-
"psalm/plugin-symfony": "^3.0",
65+
"psalm/plugin-phpunit": "^0.18",
66+
"psalm/plugin-symfony": "^4.0 || ^5.0",
6867
"rector/rector": "^0.15",
69-
"symfony/browser-kit": "^4.4 || ^5.4 || ^6.0",
70-
"symfony/css-selector": "^4.4 || ^5.4 || ^6.0",
71-
"symfony/filesystem": "^4.4 || ^5.4 || ^6.0",
68+
"symfony/browser-kit": "^4.4 || ^5.4 || ^6.2",
69+
"symfony/css-selector": "^4.4 || ^5.4 || ^6.2",
70+
"symfony/filesystem": "^4.4 || ^5.4 || ^6.2",
7271
"symfony/panther": "^1.0 || ^2.0",
73-
"symfony/phpunit-bridge": "^6.1",
74-
"vimeo/psalm": "^4.7.2"
72+
"symfony/phpunit-bridge": "^6.2",
73+
"symfony/yaml": "^4.4 || ^5.4 || ^6.2",
74+
"vimeo/psalm": "^4.7.2 || ^5.0"
7575
},
7676
"conflict": {
77-
"doctrine/orm": "<2.10"
77+
"doctrine/dbal": "<3.4",
78+
"doctrine/orm": "<2.14"
7879
},
7980
"suggest": {
8081
"twig/extra-bundle": "Auto configures the Twig Intl extension"

phpstan-baseline.neon

+16
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,19 @@ parameters:
66
- # https://github.com/phpstan/phpstan-strict-rules/issues/130
77
message: '#^Call to static method PHPUnit\\Framework\\Assert::.* will always evaluate to true\.$#'
88
path: tests/
9+
- # https://github.com/phpstan/phpstan-symfony/issues/322
10+
message: "#^Cannot call method getId\\(\\) on array\\<string, bool\\|string\\>\\|Sonata\\\\PageBundle\\\\Model\\\\PageInterface\\|Sonata\\\\PageBundle\\\\Model\\\\SiteInterface\\.$#"
11+
count: 1
12+
path: src/Form/Type/PageSelectorType.php
13+
- # https://github.com/phpstan/phpstan-symfony/issues/322
14+
message: "#^Only booleans are allowed in &&, array\\<string, bool\\|string\\>\\|Sonata\\\\PageBundle\\\\Model\\\\PageInterface\\|Sonata\\\\PageBundle\\\\Model\\\\SiteInterface\\|null given on the right side\\.$#"
15+
count: 1
16+
path: src/Form/Type/PageSelectorType.php
17+
- # https://github.com/phpstan/phpstan-symfony/issues/322
18+
message: "#^Parameter \\#2 \\$currentPage of method Sonata\\\\PageBundle\\\\Form\\\\Type\\\\PageSelectorType\\:\\:childWalker\\(\\) expects Sonata\\\\PageBundle\\\\Model\\\\PageInterface\\|null, array\\<string, bool\\|string\\>\\|Sonata\\\\PageBundle\\\\Model\\\\PageInterface\\|Sonata\\\\PageBundle\\\\Model\\\\SiteInterface\\|null given\\.$#"
19+
count: 1
20+
path: src/Form/Type/PageSelectorType.php
21+
- # https://github.com/phpstan/phpstan-symfony/issues/322
22+
message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, array\\<string, bool\\|string\\>\\|Sonata\\\\PageBundle\\\\Model\\\\PageInterface\\|Sonata\\\\PageBundle\\\\Model\\\\SiteInterface\\|null given\\.$#"
23+
count: 1
24+
path: src/Form/Type/PageSelectorType.php

psalm.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="2" findUnusedPsalmSuppress="true" resolveFromConfigFile="true" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
2+
<psalm xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" errorLevel="2" findUnusedPsalmSuppress="true" resolveFromConfigFile="true" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" findUnusedBaselineEntry="true" findUnusedCode="false">
33
<projectFiles>
44
<directory name="src"/>
55
<directory name="tests"/>

rector.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
]);
3030

3131
$rectorConfig->sets([
32-
LevelSetList::UP_TO_PHP_74,
32+
LevelSetList::UP_TO_PHP_80,
3333
]);
3434

3535
$rectorConfig->importNames();

src/Admin/BaseBlockAdmin.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,16 @@
3131
*/
3232
abstract class BaseBlockAdmin extends AbstractAdmin
3333
{
34-
protected BlockServiceManagerInterface $blockManager;
35-
3634
protected bool $inValidate = false;
3735

3836
/**
3937
* @var array<string>
4038
*/
4139
protected array $containerBlockTypes = [];
4240

43-
public function __construct(BlockServiceManagerInterface $blockManager)
41+
public function __construct(protected BlockServiceManagerInterface $blockManager)
4442
{
4543
parent::__construct();
46-
47-
$this->blockManager = $blockManager;
4844
}
4945

5046
/**
@@ -143,7 +139,7 @@ private function loadBlockDefaults(PageBlockInterface $block): PageBlockInterfac
143139

144140
try {
145141
$block->setSettings($resolver->resolve($block->getSettings()));
146-
} catch (InvalidOptionsException $e) {
142+
} catch (InvalidOptionsException) {
147143
// @TODO : add a logging error or a flash message
148144
}
149145

src/Admin/BlockAdmin.php

+4-14
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@ final class BlockAdmin extends BaseBlockAdmin
3737
{
3838
protected $classnameLabel = 'Block';
3939

40-
/**
41-
* @var array<string, array{
42-
* templates?: array<array{
43-
* name: string,
44-
* template: string,
45-
* }>,
46-
* }>
47-
*/
48-
private array $blocks;
49-
5040
/**
5141
* @param array<string, array{
5242
* templates?: array<array{
@@ -55,11 +45,11 @@ final class BlockAdmin extends BaseBlockAdmin
5545
* }>,
5646
* }> $blocks
5747
*/
58-
public function __construct(BlockServiceManagerInterface $blockManager, array $blocks = [])
59-
{
48+
public function __construct(
49+
BlockServiceManagerInterface $blockManager,
50+
private array $blocks = []
51+
) {
6052
parent::__construct($blockManager);
61-
62-
$this->blocks = $blocks;
6353
}
6454

6555
protected function getAccessMapping(): array

src/Admin/Extension/CreateSnapshotAdminExtension.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@
2424
*/
2525
final class CreateSnapshotAdminExtension extends AbstractAdminExtension
2626
{
27-
private CreateSnapshotByPageInterface $createSnapshotByPage;
28-
29-
public function __construct(CreateSnapshotByPageInterface $createSnapshotByPage)
27+
public function __construct(private CreateSnapshotByPageInterface $createSnapshotByPage)
3028
{
31-
$this->createSnapshotByPage = $createSnapshotByPage;
3229
}
3330

3431
public function postUpdate(AdminInterface $admin, object $object): void

src/Admin/PageAdmin.php

+3-10
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,11 @@ final class PageAdmin extends AbstractAdmin
4646
{
4747
protected $classnameLabel = 'Page';
4848

49-
private PageManagerInterface $pageManager;
50-
51-
private SiteManagerInterface $siteManager;
52-
5349
public function __construct(
54-
PageManagerInterface $pageManager,
55-
SiteManagerInterface $siteManager
50+
private PageManagerInterface $pageManager,
51+
private SiteManagerInterface $siteManager
5652
) {
5753
parent::__construct();
58-
59-
$this->pageManager = $pageManager;
60-
$this->siteManager = $siteManager;
6154
}
6255

6356
protected function configureRoutes(RouteCollectionInterface $collection): void
@@ -385,7 +378,7 @@ protected function configureTabMenu(ItemInterface $menu, string $action, ?AdminI
385378
'path' => $path,
386379
]),
387380
]);
388-
} catch (\Exception $e) {
381+
} catch (\Exception) {
389382
// avoid crashing the admin if the route is not setup correctly
390383
// throw $e;
391384
}

src/Admin/SiteAdmin.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,9 @@ final class SiteAdmin extends AbstractAdmin
3434
{
3535
protected $classnameLabel = 'Site';
3636

37-
private RoutePageGenerator $routePageGenerator;
38-
39-
public function __construct(RoutePageGenerator $routePageGenerator)
37+
public function __construct(private RoutePageGenerator $routePageGenerator)
4038
{
4139
parent::__construct();
42-
43-
$this->routePageGenerator = $routePageGenerator;
4440
}
4541

4642
protected function postPersist(object $object): void

0 commit comments

Comments
 (0)