nepada/phpstan-message-bus
最新稳定版本:v4.0.1
Composer 安装命令:
composer require nepada/phpstan-message-bus
包简介
PHPStan extension for nepada/message-bus.
README 文档
README
Installation
Via Composer:
composer require --dev nepada/phpstan-mesasge-bus
Unless you also install phpstan/extension-installer you need to manually enable the extension in your config:
includes: - vendor/nepada/phpstan-message-bus/extension.neon
Either way, you need to specify the directories in which your command handlers are located:
parameters: commandHandlerDirectories: - app - src
Description
The package currently provides only one extension - DynamicMethodThrowTypeExtension. The extension propagates exception thrown by command handlers up to the command bus caller.
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 { }
统计信息
- 总下载量: 1.95k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2020-07-21