From 27afa382e00c42e6e5e37c17e7c28ab29741516e Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Mon, 15 May 2017 17:03:04 +0300 Subject: [PATCH 01/10] Add phpstan analyzer and run it on CI. --- .travis.yml | 1 + composer.json | 3 ++- phpstan.neon | 3 +++ pkg/enqueue/Client/Message.php | 7 ++++++- pkg/enqueue/Consumption/Result.php | 4 ++-- .../ConsumptionExtension/SetupBrokerExtensionTest.php | 4 ++-- .../Exception/ConsumptionInterruptedExceptionTest.php | 2 +- .../Exception/IllegalContextModificationExceptionTest.php | 2 +- .../Consumption/Exception/InvalidArgumentExceptionTest.php | 2 +- .../Tests/Consumption/Exception/LogicExceptionTest.php | 2 +- pkg/enqueue/Tests/Consumption/QueueConsumerTest.php | 7 +------ .../Tests/Functions/DsnToConnectionFactoryFunctionTest.php | 2 +- pkg/enqueue/Tests/Functions/DsnToContextFunctionTest.php | 2 +- .../Tests/Symfony/Client/ConsumeMessagesCommandTest.php | 2 +- 14 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 phpstan.neon diff --git a/.travis.yml b/.travis.yml index 68c29d067..73ac65028 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,7 @@ install: - echo "memory_limit=2048M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - composer require symfony/symfony:${SYMFONY_VERSION} --no-update - composer install --ignore-platform-reqs # ext-amqp is not installed + - ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/enqueue - if [ "$FUNCTIONAL_TESTS" = true ]; then docker --version; fi - if [ "$FUNCTIONAL_TESTS" = true ]; then docker-compose --version; fi - if [ "$FUNCTIONAL_TESTS" = true ]; then bin/dev -b; fi diff --git a/composer.json b/composer.json index cbf574fea..173f4b218 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,8 @@ "symfony/browser-kit": "^2.8|^3", "symfony/expression-language": "^2.8|^3", "friendsofphp/php-cs-fixer": "^2", - "empi89/php-amqp-stubs": "*@dev" + "empi89/php-amqp-stubs": "*@dev", + "phpstan/phpstan": "^0.7.0" }, "autoload": { "files": ["pkg/enqueue/functions_include.php"] diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 000000000..be35ef23b --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,3 @@ +parameters: + excludes_analyse: + - pkg/enqueue/Util/UUID.php \ No newline at end of file diff --git a/pkg/enqueue/Client/Message.php b/pkg/enqueue/Client/Message.php index a34c14d68..899cc9928 100644 --- a/pkg/enqueue/Client/Message.php +++ b/pkg/enqueue/Client/Message.php @@ -63,6 +63,11 @@ class Message */ private $correlationId; + /** + * @var string + */ + private $scope; + /** * @var array */ @@ -89,7 +94,7 @@ public function getBody() } /** - * @param null|string|number|array|\JsonSerializable $body + * @param null|string|int|float|array|\JsonSerializable $body */ public function setBody($body) { diff --git a/pkg/enqueue/Consumption/Result.php b/pkg/enqueue/Consumption/Result.php index 893cb96ed..c25a12230 100644 --- a/pkg/enqueue/Consumption/Result.php +++ b/pkg/enqueue/Consumption/Result.php @@ -38,8 +38,8 @@ class Result private $reply; /** - * @param string $status - * @param string $reason + * @param mixed $status + * @param mixed $reason */ public function __construct($status, $reason = '') { diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetupBrokerExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetupBrokerExtensionTest.php index bb3ad8e24..457d6f7e9 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetupBrokerExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetupBrokerExtensionTest.php @@ -27,7 +27,7 @@ public function testCouldBeConstructedWithRequiredArguments() public function testShouldSetupBroker() { - $logger = new NullLogger(''); + $logger = new NullLogger(); $driver = $this->createDriverMock(); $driver @@ -45,7 +45,7 @@ public function testShouldSetupBroker() public function testShouldSetupBrokerOnlyOnce() { - $logger = new NullLogger(''); + $logger = new NullLogger(); $driver = $this->createDriverMock(); $driver diff --git a/pkg/enqueue/Tests/Consumption/Exception/ConsumptionInterruptedExceptionTest.php b/pkg/enqueue/Tests/Consumption/Exception/ConsumptionInterruptedExceptionTest.php index 100f68e61..c6f608bf1 100644 --- a/pkg/enqueue/Tests/Consumption/Exception/ConsumptionInterruptedExceptionTest.php +++ b/pkg/enqueue/Tests/Consumption/Exception/ConsumptionInterruptedExceptionTest.php @@ -1,6 +1,6 @@ expects($this->once()) ->method('onStart') ->with($this->isInstanceOf(Context::class)) - ->willReturnCallback(function (Context $context) use ( - $contextStub, - $messageConsumerStub, - $processorMock - ) { + ->willReturnCallback(function (Context $context) use ($contextStub) { $this->assertSame($contextStub, $context->getPsrContext()); $this->assertNull($context->getPsrConsumer()); $this->assertNull($context->getPsrProcessor()); @@ -446,7 +442,6 @@ public function testShouldCallOnBeforeReceiveExtensionMethod() $contextStub, $messageConsumerStub, $processorMock, - $expectedMessage, $queue ) { $this->assertSame($contextStub, $context->getPsrContext()); diff --git a/pkg/enqueue/Tests/Functions/DsnToConnectionFactoryFunctionTest.php b/pkg/enqueue/Tests/Functions/DsnToConnectionFactoryFunctionTest.php index 312b476ef..6ae301b26 100644 --- a/pkg/enqueue/Tests/Functions/DsnToConnectionFactoryFunctionTest.php +++ b/pkg/enqueue/Tests/Functions/DsnToConnectionFactoryFunctionTest.php @@ -1,6 +1,6 @@ Date: Tue, 16 May 2017 11:47:38 +0300 Subject: [PATCH 02/10] run phpstan only on one instance --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 73ac65028..efc1d610f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,9 @@ matrix: - php: 5.6 sudo: false env: SYMFONY_VERSION=2.8.* FUNCTIONAL_TESTS=false + - php: 7.1 + sudo: false + env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=false PHPSTAN=true - php: 7.0 sudo: false env: SYMFONY_VERSION=2.8.* FUNCTIONAL_TESTS=false @@ -35,7 +38,7 @@ install: - echo "memory_limit=2048M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - composer require symfony/symfony:${SYMFONY_VERSION} --no-update - composer install --ignore-platform-reqs # ext-amqp is not installed - - ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/enqueue + - if [ "PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/enqueue; fi - if [ "$FUNCTIONAL_TESTS" = true ]; then docker --version; fi - if [ "$FUNCTIONAL_TESTS" = true ]; then docker-compose --version; fi - if [ "$FUNCTIONAL_TESTS" = true ]; then bin/dev -b; fi From 268b432725b2fdf7822660dce0e43108aa25eca9 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 16 May 2017 11:50:16 +0300 Subject: [PATCH 03/10] run phpstan separatly --- .gitignore | 3 +++ .travis.yml | 18 +++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 57ae5ec2e..5e48950be 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ bin/doctrine* bin/php-cs-fixer bin/phpunit bin/sql-formatter +bin/phpstan +bin/jp.php +bin/php-parse vendor .php_cs .php_cs.cache diff --git a/.travis.yml b/.travis.yml index efc1d610f..bb31bfd97 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,27 +7,27 @@ matrix: include: - php: 5.6 sudo: false - env: SYMFONY_VERSION=2.8.* FUNCTIONAL_TESTS=false + env: SYMFONY_VERSION=2.8.* FUNCTIONAL_TESTS=false UNIT_TESTS=true - php: 7.1 sudo: false - env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=false PHPSTAN=true + env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=false UNIT_TESTS=false PHPSTAN=true - php: 7.0 sudo: false - env: SYMFONY_VERSION=2.8.* FUNCTIONAL_TESTS=false + env: SYMFONY_VERSION=2.8.* FUNCTIONAL_TESTS=false UNIT_TESTS=true - php: 5.6 sudo: false - env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=false SYMFONY_DEPRECATIONS_HELPER=weak + env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=false UNIT_TESTS=true SYMFONY_DEPRECATIONS_HELPER=weak - php: 7.0 sudo: false - env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=false SYMFONY_DEPRECATIONS_HELPER=weak + env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=false UNIT_TESTS=true SYMFONY_DEPRECATIONS_HELPER=weak - php: 7.0 sudo: required services: docker - env: SYMFONY_VERSION=2.8.* FUNCTIONAL_TESTS=true + env: SYMFONY_VERSION=2.8.* FUNCTIONAL_TESTS=true UNIT_TESTS=false - php: 7.0 sudo: required services: docker - env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=true + env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=true UNIT_TESTS=false cache: directories: @@ -38,11 +38,11 @@ install: - echo "memory_limit=2048M" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - composer require symfony/symfony:${SYMFONY_VERSION} --no-update - composer install --ignore-platform-reqs # ext-amqp is not installed - - if [ "PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/enqueue; fi - if [ "$FUNCTIONAL_TESTS" = true ]; then docker --version; fi - if [ "$FUNCTIONAL_TESTS" = true ]; then docker-compose --version; fi - if [ "$FUNCTIONAL_TESTS" = true ]; then bin/dev -b; fi script: - - if [ "$FUNCTIONAL_TESTS" = false ]; then bin/phpunit --exclude-group=functional; fi + - if [ "PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/enqueue; fi + - if [ "$UNIT_TESTS" = true ]; then bin/phpunit --exclude-group=functional; fi - if [ "$FUNCTIONAL_TESTS" = true ]; then bin/dev -t; fi From 0cf2a3c3afb6a8fd885d3c24dd95e4c2fe86acee Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 16 May 2017 12:12:39 +0300 Subject: [PATCH 04/10] phpstan fixes. --- .travis.yml | 6 ++++-- pkg/amqp-ext/Tests/Client/AmqpDriverTest.php | 2 +- pkg/dbal/Tests/DbalProducerTest.php | 2 +- .../Compiler/AddTopicMetaPassTest.php | 2 +- pkg/fs/FsContext.php | 2 +- pkg/fs/Tests/Client/FsDriverTest.php | 2 +- pkg/fs/Tests/Functional/FsContextTest.php | 6 ++++++ pkg/redis/RedisContext.php | 2 +- pkg/redis/Tests/Client/RedisDriverTest.php | 2 +- pkg/redis/Tests/RedisConsumerTest.php | 2 +- pkg/stomp/Tests/Client/RabbitMqStompDriverTest.php | 12 ++++++------ pkg/stomp/Tests/Client/StompDriverTest.php | 8 ++++---- 12 files changed, 28 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index bb31bfd97..bad518864 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,8 @@ install: - if [ "$FUNCTIONAL_TESTS" = true ]; then bin/dev -b; fi script: - - if [ "PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/enqueue; fi + # misssing pkg/amqp-ext pkg/job-queue pkg/redis + - if [ "PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/enqueue pkg/psr-queue pkg/fs pkg/simple-client; fi + - if [ "PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/stomp pkg/dbal pkg/enqueue-bundle pkg/null pkg/sqs pkg/test; fi - if [ "$UNIT_TESTS" = true ]; then bin/phpunit --exclude-group=functional; fi - - if [ "$FUNCTIONAL_TESTS" = true ]; then bin/dev -t; fi + - if [ "$FUNCTIONAL_TESTS" = true ]; then bin/dev -t; fi \ No newline at end of file diff --git a/pkg/amqp-ext/Tests/Client/AmqpDriverTest.php b/pkg/amqp-ext/Tests/Client/AmqpDriverTest.php index dd8f9ee8b..9dfc3294b 100644 --- a/pkg/amqp-ext/Tests/Client/AmqpDriverTest.php +++ b/pkg/amqp-ext/Tests/Client/AmqpDriverTest.php @@ -367,7 +367,7 @@ public function testShouldSetupBroker() $meta = new QueueMetaRegistry($this->createDummyConfig(), [ 'default' => [], - ], 'default'); + ]); $driver = new AmqpDriver( $context, diff --git a/pkg/dbal/Tests/DbalProducerTest.php b/pkg/dbal/Tests/DbalProducerTest.php index 90781b805..fd53a6d3d 100644 --- a/pkg/dbal/Tests/DbalProducerTest.php +++ b/pkg/dbal/Tests/DbalProducerTest.php @@ -51,7 +51,7 @@ public function testShouldThrowIfDestinationOfInvalidType() $producer = new DbalProducer($this->createContextMock()); - $producer->send(new NotSupportedDestination1(''), new DbalMessage()); + $producer->send(new NotSupportedDestination1(), new DbalMessage()); } public function testShouldThrowIfInsertMessageFailed() diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/AddTopicMetaPassTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/AddTopicMetaPassTest.php index a14ec3fb3..f7730ba1a 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/AddTopicMetaPassTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/AddTopicMetaPassTest.php @@ -20,7 +20,7 @@ public function testShouldImplementCompilerPass() public function testCouldBeConstructedWithoutAntArguments() { - new AddTopicMetaPass([]); + new AddTopicMetaPass(); } public function testCouldBeConstructedByCreateFactoryMethod() diff --git a/pkg/fs/FsContext.php b/pkg/fs/FsContext.php index d435f8432..838d2505f 100644 --- a/pkg/fs/FsContext.php +++ b/pkg/fs/FsContext.php @@ -179,7 +179,7 @@ public function purge(PsrQueue $queue) { InvalidDestinationException::assertDestinationInstanceOf($queue, FsDestination::class); - $this->workWithFile($queue, 'c', function (FsDestination $destination, $file) use ($queue) { + $this->workWithFile($queue, 'c', function (FsDestination $destination, $file) { ftruncate($file, 0); }); } diff --git a/pkg/fs/Tests/Client/FsDriverTest.php b/pkg/fs/Tests/Client/FsDriverTest.php index c19d1efc6..e1526bd16 100644 --- a/pkg/fs/Tests/Client/FsDriverTest.php +++ b/pkg/fs/Tests/Client/FsDriverTest.php @@ -342,7 +342,7 @@ public function testShouldSetupBroker() $meta = new QueueMetaRegistry($this->createDummyConfig(), [ 'default' => [], - ], 'default'); + ]); $driver = new FsDriver( $context, diff --git a/pkg/fs/Tests/Functional/FsContextTest.php b/pkg/fs/Tests/Functional/FsContextTest.php index b0e9451ba..bdcfb341a 100644 --- a/pkg/fs/Tests/Functional/FsContextTest.php +++ b/pkg/fs/Tests/Functional/FsContextTest.php @@ -3,11 +3,17 @@ namespace Enqueue\Fs\Tests\Functional; use Enqueue\Fs\FsConnectionFactory; +use Enqueue\Fs\FsContext; use PHPUnit\Framework\TestCase; use Symfony\Component\Filesystem\Filesystem; class FsContextTest extends TestCase { + /** + * @var FsContext|null + */ + private $fsContext; + public function tearDown() { $fs = new Filesystem(); diff --git a/pkg/redis/RedisContext.php b/pkg/redis/RedisContext.php index 6dab888db..5de8a7b3a 100644 --- a/pkg/redis/RedisContext.php +++ b/pkg/redis/RedisContext.php @@ -33,7 +33,7 @@ public function __construct($redis) $this->redisFactory = $redis; } else { throw new \InvalidArgumentException(sprintf( - 'The $redis argument must be either %s or callable that returns $s once called.', + 'The $redis argument must be either %s or callable that returns %s once called.', Redis::class, Redis::class )); diff --git a/pkg/redis/Tests/Client/RedisDriverTest.php b/pkg/redis/Tests/Client/RedisDriverTest.php index 57204b256..f18c6e317 100644 --- a/pkg/redis/Tests/Client/RedisDriverTest.php +++ b/pkg/redis/Tests/Client/RedisDriverTest.php @@ -316,7 +316,7 @@ public function testShouldDoNothingOnSetupBroker() $meta = new QueueMetaRegistry(Config::create(), [ 'default' => [], - ], 'default'); + ]); $driver = new RedisDriver( $context, diff --git a/pkg/redis/Tests/RedisConsumerTest.php b/pkg/redis/Tests/RedisConsumerTest.php index c139843d6..0b44641ca 100644 --- a/pkg/redis/Tests/RedisConsumerTest.php +++ b/pkg/redis/Tests/RedisConsumerTest.php @@ -29,7 +29,7 @@ public function testShouldReturnDestinationSetInConstructorOnGetQueue() { $destination = new RedisDestination('aQueue'); - $consumer = new RedisConsumer($this->createContextMock(), $destination, 1); + $consumer = new RedisConsumer($this->createContextMock(), $destination); $this->assertSame($destination, $consumer->getQueue()); } diff --git a/pkg/stomp/Tests/Client/RabbitMqStompDriverTest.php b/pkg/stomp/Tests/Client/RabbitMqStompDriverTest.php index bcdc51cf3..6d86e2d99 100644 --- a/pkg/stomp/Tests/Client/RabbitMqStompDriverTest.php +++ b/pkg/stomp/Tests/Client/RabbitMqStompDriverTest.php @@ -51,7 +51,7 @@ public function testShouldReturnConfigObject() public function testShouldCreateAndReturnQueueInstance() { - $expectedQueue = new StompDestination('aName'); + $expectedQueue = new StompDestination(); $context = $this->createPsrContextMock(); $context @@ -86,7 +86,7 @@ public function testShouldCreateAndReturnQueueInstance() public function testShouldCreateAndReturnQueueInstanceWithHardcodedTransportName() { - $expectedQueue = new StompDestination('aName'); + $expectedQueue = new StompDestination(); $context = $this->createPsrContextMock(); $context @@ -306,7 +306,7 @@ public function testShouldThrowExceptionIfDelayIsSetButDelayPluginInstalledOptio public function testShouldSendMessageToRouter() { - $topic = new StompDestination(''); + $topic = new StompDestination(); $transportMessage = new StompMessage(); $producer = $this->createPsrProducerMock(); @@ -362,7 +362,7 @@ public function testShouldThrowExceptionIfTopicParameterIsNotSet() public function testShouldSendMessageToProcessor() { - $queue = new StompDestination(''); + $queue = new StompDestination(); $transportMessage = new StompMessage(); $producer = $this->createPsrProducerMock(); @@ -405,8 +405,8 @@ public function testShouldSendMessageToProcessor() public function testShouldSendMessageToDelayExchangeIfDelaySet() { - $queue = new StompDestination(''); - $delayTopic = new StompDestination(''); + $queue = new StompDestination(); + $delayTopic = new StompDestination(); $transportMessage = new StompMessage(); $producer = $this->createPsrProducerMock(); diff --git a/pkg/stomp/Tests/Client/StompDriverTest.php b/pkg/stomp/Tests/Client/StompDriverTest.php index 0e74d9953..187f31c0c 100644 --- a/pkg/stomp/Tests/Client/StompDriverTest.php +++ b/pkg/stomp/Tests/Client/StompDriverTest.php @@ -39,7 +39,7 @@ public function testShouldReturnConfigObject() public function testShouldCreateAndReturnQueueInstance() { - $expectedQueue = new StompDestination('aName'); + $expectedQueue = new StompDestination(); $context = $this->createPsrContextMock(); $context @@ -66,7 +66,7 @@ public function testShouldCreateAndReturnQueueInstance() public function testShouldCreateAndReturnQueueInstanceWithHardcodedTransportName() { - $expectedQueue = new StompDestination('aName'); + $expectedQueue = new StompDestination(); $context = $this->createPsrContextMock(); $context @@ -153,7 +153,7 @@ public function testShouldConvertClientMessageToTransportMessage() public function testShouldSendMessageToRouter() { - $topic = new StompDestination(''); + $topic = new StompDestination(); $transportMessage = new StompMessage(); $producer = $this->createPsrProducerMock(); @@ -207,7 +207,7 @@ public function testShouldThrowExceptionIfTopicParameterIsNotSet() public function testShouldSendMessageToProcessor() { - $queue = new StompDestination(''); + $queue = new StompDestination(); $transportMessage = new StompMessage(); $producer = $this->createPsrProducerMock(); From 09cd252921cff32bb9523f128a14eb05824dee22 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 16 May 2017 12:14:34 +0300 Subject: [PATCH 05/10] fix travis. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bad518864..40173ebcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ install: script: # misssing pkg/amqp-ext pkg/job-queue pkg/redis - - if [ "PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/enqueue pkg/psr-queue pkg/fs pkg/simple-client; fi - - if [ "PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/stomp pkg/dbal pkg/enqueue-bundle pkg/null pkg/sqs pkg/test; fi + - if [ "$PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/enqueue pkg/psr-queue pkg/fs pkg/simple-client; fi + - if [ "$PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/stomp pkg/dbal pkg/enqueue-bundle pkg/null pkg/sqs pkg/test; fi - if [ "$UNIT_TESTS" = true ]; then bin/phpunit --exclude-group=functional; fi - if [ "$FUNCTIONAL_TESTS" = true ]; then bin/dev -t; fi \ No newline at end of file From 928d3421ecac7ca9ccb28295ea98d392e2874e13 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 16 May 2017 12:19:30 +0300 Subject: [PATCH 06/10] run php-cs-fixer --- .travis.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 40173ebcd..d17dcf661 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,27 +7,30 @@ matrix: include: - php: 5.6 sudo: false - env: SYMFONY_VERSION=2.8.* FUNCTIONAL_TESTS=false UNIT_TESTS=true + env: SYMFONY_VERSION=2.8.* UNIT_TESTS=true - php: 7.1 sudo: false - env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=false UNIT_TESTS=false PHPSTAN=true + env: SYMFONY_VERSION=3.0.* PHPSTAN=true + - php: 7.1 + sudo: false + env: SYMFONY_VERSION=3.0.* PHP_CS_FIXER=true - php: 7.0 sudo: false - env: SYMFONY_VERSION=2.8.* FUNCTIONAL_TESTS=false UNIT_TESTS=true + env: SYMFONY_VERSION=2.8.* UNIT_TESTS=true - php: 5.6 sudo: false - env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=false UNIT_TESTS=true SYMFONY_DEPRECATIONS_HELPER=weak + env: SYMFONY_VERSION=3.0.* UNIT_TESTS=true SYMFONY_DEPRECATIONS_HELPER=weak - php: 7.0 sudo: false - env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=false UNIT_TESTS=true SYMFONY_DEPRECATIONS_HELPER=weak + env: SYMFONY_VERSION=3.0.* UNIT_TESTS=true SYMFONY_DEPRECATIONS_HELPER=weak - php: 7.0 sudo: required services: docker - env: SYMFONY_VERSION=2.8.* FUNCTIONAL_TESTS=true UNIT_TESTS=false + env: SYMFONY_VERSION=2.8.* FUNCTIONAL_TESTS=true - php: 7.0 sudo: required services: docker - env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=true UNIT_TESTS=false + env: SYMFONY_VERSION=3.0.* FUNCTIONAL_TESTS=true cache: directories: @@ -46,5 +49,8 @@ script: # misssing pkg/amqp-ext pkg/job-queue pkg/redis - if [ "$PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/enqueue pkg/psr-queue pkg/fs pkg/simple-client; fi - if [ "$PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/stomp pkg/dbal pkg/enqueue-bundle pkg/null pkg/sqs pkg/test; fi + - if [ "$PHP_CS_FIXER" = true ]; then IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${COMMIT_RANGE}")); unset IFS; fi + - if [ "$PHP_CS_FIXER" = true ]; then ./bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no --path-mode=intersection -- "${COMMIT_SCA_FILES[@]}"; fi - if [ "$UNIT_TESTS" = true ]; then bin/phpunit --exclude-group=functional; fi - - if [ "$FUNCTIONAL_TESTS" = true ]; then bin/dev -t; fi \ No newline at end of file + - if [ "$FUNCTIONAL_TESTS" = true ]; then bin/dev -t; fi + From f065818abae76fab20396d0584373e8d395d3761 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 16 May 2017 12:20:26 +0300 Subject: [PATCH 07/10] fix tests. --- pkg/redis/Tests/RedisContextTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/redis/Tests/RedisContextTest.php b/pkg/redis/Tests/RedisContextTest.php index b143bed4d..77042dac8 100644 --- a/pkg/redis/Tests/RedisContextTest.php +++ b/pkg/redis/Tests/RedisContextTest.php @@ -38,7 +38,7 @@ public function testCouldBeConstructedWithRedisFactoryAsFirstArgument() public function testThrowIfNeitherRedisNorFactoryGiven() { $this->expectException(\InvalidArgumentException::class); - $this->expectExceptionMessage('The $redis argument must be either Enqueue\Redis\Redis or callable that returns $s once called.'); + $this->expectExceptionMessage('The $redis argument must be either Enqueue\Redis\Redis or callable that returns Enqueue\Redis\Redis once called.'); new RedisContext(new \stdClass()); } From 6a30514d8be7fb7757323b2acfa694d00b794571 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 16 May 2017 12:40:05 +0300 Subject: [PATCH 08/10] fixes --- .travis.yml | 2 +- pkg/enqueue-bundle/Tests/Functional/{app => App}/AppKernel.php | 0 .../Tests/Functional/{app => App}/CustomAppKernel.php | 0 .../Tests/Functional/{app => App}/config/config.yml | 0 .../Tests/Functional/{app => App}/config/custom-config.yml | 0 .../Tests/Functional/{app => App}/config/routing.yml | 0 pkg/enqueue-bundle/Tests/Functional/{app => App}/console.php | 0 7 files changed, 1 insertion(+), 1 deletion(-) rename pkg/enqueue-bundle/Tests/Functional/{app => App}/AppKernel.php (100%) rename pkg/enqueue-bundle/Tests/Functional/{app => App}/CustomAppKernel.php (100%) rename pkg/enqueue-bundle/Tests/Functional/{app => App}/config/config.yml (100%) rename pkg/enqueue-bundle/Tests/Functional/{app => App}/config/custom-config.yml (100%) rename pkg/enqueue-bundle/Tests/Functional/{app => App}/config/routing.yml (100%) rename pkg/enqueue-bundle/Tests/Functional/{app => App}/console.php (100%) diff --git a/.travis.yml b/.travis.yml index d17dcf661..e61e3ef82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,7 +49,7 @@ script: # misssing pkg/amqp-ext pkg/job-queue pkg/redis - if [ "$PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/enqueue pkg/psr-queue pkg/fs pkg/simple-client; fi - if [ "$PHPSTAN" = true ]; then ./bin/phpstan analyse -l 1 -c phpstan.neon pkg/stomp pkg/dbal pkg/enqueue-bundle pkg/null pkg/sqs pkg/test; fi - - if [ "$PHP_CS_FIXER" = true ]; then IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${COMMIT_RANGE}")); unset IFS; fi + - if [ "$PHP_CS_FIXER" = true ]; then IFS=$'\n'; COMMIT_SCA_FILES=($(git diff --name-only --diff-filter=ACMRTUXB "${TRAVIS_COMMIT_RANGE}")); unset IFS; fi - if [ "$PHP_CS_FIXER" = true ]; then ./bin/php-cs-fixer fix --config=.php_cs.dist -v --dry-run --stop-on-violation --using-cache=no --path-mode=intersection -- "${COMMIT_SCA_FILES[@]}"; fi - if [ "$UNIT_TESTS" = true ]; then bin/phpunit --exclude-group=functional; fi - if [ "$FUNCTIONAL_TESTS" = true ]; then bin/dev -t; fi diff --git a/pkg/enqueue-bundle/Tests/Functional/app/AppKernel.php b/pkg/enqueue-bundle/Tests/Functional/App/AppKernel.php similarity index 100% rename from pkg/enqueue-bundle/Tests/Functional/app/AppKernel.php rename to pkg/enqueue-bundle/Tests/Functional/App/AppKernel.php diff --git a/pkg/enqueue-bundle/Tests/Functional/app/CustomAppKernel.php b/pkg/enqueue-bundle/Tests/Functional/App/CustomAppKernel.php similarity index 100% rename from pkg/enqueue-bundle/Tests/Functional/app/CustomAppKernel.php rename to pkg/enqueue-bundle/Tests/Functional/App/CustomAppKernel.php diff --git a/pkg/enqueue-bundle/Tests/Functional/app/config/config.yml b/pkg/enqueue-bundle/Tests/Functional/App/config/config.yml similarity index 100% rename from pkg/enqueue-bundle/Tests/Functional/app/config/config.yml rename to pkg/enqueue-bundle/Tests/Functional/App/config/config.yml diff --git a/pkg/enqueue-bundle/Tests/Functional/app/config/custom-config.yml b/pkg/enqueue-bundle/Tests/Functional/App/config/custom-config.yml similarity index 100% rename from pkg/enqueue-bundle/Tests/Functional/app/config/custom-config.yml rename to pkg/enqueue-bundle/Tests/Functional/App/config/custom-config.yml diff --git a/pkg/enqueue-bundle/Tests/Functional/app/config/routing.yml b/pkg/enqueue-bundle/Tests/Functional/App/config/routing.yml similarity index 100% rename from pkg/enqueue-bundle/Tests/Functional/app/config/routing.yml rename to pkg/enqueue-bundle/Tests/Functional/App/config/routing.yml diff --git a/pkg/enqueue-bundle/Tests/Functional/app/console.php b/pkg/enqueue-bundle/Tests/Functional/App/console.php similarity index 100% rename from pkg/enqueue-bundle/Tests/Functional/app/console.php rename to pkg/enqueue-bundle/Tests/Functional/App/console.php From 9d3b89473bd19eda785bc11ba1dcc936bc1a843b Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 16 May 2017 12:47:50 +0300 Subject: [PATCH 09/10] fix --- pkg/enqueue-bundle/Tests/Functional/WebTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php b/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php index 01596fd67..425123112 100644 --- a/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php +++ b/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php @@ -34,7 +34,7 @@ protected function setUp() */ public static function getKernelClass() { - include_once __DIR__.'/app/AppKernel.php'; + include_once __DIR__.'/App/AppKernel.php'; return AppKernel::class; } From bdcee8c8a0a3d16234dc68188062348ae64257b8 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Tue, 16 May 2017 12:56:05 +0300 Subject: [PATCH 10/10] fix --- pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php index 1679793e2..02859da2d 100644 --- a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php @@ -207,7 +207,7 @@ public function testTransportConsumeMessagesCommandShouldConsumeMessage(array $e */ public static function getKernelClass() { - include_once __DIR__.'/app/CustomAppKernel.php'; + include_once __DIR__.'/App/CustomAppKernel.php'; return CustomAppKernel::class; }