Skip to content
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

[Maintenance] Allow installing Symfony 7 #110

Open
wants to merge 5 commits into
base: 1.9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 17 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,26 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.0", "8.1"]
symfony: ["^5.4", "^6.0"]
php: ["8.0", "8.1", "8.2"]
symfony: ["^5.4", "^6.4", "^7.0"]
dbal: ["^2.0", "^3.0"]
exclude:
-
php: "8.0"
symfony: "^6.4"
-
php: "8.0"
symfony: "^7.0"
-
php: "8.1"
symfony: "^7.0"
-
symfony: "^7.0"
dbal: "^2.0"

steps:
-
uses: actions/checkout@v2
uses: actions/checkout@v4

-
name: Setup PHP
Expand All @@ -37,7 +50,7 @@ jobs:
if: matrix.symfony != ''
run: |
composer global config --no-plugins allow-plugins.symfony/flex true
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:1.18.5"
composer global require --no-progress --no-scripts --no-plugins "symfony/flex:^1.17 || ^2.0"
composer config extra.symfony.require "${{ matrix.symfony }}"

-
Expand Down
24 changes: 14 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,25 @@
"require": {
"php": "^8.0",
"doctrine/data-fixtures": "^1.2",
"monolog/monolog": "^1.25 || ^2.1",
"symfony/framework-bundle": "^5.4 || ^6.0",
"symfony/monolog-bridge": "^5.4 || ^6.0",
"monolog/monolog": "^1.25 || ^2.1 || ^3",
"symfony/framework-bundle": "^5.4 || ^6.0 || ^7.0",
"symfony/monolog-bridge": "^5.4 || ^6.0 || ^7.0",
"webmozart/assert": "^1.9"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.1",
"doctrine/orm": "^2.7",
"matthiasnoback/symfony-config-test": "^4.2",
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
"doctrine/orm": "^2.7 || ^3.0",
"matthiasnoback/symfony-config-test": "^4.2 || ^5.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.2 || ^5.0",
"phpspec/phpspec": "^7.0",
"phpunit/phpunit": "^9.4",
"sylius-labs/coding-standard": "^4.0",
"vimeo/psalm": "^4.23",
"rector/rector": "^0.14.5"
"rector/rector": "^0.14.5",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-doctrine": "^1.3",
"phpstan/phpstan-webmozart-assert": "^1.2",
"phpstan/phpstan-symfony": "^1.3",
"phpstan/phpstan-phpunit": "^1.3"
},
"extra": {
"branch-alias": {
Expand All @@ -61,8 +65,8 @@
"scripts": {
"analyse": [
"@composer validate --strict",
"vendor/bin/ecs check spec src tests",
"vendor/bin/psalm"
"vendor/bin/ecs check",
"vendor/bin/phpstan analyse"
],
"fix": [
"vendor/bin/ecs check spec src tests --fix"
Expand Down
17 changes: 0 additions & 17 deletions easy-coding-standard.yml

This file was deleted.

39 changes: 22 additions & 17 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,34 @@

use PhpCsFixer\Fixer\ClassNotation\VisibilityRequiredFixer;
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
use PhpCsFixer\Fixer\Phpdoc\PhpdocTagTypeFixer;
use SlevomatCodingStandard\Sniffs\Commenting\InlineDocCommentDeclarationSniff;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\EasyCodingStandard\ValueObject\Option;
use Symplify\EasyCodingStandard\Config\ECSConfig;

return static function (ContainerConfigurator $containerConfigurator): void
{
$containerConfigurator->import('vendor/sylius-labs/coding-standard/ecs.php');
return static function (ECSConfig $config): void {
$config->import('vendor/sylius-labs/coding-standard/ecs.php');

$containerConfigurator->services()->set(HeaderCommentFixer::class)->call('configure', [[
'location' => 'after_open',
'header' =>
'This file is part of the Sylius package.
$config->parallel();
$config->paths(['src', 'spec', 'tests']);

(c) Paweł Jędrzejewski

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.',
]]);

$containerConfigurator->parameters()->set(Option::SKIP, [
$config->skip([
InlineDocCommentDeclarationSniff::class . '.MissingVariable',
VisibilityRequiredFixer::class => ['*Spec.php'],
'**/var/*',
]);

$config->ruleWithConfiguration(
HeaderCommentFixer::class,
[
'location' => 'after_open',
'comment_type' => HeaderCommentFixer::HEADER_COMMENT,
'header' => <<<TEXT
This file is part of the Sylius package.

(c) Paweł Jędrzejewski
NoResponseMate marked this conversation as resolved.
Show resolved Hide resolved

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
TEXT
]
);
};
26 changes: 26 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
- vendor/phpstan/phpstan-doctrine/rules.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/phpstan/phpstan-symfony/rules.neon
- vendor/phpstan/phpstan-webmozart-assert/extension.neon

parameters:
level: 6

reportUnmatchedIgnoredErrors: false

paths:
- 'src/'
- 'tests/'

excludePaths:
- 'tests/Application/**.php'

ignoreErrors:
- '/Property .*\:\:\$container has no type specified\./'
- '/Static property .*\:\:\$container \(.*\\Test\\TestContainer\) does not accept Symfony\\Component\\DependencyInjection\\ContainerInterface\./'
- '/PHPDoc tag \@var for variable \$manager contains unknown class Doctrine\\ODM\\MongoDB\\DocumentManager\./'
- '/PHPDoc tag \@var for variable \$manager contains unknown class Doctrine\\ODM\\PHPCR\\DocumentManagerInterface\./'
17 changes: 0 additions & 17 deletions psalm.xml

This file was deleted.

3 changes: 3 additions & 0 deletions src/DependencyInjection/SyliusFixturesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@

final class SyliusFixturesExtension extends Extension implements PrependExtensionInterface
{
/** @param array<mixed> $config */
public function getConfiguration(array $config, ContainerBuilder $container): ConfigurationInterface
{
return new Configuration();
}

/** @param array<array<mixed>> $configs */
public function load(array $configs, ContainerBuilder $container): void
{
$config = $this->processConfiguration($this->getConfiguration([], $container), $configs);
Expand Down Expand Up @@ -69,6 +71,7 @@ public function prepend(ContainerBuilder $container): void
}
}

/** @param array{suites: array<string, array<mixed>>} $config */
private function registerSuites(array $config, ContainerBuilder $container): void
{
$suiteRegistry = $container->findDefinition('sylius_fixtures.suite_registry');
Expand Down
1 change: 1 addition & 0 deletions src/Fixture/FixtureInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

interface FixtureInterface extends ConfigurationInterface
{
/** @param array<mixed> $options */
public function load(array $options): void;

public function getName(): string;
Expand Down
4 changes: 2 additions & 2 deletions src/Fixture/FixtureRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

final class FixtureRegistry implements FixtureRegistryInterface
{
/** @var array */
private $fixtures = [];
/** @var array<string, FixtureInterface> */
private array $fixtures = [];

public function addFixture(FixtureInterface $fixture): void
{
Expand Down
1 change: 1 addition & 0 deletions src/Listener/AfterFixtureListenerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@

interface AfterFixtureListenerInterface extends ListenerInterface
{
/** @param array<mixed> $options */
public function afterFixture(FixtureEvent $fixtureEvent, array $options): void;
}
1 change: 1 addition & 0 deletions src/Listener/AfterSuiteListenerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@

interface AfterSuiteListenerInterface extends ListenerInterface
{
/** @param array<mixed> $options */
public function afterSuite(SuiteEvent $suiteEvent, array $options): void;
}
1 change: 1 addition & 0 deletions src/Listener/BeforeFixtureListenerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@

interface BeforeFixtureListenerInterface extends ListenerInterface
{
/** @param array<mixed> $options */
public function beforeFixture(FixtureEvent $fixtureEvent, array $options): void;
}
1 change: 1 addition & 0 deletions src/Listener/BeforeSuiteListenerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@

interface BeforeSuiteListenerInterface extends ListenerInterface
{
/** @param array<mixed> $options */
public function beforeSuite(SuiteEvent $suiteEvent, array $options): void;
}
6 changes: 4 additions & 2 deletions src/Listener/FixtureEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ final class FixtureEvent

private FixtureInterface $fixture;

/** @var array */
private $fixtureOptions;
/** @var array<mixed> */
private array $fixtureOptions;

/** @param array<mixed> $fixtureOptions */
public function __construct(SuiteInterface $suite, FixtureInterface $fixture, array $fixtureOptions)
NoResponseMate marked this conversation as resolved.
Show resolved Hide resolved
{
$this->suite = $suite;
Expand All @@ -42,6 +43,7 @@ public function fixture(): FixtureInterface
return $this->fixture;
}

/** @return array<mixed> */
public function fixtureOptions(): array
{
return $this->fixtureOptions;
Expand Down
4 changes: 2 additions & 2 deletions src/Listener/ListenerRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

final class ListenerRegistry implements ListenerRegistryInterface
{
/** @var array */
private $listeners = [];
/** @var array<string, ListenerInterface> */
private array $listeners = [];

public function addListener(ListenerInterface $listener): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Listener/ListenerRegistryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface ListenerRegistryInterface
public function getListener(string $name): ListenerInterface;

/**
* @return array|ListenerInterface[] Name indexed
* @return array<string, ListenerInterface> Name indexed
*/
public function getListeners(): array;
}
2 changes: 2 additions & 0 deletions src/Listener/LoggerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ public function __construct(LoggerInterface $logger)
$this->logger = $logger;
}

/** @param array<mixed> $options */
public function beforeSuite(SuiteEvent $suiteEvent, array $options): void
{
$this->logger->notice(sprintf('Running suite "%s"...', $suiteEvent->suite()->getName()));
}

/** @param array<mixed> $options */
public function beforeFixture(FixtureEvent $fixtureEvent, array $options): void
{
$this->logger->notice(sprintf('Running fixture "%s"...', $fixtureEvent->fixture()->getName()));
Expand Down
6 changes: 3 additions & 3 deletions src/Listener/MongoDBPurgerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
namespace Sylius\Bundle\FixturesBundle\Listener;

use Doctrine\Common\DataFixtures\Purger\MongoDBPurger;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;

final class MongoDBPurgerListener extends AbstractListener implements BeforeSuiteListenerInterface
{
/** @var ManagerRegistry */
private $managerRegistry;
private ManagerRegistry $managerRegistry;

public function __construct(ManagerRegistry $managerRegistry)
NoResponseMate marked this conversation as resolved.
Show resolved Hide resolved
{
$this->managerRegistry = $managerRegistry;
}

/** @param array{managers: string[]} $options */
public function beforeSuite(SuiteEvent $suiteEvent, array $options): void
{
foreach ($options['managers'] as $managerName) {
Expand Down
4 changes: 3 additions & 1 deletion src/Listener/ORMPurgerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ final class ORMPurgerListener extends AbstractListener implements BeforeSuiteLis
{
private ManagerRegistry $managerRegistry;

/** @var array<string, int> */
private static array $purgeModes = [
'delete' => ORMPurger::PURGE_MODE_DELETE,
'truncate' => ORMPurger::PURGE_MODE_TRUNCATE,
Expand All @@ -32,14 +33,15 @@ public function __construct(ManagerRegistry $managerRegistry)
$this->managerRegistry = $managerRegistry;
}

/** @param array{managers: string[], exclude: array<int|string>, mode: string} $options */
public function beforeSuite(SuiteEvent $suiteEvent, array $options): void
{
foreach ($options['managers'] as $managerName) {
/** @var EntityManagerInterface $manager */
$manager = $this->managerRegistry->getManager($managerName);

$purger = new ORMPurger($manager, $options['exclude']);
$purger->setPurgeMode(static::$purgeModes[$options['mode']]);
$purger->setPurgeMode(self::$purgeModes[$options['mode']]);
$purger->purge();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Listener/PHPCRPurgerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
namespace Sylius\Bundle\FixturesBundle\Listener;

use Doctrine\Common\DataFixtures\Purger\PHPCRPurger;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ODM\PHPCR\DocumentManagerInterface;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;

final class PHPCRPurgerListener extends AbstractListener implements BeforeSuiteListenerInterface
{
/** @var ManagerRegistry */
private $managerRegistry;
private ManagerRegistry $managerRegistry;

public function __construct(ManagerRegistry $managerRegistry)
{
$this->managerRegistry = $managerRegistry;
}

/** @param array{managers: string[]} $options */
public function beforeSuite(SuiteEvent $suiteEvent, array $options): void
{
foreach ($options['managers'] as $managerName) {
Expand Down