Skip to content
Merged
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 @@ -53,15 +53,15 @@
"matthiasnoback/symfony-dependency-injection-test": "^4.0 || ^5.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpdoc-parser": "^1.0",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpstan/phpstan-strict-rules": "^1.0",
"phpstan/phpstan-symfony": "^1.0",
"phpstan/phpstan": "^1.0 || ^2.0",
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
"phpstan/phpstan-strict-rules": "^1.0 || ^2.0",
"phpstan/phpstan-symfony": "^1.0 || ^2.0",
"phpunit/phpunit": "^9.5",
"psalm/plugin-phpunit": "^0.18",
"psalm/plugin-phpunit": "^0.18 || ^0.19",
"psalm/plugin-symfony": "^5.0",
"rector/rector": "^1.1",
"sonata-project/admin-bundle": "^4.34",
"rector/rector": "^1.1 || ^2.0",
"sonata-project/admin-bundle": "^4.35.4",
"sonata-project/block-bundle": "^4.11 || ^5.0",
"sonata-project/doctrine-orm-admin-bundle": "^4.0",
"symfony/asset": "^6.4 || ^7.1",
Expand All @@ -72,7 +72,7 @@
"symfony/security-csrf": "^6.4 || ^7.1",
"symfony/twig-bundle": "^6.4 || ^7.1",
"symfony/yaml": "^6.4 || ^7.1",
"vimeo/psalm": "^5.0"
"vimeo/psalm": "^5.0 || ^6.10"
},
"conflict": {
"doctrine/mongodb-odm": "<2.4",
Expand Down
3 changes: 3 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ parameters:
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\\.$#"
count: 1
path: src/Form/Type/CategorySelectorType.php
-
message: '#^Call to method get\(\) of internal class Symfony\\Bundle\\FrameworkBundle\\Test\\TestContainer from outside its root namespace Symfony.$#'
path: tests/
6 changes: 1 addition & 5 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
<issueHandlers>
<InternalMethod>
<errorLevel type="suppress">
<directory name="tests/Controller"/>
</errorLevel>
</InternalMethod>
<MissingClassConstType errorLevel="suppress"/>
<MissingOverrideAttribute errorLevel="suppress"/>
</issueHandlers>
</psalm>
9 changes: 6 additions & 3 deletions src/DependencyInjection/SonataClassificationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,12 @@ private function registerSonataDoctrineMapping(array $config): void
);

$categoryCascade = ['persist', 'refresh', 'merge', 'detach'];
$categoryIsEntity = \in_array(BaseCategory::class, class_parents($config['class']['category']), true);
if ($categoryIsEntity && class_exists(EntityManager::class) && !method_exists(EntityManager::class, 'merge')) { // @phpstan-ignore-line
unset($categoryCascade[array_search('merge', $categoryCascade, true)]);
$parents = class_parents($config['class']['category']);
if (false !== $parents) {
$categoryIsEntity = \in_array(BaseCategory::class, $parents, true);
if ($categoryIsEntity && class_exists(EntityManager::class) && !method_exists(EntityManager::class, 'merge')) { // @phpstan-ignore-line
unset($categoryCascade[array_search('merge', $categoryCascade, true)]);
}
}
$collector->addAssociation(
$config['class']['category'],
Expand Down
2 changes: 1 addition & 1 deletion tests/Admin/Filter/CategoryFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class CategoryFilterTest extends TestCase

protected function setUp(): void
{
$this->categoryManager = $this->createStub(CategoryManagerInterface::class);
$this->categoryManager = static::createStub(CategoryManagerInterface::class);
}

public function testRenderSettings(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Admin/Filter/CollectionFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class CollectionFilterTest extends TestCase

protected function setUp(): void
{
$this->collectionManager = $this->createStub(CollectionManagerInterface::class);
$this->collectionManager = static::createStub(CollectionManagerInterface::class);
}

public function testRenderSettings(): void
Expand Down
2 changes: 2 additions & 0 deletions tests/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Security\Http\Attribute\IsGranted;
use Symfony\UX\StimulusBundle\StimulusBundle;

final class AppKernel extends Kernel
{
Expand All @@ -54,6 +55,7 @@ public function registerBundles(): iterable
new SonataDoctrineORMAdminBundle(),
new SonataClassificationBundle(),
new TwigBundle(),
new StimulusBundle(),
];
}

Expand Down
3 changes: 3 additions & 0 deletions tests/App/Entity/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use Doctrine\ORM\Mapping as ORM;
use Sonata\ClassificationBundle\Entity\BaseCategory;

/**
* @psalm-suppress ClassMustBeFinal
*/
#[ORM\Entity]
#[ORM\Table(name: 'classification__category')]
class Category extends BaseCategory
Expand Down
3 changes: 3 additions & 0 deletions tests/App/Entity/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use Doctrine\ORM\Mapping as ORM;
use Sonata\ClassificationBundle\Entity\BaseCollection;

/**
* @psalm-suppress ClassMustBeFinal
*/
#[ORM\Entity]
#[ORM\Table(name: 'classification__collection')]
class Collection extends BaseCollection
Expand Down
3 changes: 3 additions & 0 deletions tests/App/Entity/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use Doctrine\ORM\Mapping as ORM;
use Sonata\ClassificationBundle\Entity\BaseContext;

/**
* @psalm-suppress ClassMustBeFinal
*/
#[ORM\Entity]
#[ORM\Table(name: 'classification__context')]
class Context extends BaseContext
Expand Down
3 changes: 3 additions & 0 deletions tests/App/Entity/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use Doctrine\ORM\Mapping as ORM;
use Sonata\ClassificationBundle\Entity\BaseTag;

/**
* @psalm-suppress ClassMustBeFinal
*/
#[ORM\Entity]
#[ORM\Table(name: 'classification__tag')]
class Tag extends BaseTag
Expand Down
2 changes: 1 addition & 1 deletion tests/Entity/CategoryManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use Sonata\ClassificationBundle\Tests\App\Entity\Context;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

class CategoryManagerTest extends KernelTestCase
final class CategoryManagerTest extends KernelTestCase
{
public function testGetRootCategoryWithChildren(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Form/Type/CategorySelectorTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class CategorySelectorTypeTest extends TestCase
{
public function testConfigureOptions(): void
{
$manager = $this->createStub(CategoryManagerInterface::class);
$manager = static::createStub(CategoryManagerInterface::class);
$categorySelectorType = new CategorySelectorType($manager);
$optionsResolver = new OptionsResolver();
$categorySelectorType->configureOptions($optionsResolver);
Expand Down