diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 9a9bb96..328415c 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,13 +1,24 @@ # language: php +build: + dependencies: + before: + - 'composer self-update' + - 'composer update --prefer-stable --prefer-source --no-interaction --no-progress --no-suggest' + cache: + directories: + - vendor/ + nodes: + analysis: + project_setup: + override: true + tests: + override: [php-scrutinizer-run] + filter: paths: [src/*] excluded_paths: [tests/*, vendor/*] -before_commands: - - 'composer self-update' - - 'composer update --prefer-stable --prefer-source --no-interaction --no-scripts --no-progress --no-suggest' - coding_style: php: upper_lower_casing: @@ -17,8 +28,8 @@ coding_style: true_false_null: lower spaces: around_operators: - concatenation: true - negation: false + concatenation: true + negation: false other: after_type_cast: true @@ -34,7 +45,6 @@ tools: enabled: true config: ruleset: 'unusedcode,naming,design,controversial,codesize' - php_cpd: true php_loc: true php_pdepend: true diff --git a/.travis.yml b/.travis.yml index edd3ab5..b834abe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,9 @@ env: - COMPOSER_FLAGS="--prefer-stable --prefer-dist" php: + - 7.2 - 7.3 + - 7.4snapshot - nightly matrix: @@ -22,7 +24,7 @@ matrix: - php: 7.1 env: - COMPOSER_FLAGS="--prefer-lowest --prefer-stable --prefer-dist" - - php: 7.2 + - php: 7.1 env: - TEST_VERSION=true - COMPOSER_FLAGS="--prefer-stable --prefer-dist" @@ -30,17 +32,17 @@ matrix: - php: nightly before_install: - - if [[ -z $TEST_VERSION && -f "/home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini" ]]; then phpenv config-rm xdebug.ini; fi - - composer global require hirak/prestissimo - - composer self-update --stable --no-progress + - if [[ -z $TEST_VERSION && -f "/home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini" ]]; then phpenv config-rm xdebug.ini; fi + - composer global require hirak/prestissimo + - composer self-update --stable --no-progress install: - - travis_retry composer update $COMPOSER_FLAGS --no-interaction --no-scripts --no-progress - - if [[ $TEST_VERSION ]]; then travis_retry composer require php-coveralls/php-coveralls $COMPOSER_FLAGS --no-interaction --no-scripts --no-progress ; fi + - travis_retry composer update $COMPOSER_FLAGS --no-interaction --no-progress + - if [[ $TEST_VERSION ]]; then travis_retry composer require php-coveralls/php-coveralls $COMPOSER_FLAGS --no-interaction --no-scripts --no-progress ; fi script: - - if [[ $TEST_VERSION ]]; then composer qa && composer report-phpunit-clover ; fi - - if [[ -z $TEST_VERSION ]]; then composer test-phpunit ; fi + - if [[ $TEST_VERSION ]]; then composer qa && composer report-phpunit-clover ; fi + - if [[ -z $TEST_VERSION ]]; then composer test-phpunit ; fi after_script: - - if [[ $TEST_VERSION ]]; then travis_retry php vendor/bin/php-coveralls --verbose ; fi + - if [[ $TEST_VERSION ]]; then travis_retry php vendor/bin/php-coveralls --verbose ; fi diff --git a/composer.json b/composer.json index f7e06bb..bc4af78 100644 --- a/composer.json +++ b/composer.json @@ -25,22 +25,23 @@ "prefer-stable": true, "require": { "php": "^7.1", - "phpgears/dto": "~0.2" + "phpgears/dto": "~0.3" }, "require-dev": { "brainmaestro/composer-git-hooks": "^2.1", "friendsofphp/php-cs-fixer": "^2.0", "infection/infection": "^0.9", "phpmd/phpmd": "^2.0", - "phpstan/phpstan": "^0.11", - "phpstan/phpstan-deprecation-rules": "^0.11", - "phpstan/phpstan-strict-rules": "^0.11", - "phpunit/phpunit": "^6.0|^7.0", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "~0.11.12", + "phpstan/phpstan-deprecation-rules": "~0.11.2", + "phpstan/phpstan-strict-rules": "~0.11.1", + "phpunit/phpunit": "^7.0|^8.0", "povils/phpmnd": "^2.0", "roave/security-advisories": "dev-master", - "sebastian/phpcpd": "^3.0|^4.0", - "squizlabs/php_codesniffer": "^2.0", - "thecodingmachine/phpstan-strict-rules": "^0.11" + "sebastian/phpcpd": "^4.0", + "squizlabs/php_codesniffer": "^3.0", + "thecodingmachine/phpstan-strict-rules": "^0.10.2" }, "suggest": { }, diff --git a/phpstan.neon b/phpstan.neon index 02c72a4..a1c637a 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,8 +1,3 @@ -includes: - - vendor/phpstan/phpstan-strict-rules/rules.neon - - vendor/phpstan/phpstan-deprecation-rules/rules.neon - - vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon - parameters: level: max paths: diff --git a/src/AbstractCommand.php b/src/AbstractCommand.php index 29b85d1..6bd6b70 100644 --- a/src/AbstractCommand.php +++ b/src/AbstractCommand.php @@ -32,7 +32,7 @@ abstract class AbstractCommand implements Command */ final protected function __construct(array $parameters) { - $this->checkImmutability(); + $this->assertImmutable(); $this->setPayload($parameters); } diff --git a/src/AbstractCommandHandler.php b/src/AbstractCommandHandler.php index f8ebac0..ae4aed7 100644 --- a/src/AbstractCommandHandler.php +++ b/src/AbstractCommandHandler.php @@ -28,7 +28,7 @@ final public function handle(Command $command): void $supportedCommandType = $this->getSupportedCommandType(); if (!\is_a($command, $supportedCommandType)) { throw new InvalidCommandException(\sprintf( - 'Command must be a %s, %s given', + 'Command must be a "%s", "%s" given', $supportedCommandType, \get_class($command) )); diff --git a/src/AbstractEmptyCommand.php b/src/AbstractEmptyCommand.php index 83467f6..28ad79b 100644 --- a/src/AbstractEmptyCommand.php +++ b/src/AbstractEmptyCommand.php @@ -30,7 +30,7 @@ abstract class AbstractEmptyCommand implements Command */ final protected function __construct() { - $this->checkImmutability(); + $this->assertImmutable(); } /** diff --git a/src/AbstractQuery.php b/src/AbstractQuery.php index 0d53df3..3bc11e0 100644 --- a/src/AbstractQuery.php +++ b/src/AbstractQuery.php @@ -32,7 +32,7 @@ abstract class AbstractQuery implements Query */ final protected function __construct(array $parameters) { - $this->checkImmutability(); + $this->assertImmutable(); $this->setPayload($parameters); } diff --git a/src/AbstractQueryHandler.php b/src/AbstractQueryHandler.php index 08e5df3..c72314e 100644 --- a/src/AbstractQueryHandler.php +++ b/src/AbstractQueryHandler.php @@ -28,7 +28,7 @@ final public function handle(Query $query): DTO $supportedQueryType = $this->getSupportedQueryType(); if (!\is_a($query, $supportedQueryType)) { throw new InvalidQueryException(\sprintf( - 'Query command must be a %s, %s given', + 'Query command must be a "%s", "%s" given', $supportedQueryType, \get_class($query) )); diff --git a/tests/CQRS/AbstractCommandHandlerTest.php b/tests/CQRS/AbstractCommandHandlerTest.php index 5af0517..73de21c 100644 --- a/tests/CQRS/AbstractCommandHandlerTest.php +++ b/tests/CQRS/AbstractCommandHandlerTest.php @@ -13,6 +13,7 @@ namespace Gears\CQRS\Tests; +use Gears\CQRS\Exception\InvalidCommandException; use Gears\CQRS\Tests\Stub\AbstractCommandHandlerStub; use Gears\CQRS\Tests\Stub\AbstractCommandStub; use Gears\CQRS\Tests\Stub\AbstractEmptyCommandStub; @@ -23,12 +24,11 @@ */ class AbstractCommandHandlerTest extends TestCase { - /** - * @expectedException \Gears\CQRS\Exception\InvalidCommandException - * @expectedExceptionMessageRegExp /Command must be a .+\\AbstractCommandStub, .+ given/ - */ public function testInvalidCommandType(): void { + $this->expectException(InvalidCommandException::class); + $this->expectExceptionMessageRegExp('/^Command must be a ".+\\\AbstractCommandStub", ".+" given$/'); + $handler = new AbstractCommandHandlerStub(); $handler->handle(AbstractEmptyCommandStub::instance()); } @@ -38,17 +38,17 @@ public function testHandling(): void $handler = new AbstractCommandHandlerStub(); $handler->handle(AbstractCommandStub::instance()); - $this->assertTrue(true); + static::assertTrue(true); } public function testReconstitute(): void { $command = AbstractCommandStub::reconstitute(['parameter' => 'one']); - $this->assertTrue($command->has('parameter')); + static::assertTrue($command->has('parameter')); $emptyCommand = AbstractEmptyCommandStub::reconstitute(['parameter' => 'one']); - $this->assertFalse($emptyCommand->has('parameter')); + static::assertFalse($emptyCommand->has('parameter')); } } diff --git a/tests/CQRS/AbstractQueryHandlerTest.php b/tests/CQRS/AbstractQueryHandlerTest.php index 56da0fc..d21a2d5 100644 --- a/tests/CQRS/AbstractQueryHandlerTest.php +++ b/tests/CQRS/AbstractQueryHandlerTest.php @@ -14,6 +14,7 @@ namespace Gears\CQRS\Tests; use Gears\CQRS\AbstractQuery; +use Gears\CQRS\Exception\InvalidQueryException; use Gears\CQRS\Tests\Stub\AbstractQueryHandlerStub; use Gears\CQRS\Tests\Stub\AbstractQueryStub; use Gears\DTO\DTO; @@ -28,15 +29,14 @@ public function testHandling(): void { $handler = new AbstractQueryHandlerStub(); - $this->assertInstanceOf(DTO::class, $handler->handle(AbstractQueryStub::instance())); + static::assertInstanceOf(DTO::class, $handler->handle(AbstractQueryStub::instance())); } - /** - * @expectedException \Gears\CQRS\Exception\InvalidQueryException - * @expectedExceptionMessageRegExp /Query command must be a .+\\AbstractQueryStub, .+ given/ - */ public function testInvalidQueryType(): void { + $this->expectException(InvalidQueryException::class); + $this->expectExceptionMessageRegExp('/^Query command must be a ".+\\\AbstractQueryStub", ".+" given$/'); + /** @var AbstractQuery $query */ $query = $this->getMockBuilder(AbstractQuery::class) ->disableOriginalConstructor()