nepada / phpstan-message-bus
PHPStan 扩展,用于 nepada/message-bus。
v3.2.0
2024-04-01 22:41 UTC
Requires
- php: >=7.4.0 <8.4
- nepada/message-bus: ^2.0@dev || ^3.0@dev
- nette/robot-loader: ^3.3.1@dev || ~3.2.4@dev || ~3.1.2@dev || ^4.0@dev
- phpstan/phpstan: ^1.10.51
Requires (Dev)
- composer-runtime-api: ^2.0
- composer/semver: 3.4.0
- nepada/coding-standard: 7.14.0
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpstan/phpstan-phpunit: 1.3.16
- phpstan/phpstan-strict-rules: 1.5.2
- phpunit/phpunit: ^8.5.21 || ^9.5.10
- shipmonk/phpstan-rules: 2.11.3
- spaze/phpstan-disallowed-calls: 3.1.2
Conflicts
- nette/finder: <2.5.1
This package is auto-updated.
Last update: 2024-09-01 23:00:28 UTC
README
安装
通过 Composer
composer require --dev nepada/phpstan-mesasge-bus
除非您还安装了 phpstan/extension-installer,否则您需要手动在您的配置中启用该扩展
includes: - vendor/nepada/phpstan-message-bus/extension.neon
无论如何,您需要指定包含您的命令处理器所在的目录
parameters: commandHandlerDirectories: - app - src
描述
该软件包目前仅提供一种扩展 - DynamicMethodThrowTypeExtension
。该扩展将命令处理器抛出的异常传播到命令总线调用者。
final class FooService { private \Nepada\MessageBus\Commands\CommandBus $commandBus; public function __construct(\Nepada\MessageBus\Commands\CommandBus $commandBus) { $this->commandBus = $commandBus; } public function placeOrder(): void { try { $command = new PlaceOrderCommand(); $this->commandBus->handle($command); } catch (FailedToPlaceOrderException $exception) { // FailedToPlaceOrderException may be thrown and needs to handled } } } final class PlaceOrderCommand implements \Nepada\MessageBus\Commands\Command { } final class PlaceOrderHandler implements \Nepada\MessageBus\Commands\CommandHandler { /** * @param PlaceOrderCommand $command * @throws FailedToPlaceOrderException */ public function __invoke(PlaceOrderCommand $command): void { throw new FailedToPlaceOrderException('Failed to place order'); } } class FailedToPlaceOrderException extends \RuntimeException { }