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

Organization of ConsoleCommands/Messages #15730

27 changes: 27 additions & 0 deletions UPGRADE-1.13.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,30 @@
+ private RepositoryInterface|ZoneRepositoryInterface $zoneRepository,
)
```

1. Moved classes from `Command` to `Console\Command`. The `Command` namespace is deprecated for console command classes and will be removed in Sylius 2.0.
List of affected classes:
- `\Sylius\Bundle\OrderBundle\Command\RemoveExpiredCartsCommand` to `\Sylius\Bundle\OrderBundle\Console\Command\RemoveExpiredCartsCommand`
- `\Sylius\Bundle\PromotionBundle\Command\GenerateCouponsCommand` to `\Sylius\Bundle\PromotionBundle\Console\Command\GenerateCouponsCommand`
- `\Sylius\Bundle\UiBundle\Command\DebugTemplateEventCommand` to `\Sylius\Bundle\UiBundle\Console\Command\DebugTemplateEventCommand`
- `\Sylius\Bundle\UserBundle\Command\AbstractRoleCommand` to `\Sylius\Bundle\UserBundle\Console\Command\AbstractRoleCommand`
- `\Sylius\Bundle\UserBundle\Command\DemoteUserCommand` to `\Sylius\Bundle\UserBundle\Console\Command\DemoteUserCommand`
- `\Sylius\Bundle\UserBundle\Command\PromoteUserCommand` to `\Sylius\Bundle\UserBundle\Console\Command\PromoteUserCommand`
- `\Sylius\Bundle\CoreBundle\Command\Model\PluginInfo` to `\Sylius\Bundle\CoreBundle\Console\Command\Model\PluginInfo`
- `\Sylius\Bundle\CoreBundle\Command\AbstractInstallCommand` to `\Sylius\Bundle\CoreBundle\Console\Command\AbstractInstallCommand`
- `\Sylius\Bundle\CoreBundle\Command\CancelUnpaidOrdersCommand` to `\Sylius\Bundle\CoreBundle\Console\Command\CancelUnpaidOrdersCommand`
- `\Sylius\Bundle\CoreBundle\Command\CheckRequirementsCommand` to `\Sylius\Bundle\CoreBundle\Console\Command\CheckRequirementsCommand`
- `\Sylius\Bundle\CoreBundle\Command\InformAboutGUSCommand` to `\Sylius\Bundle\CoreBundle\Console\Command\InformAboutGUSCommand`
- `\Sylius\Bundle\CoreBundle\Command\InstallAssetsCommand` to `\Sylius\Bundle\CoreBundle\Console\Command\InstallAssetsCommand`
- `\Sylius\Bundle\CoreBundle\Command\InstallCommand` to `\Sylius\Bundle\CoreBundle\Console\Command\InstallCommand`
- `\Sylius\Bundle\CoreBundle\Command\InstallDatabaseCommand` to `\Sylius\Bundle\CoreBundle\Console\Command\InstallDatabaseCommand`
- `\Sylius\Bundle\CoreBundle\Command\InstallSampleDataCommand` to `\Sylius\Bundle\CoreBundle\Console\Command\InstallSampleDataCommand`
- `\Sylius\Bundle\CoreBundle\Command\JwtConfigurationCommand` to `\Sylius\Bundle\CoreBundle\Console\Command\JwtConfigurationCommand`
- `\Sylius\Bundle\CoreBundle\Command\SetupCommand` to `\Sylius\Bundle\CoreBundle\Console\Command\SetupCommand`
- `\Sylius\Bundle\CoreBundle\Command\ShowAvailablePluginsCommand` to `\Sylius\Bundle\CoreBundle\Console\Command\ShowAvailablePluginsCommand`

1. In version 2.0 introduces a significant restructuring of our class system to enhance efficiency and clarity. The changes are as follows:
- `Message` will be migrated to `Command`.
- `MessageDispatcher` will be migrated to `CommandDispatcher`.
- `MessageHandler` will be migrated to `CommandHandler`.
- Example: Within the `Sylius\Bundle\CoreBundle`, the `MessageHandler\OrderHandler` class will be migrated to `CommandHandler\OrderHandler`. This pattern will be mirrored across other bundles in the system.
176 changes: 93 additions & 83 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -185,26 +185,6 @@ parameters:
count: 1
path: src/Sylius/Bundle/AdminBundle/Menu/PromotionUpdateMenuBuilder.php

-
message: "#^Method Sylius\\\\Bundle\\\\AdminBundle\\\\MessageHandler\\\\CreateAdminUserHandler\\:\\:__construct\\(\\) has parameter \\$adminUserFactory with generic interface Sylius\\\\Component\\\\Resource\\\\Factory\\\\FactoryInterface but does not specify its types\\: T$#"
count: 1
path: src/Sylius/Bundle/AdminBundle/MessageHandler/CreateAdminUserHandler.php

-
message: "#^Method Sylius\\\\Bundle\\\\AdminBundle\\\\MessageHandler\\\\CreateAdminUserHandler\\:\\:__construct\\(\\) has parameter \\$adminUserRepository with generic interface Sylius\\\\Component\\\\User\\\\Repository\\\\UserRepositoryInterface but does not specify its types\\: T$#"
count: 1
path: src/Sylius/Bundle/AdminBundle/MessageHandler/CreateAdminUserHandler.php

-
message: "#^Method Sylius\\\\Bundle\\\\AdminBundle\\\\MessageHandler\\\\CreateAdminUserHandler\\:\\:__construct\\(\\) has parameter \\$validationGroups with no value type specified in iterable type array\\.$#"
count: 1
path: src/Sylius/Bundle/AdminBundle/MessageHandler/CreateAdminUserHandler.php

-
message: "#^Method Sylius\\\\Bundle\\\\AdminBundle\\\\MessageHandler\\\\CreateAdminUserHandler\\:\\:getViolationMessages\\(\\) return type has no value type specified in iterable type iterable\\.$#"
count: 1
path: src/Sylius/Bundle/AdminBundle/MessageHandler/CreateAdminUserHandler.php

-
message: "#^Method Sylius\\\\Bundle\\\\AdminBundle\\\\Twig\\\\ChannelNameExtension\\:\\:__construct\\(\\) has parameter \\$channelRepository with generic interface Sylius\\\\Component\\\\Channel\\\\Repository\\\\ChannelRepositoryInterface but does not specify its types\\: T$#"
count: 1
Expand Down Expand Up @@ -2300,46 +2280,6 @@ parameters:
count: 1
path: src/Sylius/Bundle/CoreBundle/Collector/SyliusCollector.php

-
message: "#^Method Sylius\\\\Bundle\\\\CoreBundle\\\\Command\\\\AbstractInstallCommand\\:\\:initialize\\(\\) has no return type specified\\.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php

-
message: "#^Method Sylius\\\\Bundle\\\\CoreBundle\\\\Command\\\\AbstractInstallCommand\\:\\:renderTable\\(\\) has parameter \\$headers with no value type specified in iterable type array\\.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php

-
message: "#^Method Sylius\\\\Bundle\\\\CoreBundle\\\\Command\\\\AbstractInstallCommand\\:\\:renderTable\\(\\) has parameter \\$rows with no value type specified in iterable type array\\.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php

-
message: "#^Method Sylius\\\\Bundle\\\\CoreBundle\\\\Command\\\\AbstractInstallCommand\\:\\:runCommands\\(\\) has parameter \\$commands with no value type specified in iterable type array\\.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php

-
message: "#^PHPDoc tag @var for variable \\$command has no value type specified in iterable type array\\.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/InstallCommand.php

-
message: "#^Property Sylius\\\\Bundle\\\\CoreBundle\\\\Command\\\\InstallCommand\\:\\:\\$commands type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/InstallCommand.php

-
message: "#^Method Sylius\\\\Bundle\\\\CoreBundle\\\\Command\\\\SetupCommand\\:\\:getAdminUserRepository\\(\\) return type with generic interface Sylius\\\\Component\\\\User\\\\Repository\\\\UserRepositoryInterface does not specify its types\\: T$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/SetupCommand.php

-
message: "#^PHPDoc tag @var for variable \\$userRepository contains generic interface Sylius\\\\Component\\\\User\\\\Repository\\\\UserRepositoryInterface but does not specify its types\\: T$#"
count: 3
path: src/Sylius/Bundle/CoreBundle/Command/SetupCommand.php

-
message: "#^Method Sylius\\\\Bundle\\\\CoreBundle\\\\Context\\\\CustomerAndChannelBasedCartContext\\:\\:__construct\\(\\) has parameter \\$orderRepository with generic interface Sylius\\\\Component\\\\Core\\\\Repository\\\\OrderRepositoryInterface but does not specify its types\\: T$#"
count: 1
Expand Down Expand Up @@ -4150,11 +4090,6 @@ parameters:
count: 1
path: src/Sylius/Bundle/LocaleBundle/SyliusLocaleBundle.php

-
message: "#^Method Sylius\\\\Bundle\\\\OrderBundle\\\\Command\\\\RemoveExpiredCartsCommand\\:\\:__construct\\(\\) has parameter \\$expirationTime with no type specified\\.$#"
count: 1
path: src/Sylius/Bundle/OrderBundle/Command/RemoveExpiredCartsCommand.php

-
message: "#^Method Sylius\\\\Bundle\\\\OrderBundle\\\\Context\\\\SessionBasedCartContext\\:\\:__construct\\(\\) has parameter \\$orderRepository with generic interface Sylius\\\\Component\\\\Order\\\\Repository\\\\OrderRepositoryInterface but does not specify its types\\: T$#"
count: 1
Expand Down Expand Up @@ -4495,11 +4430,6 @@ parameters:
count: 1
path: src/Sylius/Bundle/ProductBundle/Validator/UniqueSimpleProductCodeValidator.php

-
message: "#^Method Sylius\\\\Bundle\\\\PromotionBundle\\\\Command\\\\GenerateCouponsCommand\\:\\:__construct\\(\\) has parameter \\$promotionRepository with generic interface Sylius\\\\Component\\\\Promotion\\\\Repository\\\\PromotionRepositoryInterface but does not specify its types\\: T$#"
count: 1
path: src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php

-
message: "#^Method Sylius\\\\Bundle\\\\PromotionBundle\\\\DiscountApplicationCriteria\\\\DiscountApplicationCriteriaInterface\\:\\:isApplicable\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -5061,24 +4991,14 @@ parameters:
path: src/Sylius/Bundle/UiBundle/Twig/TemplateEventExtension.php

-
message: "#^Method Sylius\\\\Bundle\\\\UserBundle\\\\Command\\\\AbstractRoleCommand\\:\\:executeRoleCommand\\(\\) has parameter \\$securityRoles with no value type specified in iterable type array\\.$#"
message: "#^Method Sylius\\\\Bundle\\\\UserBundle\\\\Console\\\\Command\\\\AbstractRoleCommand\\:\\:getUserRepository\\(\\) return type with generic interface Sylius\\\\Component\\\\User\\\\Repository\\\\UserRepositoryInterface does not specify its types\\: T$#"
count: 1
path: src/Sylius/Bundle/UserBundle/Command/AbstractRoleCommand.php

-
message: "#^Method Sylius\\\\Bundle\\\\UserBundle\\\\Command\\\\AbstractRoleCommand\\:\\:getAvailableUserTypes\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Sylius/Bundle/UserBundle/Command/AbstractRoleCommand.php

-
message: "#^Method Sylius\\\\Bundle\\\\UserBundle\\\\Command\\\\AbstractRoleCommand\\:\\:getUserRepository\\(\\) return type with generic interface Sylius\\\\Component\\\\User\\\\Repository\\\\UserRepositoryInterface does not specify its types\\: T$#"
count: 1
path: src/Sylius/Bundle/UserBundle/Command/AbstractRoleCommand.php
path: src/Sylius/Bundle/UserBundle/Console/Command/AbstractRoleCommand.php

-
message: "#^Unable to resolve the template type T in call to method Doctrine\\\\Persistence\\\\ObjectManager\\:\\:getRepository\\(\\)$#"
count: 1
path: src/Sylius/Bundle/UserBundle/Command/AbstractRoleCommand.php
path: src/Sylius/Bundle/UserBundle/Console/Command/AbstractRoleCommand.php

-
message: "#^Method Sylius\\\\Bundle\\\\UserBundle\\\\Command\\\\DemoteUserCommand\\:\\:executeRoleCommand\\(\\) has parameter \\$securityRoles with no value type specified in iterable type array\\.$#"
Expand Down Expand Up @@ -6984,3 +6904,93 @@ parameters:
message: "#^Method Sylius\\\\Component\\\\User\\\\Security\\\\Checker\\\\TokenUniquenessChecker\\:\\:__construct\\(\\) has parameter \\$repository with generic interface Sylius\\\\Component\\\\Resource\\\\Repository\\\\RepositoryInterface but does not specify its types\\: T$#"
count: 1
path: src/Sylius/Component/User/Security/Checker/TokenUniquenessChecker.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/AbstractInstallCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/CancelUnpaidOrdersCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/CheckRequirementsCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/InformAboutGUSCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/InstallAssetsCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/InstallCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/InstallDatabaseCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/InstallSampleDataCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/JwtConfigurationCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/SetupCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/ShowAvailablePluginsCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/CoreBundle/Command/Model/PluginInfo.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/OrderBundle/Command/RemoveExpiredCartsCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/PromotionBundle/Command/GenerateCouponsCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/UiBundle/Command/DebugTemplateEventCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/UserBundle/Command/AbstractRoleCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/UserBundle/Command/DemoteUserCommand.php

-
message: "#^If condition is always false.$#"
count: 1
path: src/Sylius/Bundle/UserBundle/Command/PromoteUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

declare(strict_types=1);

namespace Sylius\Bundle\AdminBundle\Command;
namespace Sylius\Bundle\AdminBundle\Console\Command;

use Sylius\Bundle\AdminBundle\Command\Factory\QuestionFactoryInterface;
use Sylius\Bundle\AdminBundle\Console\Command\Factory\QuestionFactoryInterface;
use Sylius\Component\Core\Model\AdminUserInterface;
use Sylius\Component\User\Repository\UserRepositoryInterface;
use Sylius\Component\User\Security\PasswordUpdaterInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

declare(strict_types=1);

namespace Sylius\Bundle\AdminBundle\Command;
namespace Sylius\Bundle\AdminBundle\Console\Command;

use Sylius\Bundle\AdminBundle\Command\Factory\QuestionFactoryInterface;
use Sylius\Bundle\AdminBundle\Exception\CreateAdminUserFailedException;
use Sylius\Bundle\AdminBundle\Console\Command\Factory\QuestionFactoryInterface;
use Sylius\Bundle\AdminBundle\Message\CreateAdminUser;
use Sylius\Bundle\AdminBundle\Exception\CreateAdminUserFailedException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Sylius\Bundle\AdminBundle\Command\Factory;
namespace Sylius\Bundle\AdminBundle\Console\Command\Factory;

use Symfony\Component\Console\Question\Question;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace Sylius\Bundle\AdminBundle\Command\Factory;
namespace Sylius\Bundle\AdminBundle\Console\Command\Factory;

use Symfony\Component\Console\Question\Question;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@

final class CreateAdminUserHandler implements MessageHandlerInterface
{
/**
* @param UserRepositoryInterface<AdminUserInterface> $adminUserRepository
* @param FactoryInterface<AdminUserInterface> $adminUserFactory
* @param array<array-key, string> $validationGroups
*/
public function __construct(
private UserRepositoryInterface $adminUserRepository,
private FactoryInterface $adminUserFactory,
Expand Down Expand Up @@ -65,6 +70,7 @@ private function setUpAdminUser(CreateAdminUser $command): AdminUserInterface
return $adminUser;
}

/** @return iterable<string> */
private function getViolationMessages(ConstraintViolationListInterface $constraintViolationList): iterable
{
foreach ($constraintViolationList as $violation) {
Expand Down
12 changes: 6 additions & 6 deletions src/Sylius/Bundle/AdminBundle/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
<services>
<defaults public="true" />

<service id="Sylius\Bundle\AdminBundle\Command\CreateAdminUserCommand">
<service id="Sylius\Bundle\AdminBundle\Console\Command\CreateAdminUserCommand">
<argument type="service" id="sylius.command_bus" />
<argument>%sylius_locale.locale%</argument>
<argument type="service" id="sylius.command_factory.question" />
<argument type="service" id="sylius.console.command_factory.question" />
<tag name="console.command" />
</service>

<service id="Sylius\Bundle\AdminBundle\Command\ChangeAdminUserPasswordCommand">
<service id="Sylius\Bundle\AdminBundle\Console\Command\ChangeAdminUserPasswordCommand">
<argument type="service" id="sylius.repository.admin_user" />
<argument type="service" id="sylius.security.password_updater" />
<argument type="service" id="sylius.command_factory.question" />
<argument type="service" id="sylius.console.command_factory.question" />
<tag name="console.command" />
</service>

Expand All @@ -59,9 +59,9 @@
<tag name="messenger.message_handler" bus="sylius_default.bus" />
</service>

<service id="sylius.command_factory.question" class="Sylius\Bundle\AdminBundle\Command\Factory\QuestionFactory" />
<service id="sylius.console.command_factory.question" class="Sylius\Bundle\AdminBundle\Console\Command\Factory\QuestionFactory" />

<service id="Sylius\Bundle\AdminBundle\Command\Factory\QuestionFactoryInterface" alias="sylius.command_factory.question" />
<service id="Sylius\Bundle\AdminBundle\Console\Command\Factory\QuestionFactoryInterface" alias="sylius.console.command_factory.question" />

<service id="sylius.context.locale.admin_based" class="Sylius\Bundle\AdminBundle\Context\AdminBasedLocaleContext">
<argument type="service" id="security.token_storage" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

declare(strict_types=1);

namespace Sylius\Bundle\AdminBundle\Tests\Command;
namespace Sylius\Bundle\AdminBundle\Tests\Console\Command;

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Sylius\Bundle\AdminBundle\Command\ChangeAdminUserPasswordCommand;
use Sylius\Bundle\AdminBundle\Command\Factory\QuestionFactoryInterface;
use Sylius\Bundle\AdminBundle\Console\Command\ChangeAdminUserPasswordCommand;
use Sylius\Bundle\AdminBundle\Console\Command\Factory\QuestionFactoryInterface;
use Sylius\Component\Core\Model\AdminUser;
use Sylius\Component\User\Repository\UserRepositoryInterface;
use Sylius\Component\User\Security\PasswordUpdaterInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

declare(strict_types=1);

namespace Sylius\Bundle\AdminBundle\Tests\Command;
namespace Sylius\Bundle\AdminBundle\Tests\Console\Command;

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Sylius\Bundle\AdminBundle\Command\CreateAdminUserCommand;
use Sylius\Bundle\AdminBundle\Command\Factory\QuestionFactoryInterface;
use Sylius\Bundle\AdminBundle\Console\Command\Factory\QuestionFactoryInterface;
Wojdylak marked this conversation as resolved.
Show resolved Hide resolved
use Sylius\Bundle\AdminBundle\Console\Command\CreateAdminUserCommand;
use Sylius\Bundle\AdminBundle\Exception\CreateAdminUserFailedException;
use Sylius\Bundle\AdminBundle\Message\CreateAdminUser;
use Symfony\Component\Console\Command\Command;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

declare(strict_types=1);

namespace Sylius\Bundle\AdminBundle\Tests\Command\Factory;
namespace Sylius\Bundle\AdminBundle\Tests\Console\Command\Factory;

use PHPUnit\Framework\TestCase;
use Sylius\Bundle\AdminBundle\Command\Factory\QuestionFactory;
use Sylius\Bundle\AdminBundle\Console\Command\Factory\QuestionFactory;

final class QuestionFactoryTest extends TestCase
{
Expand Down
Loading
Loading