Skip to content

Commit

Permalink
Split PHPStan support out into own repo
Browse files Browse the repository at this point in the history
  • Loading branch information
rosstuck committed Jul 28, 2019
1 parent 9166016 commit 09b9c75
Show file tree
Hide file tree
Showing 29 changed files with 2 additions and 900 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -17,7 +17,7 @@ before_script:
- mkdir -p build/logs

script:
- vendor/bin/phpstan --level=max analyse src
- vendor/bin/phpstan --level=max analyse src tests
- vendor/bin/phpunit --coverage-clover=build/logs/clover.xml
- vendor/bin/phpcs --standard=PSR2 src

Expand Down
36 changes: 1 addition & 35 deletions README.md
Expand Up @@ -20,45 +20,11 @@ Using Composer:
## Plugins
The core Tactician package is small but there are several plugin packages that extend the usefulness of Tactician:

- [PHPStan](https://github.com/thephpleague/tactician-phpstan): Add static analysis support to Tactician. Highly recommended.
- [Logger](https://github.com/thephpleague/tactician-logger): Adds PSR-3 logging support for receiving, completing or failing commands.
- [Doctrine](https://github.com/thephpleague/tactician-doctrine): Wraps commands in separate Doctrine ORM transactions.
- [and many more](https://packagist.org/search/?q=tactician)

## PHPStan Integration

Traditionally, command buses can obscure static analysis. The Tactician PHPStan plugin helps bring stronger type checking by finding missing handler classes, validating handler return types and more.

You'll need to make your `CommandToHandlerMapping` available to PHPStan. The easiest way to do this is to create a small bootstrap file that returns the same Handler configuration you use in your app.

A simple version of this might look like:

~~~
# handler-mapper-loader.php
<?php
use League\Tactician\Handler\Mapping\ClassName\Suffix;
use League\Tactician\Handler\Mapping\MappingByNamingConvention;
use League\Tactician\Handler\Mapping\MethodName\Handle;
return new MappingByNamingConvention(
new Suffix('Handler'),
new Handle()
);
~~~

You can also your bootstrap container or anything else you like, you just need to return a `CommandToHandlerMapping`.

Now expose the bootstrap file in your `phpstan.neon` config.

~~~
# phpstan.neon
parameters:
tactician:
bootstrap: handler-mapping-loader.php
~~~

And you're good to go!

## Framework Integration
There are a number of framework integration packages for Tactician, [search for Tactician on Packagist](https://packagist.org/search/?q=tactician) for the most up-to-date listings.

Expand Down
3 changes: 0 additions & 3 deletions composer.json
Expand Up @@ -26,9 +26,6 @@
}
},
"autoload-dev": {
"classmap": [
"tests/PHPStan/data"
],
"psr-4": {
"League\\Tactician\\Tests\\": "tests/"
},
Expand Down
10 changes: 0 additions & 10 deletions handler-mapping-loader.php

This file was deleted.

18 changes: 0 additions & 18 deletions phpstan.neon

This file was deleted.

83 changes: 0 additions & 83 deletions src/PHPStan/HandlerReturnTypeExtension.php

This file was deleted.

19 changes: 0 additions & 19 deletions src/PHPStan/MappingLoader.php

This file was deleted.

158 changes: 0 additions & 158 deletions src/PHPStan/TacticianRuleSet.php

This file was deleted.

34 changes: 0 additions & 34 deletions tests/PHPStan/HandlerReturnTypeExtensionTest.php

This file was deleted.

0 comments on commit 09b9c75

Please sign in to comment.