Skip to content

Commit f026440

Browse files
Bump phpstan and psalm
1 parent 95aa040 commit f026440

9 files changed

Lines changed: 30 additions & 16 deletions

File tree

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@
5353
"matthiasnoback/symfony-dependency-injection-test": "^4.0 || ^5.0",
5454
"phpstan/extension-installer": "^1.0",
5555
"phpstan/phpdoc-parser": "^1.0",
56-
"phpstan/phpstan": "^1.0",
57-
"phpstan/phpstan-phpunit": "^1.0",
58-
"phpstan/phpstan-strict-rules": "^1.0",
59-
"phpstan/phpstan-symfony": "^1.0",
56+
"phpstan/phpstan": "^1.0 || ^2.0",
57+
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
58+
"phpstan/phpstan-strict-rules": "^1.0 || ^2.0",
59+
"phpstan/phpstan-symfony": "^1.0 || ^2.0",
6060
"phpunit/phpunit": "^9.5",
61-
"psalm/plugin-phpunit": "^0.18",
61+
"psalm/plugin-phpunit": "^0.18 || ^0.19",
6262
"psalm/plugin-symfony": "^5.0",
63-
"rector/rector": "^1.1",
63+
"rector/rector": "^1.1 || ^2.0",
6464
"sonata-project/admin-bundle": "^4.34",
6565
"sonata-project/block-bundle": "^4.11 || ^5.0",
6666
"sonata-project/doctrine-orm-admin-bundle": "^4.0",
@@ -72,7 +72,7 @@
7272
"symfony/security-csrf": "^6.4 || ^7.1",
7373
"symfony/twig-bundle": "^6.4 || ^7.1",
7474
"symfony/yaml": "^6.4 || ^7.1",
75-
"vimeo/psalm": "^5.0"
75+
"vimeo/psalm": "^5.0 || ^6.10"
7676
},
7777
"conflict": {
7878
"doctrine/mongodb-odm": "<2.4",

phpstan-baseline.neon

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ parameters:
1111
message: "#^Parameter \\#2 \\$category of method Sonata\\\\ClassificationBundle\\\\Form\\\\Type\\\\CategorySelectorType\\:\\:childWalker\\(\\) expects Sonata\\\\ClassificationBundle\\\\Model\\\\CategoryInterface, Sonata\\\\ClassificationBundle\\\\Model\\\\CategoryInterface\\|Sonata\\\\ClassificationBundle\\\\Model\\\\ContextInterface given\\.$#"
1212
count: 1
1313
path: src/Form/Type/CategorySelectorType.php
14+
-
15+
message: '#^Call to method get\(\) of internal class Symfony\\Bundle\\FrameworkBundle\\Test\\TestContainer from outside its root namespace Symfony.$#'
16+
path: tests/

psalm.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
1313
</plugins>
1414
<issueHandlers>
15-
<InternalMethod>
16-
<errorLevel type="suppress">
17-
<directory name="tests/Controller"/>
18-
</errorLevel>
19-
</InternalMethod>
2015
<MissingClassConstType errorLevel="suppress"/>
16+
<MissingOverrideAttribute errorLevel="suppress"/>
2117
</issueHandlers>
2218
</psalm>

src/DependencyInjection/SonataClassificationExtension.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,12 @@ private function registerSonataDoctrineMapping(array $config): void
136136
);
137137

138138
$categoryCascade = ['persist', 'refresh', 'merge', 'detach'];
139-
$categoryIsEntity = \in_array(BaseCategory::class, class_parents($config['class']['category']), true);
140-
if ($categoryIsEntity && class_exists(EntityManager::class) && !method_exists(EntityManager::class, 'merge')) { // @phpstan-ignore-line
141-
unset($categoryCascade[array_search('merge', $categoryCascade, true)]);
139+
$parents = class_parents($config['class']['category']);
140+
if (false !== $parents) {
141+
$categoryIsEntity = \in_array(BaseCategory::class, class_parents($config['class']['category']), true);
142+
if ($categoryIsEntity && class_exists(EntityManager::class) && !method_exists(EntityManager::class, 'merge')) { // @phpstan-ignore-line
143+
unset($categoryCascade[array_search('merge', $categoryCascade, true)]);
144+
}
142145
}
143146
$collector->addAssociation(
144147
$config['class']['category'],

tests/App/Entity/Category.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use Doctrine\ORM\Mapping as ORM;
1818
use Sonata\ClassificationBundle\Entity\BaseCategory;
1919

20+
/**
21+
* @psalm-suppress ClassMustBeFinal
22+
*/
2023
#[ORM\Entity]
2124
#[ORM\Table(name: 'classification__category')]
2225
class Category extends BaseCategory

tests/App/Entity/Collection.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use Doctrine\ORM\Mapping as ORM;
1818
use Sonata\ClassificationBundle\Entity\BaseCollection;
1919

20+
/**
21+
* @psalm-suppress ClassMustBeFinal
22+
*/
2023
#[ORM\Entity]
2124
#[ORM\Table(name: 'classification__collection')]
2225
class Collection extends BaseCollection

tests/App/Entity/Context.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use Doctrine\ORM\Mapping as ORM;
1818
use Sonata\ClassificationBundle\Entity\BaseContext;
1919

20+
/**
21+
* @psalm-suppress ClassMustBeFinal
22+
*/
2023
#[ORM\Entity]
2124
#[ORM\Table(name: 'classification__context')]
2225
class Context extends BaseContext

tests/App/Entity/Tag.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use Doctrine\ORM\Mapping as ORM;
1818
use Sonata\ClassificationBundle\Entity\BaseTag;
1919

20+
/**
21+
* @psalm-suppress ClassMustBeFinal
22+
*/
2023
#[ORM\Entity]
2124
#[ORM\Table(name: 'classification__tag')]
2225
class Tag extends BaseTag

tests/Entity/CategoryManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Sonata\ClassificationBundle\Tests\App\Entity\Context;
2121
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
2222

23-
class CategoryManagerTest extends KernelTestCase
23+
final class CategoryManagerTest extends KernelTestCase
2424
{
2525
public function testGetRootCategoryWithChildren(): void
2626
{

0 commit comments

Comments
 (0)