nepada / phpstan-message-bus
PHPStan extension for nepada/message-bus.
Installs: 1 600
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Type:phpstan-extension
Requires
- php: >=7.4.0 <8.5
- 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: ^2.0
Requires (Dev)
- composer-runtime-api: ^2.0
- composer/semver: 3.4.3
- nepada/coding-standard: 7.14.1
- php-parallel-lint/php-parallel-lint: 1.4.0
- phpstan/phpstan-phpunit: 2.0.0
- phpstan/phpstan-strict-rules: 2.0.0
- phpunit/phpunit: ^8.5.21 || ^9.5.10
- shipmonk/phpstan-rules: 4.0.0
- spaze/phpstan-disallowed-calls: 4.0.0
Conflicts
- nette/finder: <2.5.1
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 { }