From 44f298973e03ceefaae9c4caffc9086e9f0f6393 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Thu, 5 Jan 2017 14:02:16 +0200 Subject: [PATCH 1/2] Update php-cs-fixer to 2.x version. --- .gitignore | 4 +++- .php_cs | 21 --------------------- .php_cs.dist | 28 ++++++++++++++++++++++++++++ bin/dev | 5 ++++- bin/pre-commit | 2 +- composer.json | 2 +- 6 files changed, 37 insertions(+), 25 deletions(-) delete mode 100644 .php_cs create mode 100644 .php_cs.dist diff --git a/.gitignore b/.gitignore index ec60c84f8..b9809c577 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ bin/doctrine* bin/php-cs-fixer bin/phpunit bin/sql-formatter -vendor \ No newline at end of file +vendor +.php_cs +.php_cs.cache \ No newline at end of file diff --git a/.php_cs b/.php_cs deleted file mode 100644 index d3414a1f1..000000000 --- a/.php_cs +++ /dev/null @@ -1,21 +0,0 @@ -in(__DIR__) - ->notPath('vendor') -; - -return Symfony\CS\Config::create() - ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) - ->fixers([ - 'ordered_use', - 'no_blank_lines_before_namespace', - 'short_array_syntax', - 'unused_use', - 'phpdoc_order', - - - ]) - ->finder($finder) -; - diff --git a/.php_cs.dist b/.php_cs.dist new file mode 100644 index 000000000..99a418499 --- /dev/null +++ b/.php_cs.dist @@ -0,0 +1,28 @@ +setRiskyAllowed(true) + ->setRules(array( + '@Symfony' => true, + '@Symfony:risky' => true, + 'array_syntax' => array('syntax' => 'short'), + 'combine_consecutive_unsets' => true, + // one should use PHPUnit methods to set up expected exception instead of annotations + 'general_phpdoc_annotation_remove' => array('expectedException', 'expectedExceptionMessage', 'expectedExceptionMessageRegExp'), + 'heredoc_to_nowdoc' => true, + 'no_extra_consecutive_blank_lines' => array('break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'), + 'no_unreachable_default_argument_value' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'ordered_class_elements' => true, + 'ordered_imports' => true, + 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_order' => true, + 'psr4' => true, + 'strict_param' => true, + )) + ->setFinder( + PhpCsFixer\Finder::create() + ->in(__DIR__) + ) +; \ No newline at end of file diff --git a/bin/dev b/bin/dev index dcfa42f1e..11f87e39d 100755 --- a/bin/dev +++ b/bin/dev @@ -3,7 +3,7 @@ set -x set -e -while getopts "buste" OPTION; do +while getopts "bustef" OPTION; do case $OPTION in b) COMPOSE_PROJECT_NAME=mqdev docker-compose build @@ -17,6 +17,9 @@ while getopts "buste" OPTION; do e) docker exec -it mqdev_dev_1 /bin/bash ;; + f) + ./bin/php-cs-fixer fix + ;; t) COMPOSE_PROJECT_NAME=mqdev docker-compose run --workdir="/mqdev" --rm dev ./bin/test ;; diff --git a/bin/pre-commit b/bin/pre-commit index 9ab08b441..9e32fece8 100755 --- a/bin/pre-commit +++ b/bin/pre-commit @@ -105,7 +105,7 @@ function runPhpCsFixer() $output = ''; $returnCode = null; exec(sprintf( - '%s %s fix %s --config-file=%s', + '%s %s fix %s --config=%s', $phpBin, $phpCsFixerBin, $projectRootDir.'/'.$file, diff --git a/composer.json b/composer.json index e0fe925ad..cce8a9151 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "symfony/monolog-bundle": "^2.8|^3", "symfony/browser-kit": "^2.8|^3", "symfony/expression-language": "^2.8|^3", - "friendsofphp/php-cs-fixer": "^1" + "friendsofphp/php-cs-fixer": "^2" }, "config": { "bin-dir": "bin" From 3f446f1a35b0f62294f4d88d6d6815084ee25800 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Thu, 5 Jan 2017 14:06:03 +0200 Subject: [PATCH 2/2] Run php-cs-fixer fix on whole project --- bin/pre-commit | 5 +- pkg/amqp-ext/AmqpConnectionFactory.php | 1 + pkg/amqp-ext/AmqpConsumer.php | 1 + pkg/amqp-ext/AmqpContext.php | 5 +- pkg/amqp-ext/AmqpMessage.php | 1 + pkg/amqp-ext/AmqpProducer.php | 1 + pkg/amqp-ext/AmqpQueue.php | 1 + pkg/amqp-ext/AmqpTopic.php | 1 + pkg/amqp-ext/Client/AmqpDriver.php | 5 +- pkg/amqp-ext/Client/RabbitMqDriver.php | 7 +- pkg/amqp-ext/Symfony/AmqpTransportFactory.php | 1 + .../Symfony/RabbitMqTransportFactory.php | 1 + pkg/amqp-ext/Tests/AmqpContextTest.php | 1 + pkg/amqp-ext/Tests/AmqpMessageTest.php | 3 +- pkg/amqp-ext/Tests/AmqpQueueTest.php | 1 + pkg/amqp-ext/Tests/AmqpTopicTest.php | 1 + pkg/amqp-ext/Tests/Client/AmqpDriverTest.php | 3 +- .../Tests/Client/RabbitMqDriverTest.php | 4 +- .../Functional/AmqpCommonUseCasesTest.php | 3 +- .../AmqpConsumptionUseCasesTest.php | 1 + .../Tests/Functional/AmqpRpcUseCasesTest.php | 1 + .../Symfony/AmqpTransportFactoryTest.php | 1 + .../Symfony/RabbitMqTransportFactoryTest.php | 1 + .../DoctrineClearIdentityMapExtension.php | 1 + .../DoctrinePingConnectionExtension.php | 1 + .../Compiler/AddTopicMetaPass.php | 1 + .../Compiler/BuildClientRoutingPass.php | 1 + .../Compiler/BuildExtensionsPass.php | 1 + .../Compiler/BuildProcessorRegistryPass.php | 1 + .../Compiler/BuildQueueMetaRegistryPass.php | 1 + .../BuildTopicMetaSubscribersPass.php | 1 + .../ExtractProcessorTagSubscriptionsTrait.php | 1 + .../DependencyInjection/Configuration.php | 1 + .../DependencyInjection/EnqueueExtension.php | 1 + pkg/enqueue-bundle/EnqueueBundle.php | 1 + pkg/enqueue-bundle/Entity/Job.php | 1 + pkg/enqueue-bundle/Entity/JobUnique.php | 1 + .../Profiler/MessageQueueCollector.php | 1 + .../Client/ConsumeMessagesCommandTest.php | 3 +- .../Tests/Functional/Client/DriverTest.php | 3 +- .../Functional/Client/MessageProducerTest.php | 3 +- .../Client/ProduceMessageCommandTest.php | 3 +- .../Functional/ConsumeMessagesCommandTest.php | 11 +-- .../Tests/Functional/ContextTest.php | 1 + .../CalculateRootJobStatusProcessorTest.php | 3 +- .../Job/DependentJobServiceTest.php | 3 +- .../Tests/Functional/Job/JobRunnerTest.php | 3 +- .../Tests/Functional/Job/JobStorageTest.php | 3 +- .../Tests/Functional/QueueConsumerTest.php | 1 + .../Tests/Functional/QueueRegistryTest.php | 1 + .../Tests/Functional/QueuesCommandTest.php | 1 + .../Tests/Functional/TestProcessor.php | 1 + .../Tests/Functional/TopicRegistryTest.php | 1 + .../Tests/Functional/TopicsCommandTest.php | 1 + .../Tests/Functional/WebTestCase.php | 1 + .../Tests/Functional/app/AmqpAppKernel.php | 11 +-- .../Tests/Functional/app/AppKernel.php | 11 +-- .../DoctrineClearIdentityMapExtensionTest.php | 1 + .../DoctrinePingConnectionExtensionTest.php | 1 + .../Compiler/AddTopicMetaPassTest.php | 3 +- .../Compiler/BuildClientRoutingPassTest.php | 1 + .../Compiler/BuildExtensionsPassTest.php | 3 +- .../BuildProcessorRegistryPassTest.php | 1 + .../BuildQueueMetaRegistryPassTest.php | 1 + .../BuildTopicMetaSubscribersPassTest.php | 1 + .../Compiler/Mock/InvalidTopicSubscriber.php | 1 + .../Mock/OnlyTopicNameTopicSubscriber.php | 1 + .../Mock/ProcessorNameTopicSubscriber.php | 1 + .../Mock/QueueNameTopicSubscriber.php | 1 + .../DependencyInjection/ConfigurationTest.php | 1 + .../EnqueueExtensionTest.php | 1 + .../Tests/Unit/EnqueueBundleTest.php | 1 + .../Tests/Unit/Mocks/FooTransportFactory.php | 1 + .../Profiler/MessageQueueCollectorTest.php | 3 +- pkg/enqueue/Client/ArrayProcessorRegistry.php | 1 + pkg/enqueue/Client/Config.php | 1 + .../DelayRedeliveredMessageExtension.php | 1 + .../SetRouterPropertiesExtension.php | 1 + .../SetupBrokerExtension.php | 1 + pkg/enqueue/Client/DelegateProcessor.php | 1 + pkg/enqueue/Client/DriverInterface.php | 1 + pkg/enqueue/Client/Message.php | 1 + pkg/enqueue/Client/MessagePriority.php | 1 + pkg/enqueue/Client/MessageProducer.php | 1 + .../Client/MessageProducerInterface.php | 3 +- pkg/enqueue/Client/Meta/QueueMeta.php | 1 + pkg/enqueue/Client/Meta/QueueMetaRegistry.php | 1 + pkg/enqueue/Client/Meta/TopicMeta.php | 1 + pkg/enqueue/Client/Meta/TopicMetaRegistry.php | 1 + pkg/enqueue/Client/NullDriver.php | 1 + .../Client/ProcessorRegistryInterface.php | 1 + pkg/enqueue/Client/RouterProcessor.php | 1 + pkg/enqueue/Client/SimpleClient.php | 1 + .../Client/TopicSubscriberInterface.php | 1 + .../Client/TraceableMessageProducer.php | 10 +-- pkg/enqueue/Consumption/CallbackProcessor.php | 1 + pkg/enqueue/Consumption/ChainExtension.php | 1 + pkg/enqueue/Consumption/Context.php | 1 + .../Consumption/EmptyExtensionTrait.php | 1 + .../ConsumptionInterruptedException.php | 1 + .../Exception/ExceptionInterface.php | 1 + .../IllegalContextModificationException.php | 1 + .../Exception/InvalidArgumentException.php | 1 + .../Consumption/Exception/LogicException.php | 1 + .../LimitConsumedMessagesExtension.php | 1 + .../LimitConsumerMemoryExtension.php | 1 + .../LimitConsumptionTimeExtension.php | 1 + .../Consumption/Extension/LoggerExtension.php | 1 + .../Consumption/Extension/ReplyExtension.php | 1 + .../Consumption/Extension/SignalExtension.php | 1 + .../Consumption/ExtensionInterface.php | 1 + pkg/enqueue/Consumption/QueueConsumer.php | 1 + pkg/enqueue/Consumption/Result.php | 17 ++--- pkg/enqueue/Router/Recipient.php | 1 + .../Router/RecipientListRouterInterface.php | 1 + .../Router/RouteRecipientListProcessor.php | 1 + pkg/enqueue/Rpc/Promise.php | 4 +- pkg/enqueue/Rpc/RpcClient.php | 1 + .../Symfony/Client/ConsumeMessagesCommand.php | 1 + .../ContainerAwareProcessorRegistry.php | 1 + .../Symfony/Client/Meta/QueuesCommand.php | 1 + .../Symfony/Client/Meta/TopicsCommand.php | 1 + .../Symfony/Client/ProduceMessageCommand.php | 1 + .../Symfony/Client/SetupBrokerCommand.php | 1 + .../SetupBrokerExtensionCommandTrait.php | 1 + .../Consumption/ConsumeMessagesCommand.php | 1 + .../ContainerAwareConsumeMessagesCommand.php | 1 + .../LimitsExtensionsCommandTrait.php | 1 + .../Symfony/DefaultTransportFactory.php | 1 + pkg/enqueue/Symfony/NullTransportFactory.php | 1 + .../Symfony/TransportFactoryInterface.php | 1 + .../Client/ArrayProcessorRegistryTest.php | 1 + pkg/enqueue/Tests/Client/ConfigTest.php | 1 + .../DelayRedeliveredMessageExtensionTest.php | 1 + .../SetRouterPropertiesExtensionTest.php | 3 +- .../SetupBrokerExtensionTest.php | 3 +- .../Tests/Client/DelegateProcessorTest.php | 1 + .../Tests/Client/MessagePriorityTest.php | 1 + .../Tests/Client/MessageProducerTest.php | 1 + pkg/enqueue/Tests/Client/MessageTest.php | 1 + .../Client/Meta/QueueMetaRegistryTest.php | 1 + .../Tests/Client/Meta/QueueMetaTest.php | 1 + .../Client/Meta/TopicMetaRegistryTest.php | 1 + .../Tests/Client/Meta/TopicMetaTest.php | 1 + pkg/enqueue/Tests/Client/NullDriverTest.php | 1 + .../Tests/Client/RouterProcessorTest.php | 1 + .../Client/TraceableMessageProducerTest.php | 1 + .../Consumption/CallbackProcessorTest.php | 1 + pkg/enqueue/Tests/Consumption/ContextTest.php | 1 + .../ConsumptionInterruptedExceptionTest.php | 1 + ...llegalContextModificationExceptionTest.php | 1 + .../InvalidArgumentExceptionTest.php | 1 + .../Exception/LogicExceptionTest.php | 1 + .../LimitConsumedMessagesExtensionTest.php | 1 + .../LimitConsumerMemoryExtensionTest.php | 1 + .../LimitConsumptionTimeExtensionTest.php | 1 + .../Extension/LoggerExtensionTest.php | 1 + .../Extension/ReplyExtensionTest.php | 1 + .../Tests/Consumption/ExtensionsTest.php | 1 + .../Consumption/Mock/BreakCycleExtension.php | 1 + .../Tests/Consumption/QueueConsumerTest.php | 3 + pkg/enqueue/Tests/Consumption/ResultTest.php | 1 + .../Functional/Client/SimpleClientTest.php | 1 + pkg/enqueue/Tests/Router/RecipientTest.php | 1 + .../RouteRecipientListProcessorTest.php | 1 + pkg/enqueue/Tests/Rpc/PromiseTest.php | 1 + pkg/enqueue/Tests/Rpc/RpcClientTest.php | 1 + .../Client/ConsumeMessagesCommandTest.php | 1 + .../ContainerAwareProcessorRegistryTest.php | 1 + .../Symfony/Client/Meta/QueuesCommandTest.php | 2 + .../Symfony/Client/Meta/TopicsCommandTest.php | 1 + .../Mock/SetupBrokerExtensionCommand.php | 11 +-- .../Client/ProduceMessageCommandTest.php | 1 + .../Symfony/Client/SetupBrokerCommandTest.php | 1 + .../SetupBrokerExtensionCommandTraitTest.php | 1 + .../ConsumeMessagesCommandTest.php | 3 +- ...ntainerAwareConsumeMessagesCommandTest.php | 1 + .../LimitsExtensionsCommandTraitTest.php | 1 + .../Mock/LimitsExtensionsCommand.php | 11 +-- .../Symfony/DefaultTransportFactoryTest.php | 1 + .../Symfony/NullTransportFactoryTest.php | 1 + .../Null/NullConnectionFactoryTest.php | 1 + .../Tests/Transport/Null/NullConsumerTest.php | 1 + .../Tests/Transport/Null/NullContextTest.php | 3 +- .../Tests/Transport/Null/NullMessageTest.php | 3 +- .../Tests/Transport/Null/NullProducerTest.php | 1 + .../Tests/Transport/Null/NullQueueTest.php | 1 + .../Tests/Transport/Null/NullTopicTest.php | 1 + .../Util/Fixtures/JsonSerializableClass.php | 1 + .../Tests/Util/Fixtures/SimpleClass.php | 3 +- pkg/enqueue/Tests/Util/JSONTest.php | 2 + pkg/enqueue/Tests/Util/UUIDTest.php | 1 + pkg/enqueue/Tests/Util/VarExportTest.php | 3 + .../Transport/Null/NullConnectionFactory.php | 1 + pkg/enqueue/Transport/Null/NullConsumer.php | 1 + pkg/enqueue/Transport/Null/NullContext.php | 1 + pkg/enqueue/Transport/Null/NullMessage.php | 1 + pkg/enqueue/Transport/Null/NullProducer.php | 1 + pkg/enqueue/Transport/Null/NullQueue.php | 1 + pkg/enqueue/Transport/Null/NullTopic.php | 1 + pkg/enqueue/Util/JSON.php | 1 + pkg/enqueue/Util/UUID.php | 5 +- pkg/enqueue/Util/VarExport.php | 1 + .../CalculateRootJobStatusProcessor.php | 1 + .../CalculateRootJobStatusService.php | 7 +- pkg/job-queue/DependentJobContext.php | 1 + pkg/job-queue/DependentJobProcessor.php | 1 + pkg/job-queue/DependentJobService.php | 1 + pkg/job-queue/DuplicateJobException.php | 1 + pkg/job-queue/Job.php | 1 + pkg/job-queue/JobProcessor.php | 3 +- pkg/job-queue/JobRunner.php | 1 + pkg/job-queue/JobStorage.php | 1 + pkg/job-queue/Schema.php | 1 + .../Test/DbalPersistedConnection.php | 69 ++++++++++--------- pkg/job-queue/Test/JobRunner.php | 1 + .../CalculateRootJobStatusProcessorTest.php | 1 + .../CalculateRootJobStatusServiceTest.php | 3 + .../Tests/DependentJobContextTest.php | 1 + .../Tests/DependentJobProcessorTest.php | 1 + .../Tests/DependentJobServiceTest.php | 1 + pkg/job-queue/Tests/Functional/Entity/Job.php | 1 + .../Tests/Functional/Entity/JobUnique.php | 1 + .../Tests/Functional/Job/JobStorageTest.php | 1 + .../Tests/Functional/WebTestCase.php | 1 + .../Tests/Functional/app/AppKernel.php | 10 +-- pkg/job-queue/Tests/JobProcessorTest.php | 3 +- pkg/job-queue/Tests/JobRunnerTest.php | 1 + pkg/job-queue/Tests/JobStorageTest.php | 1 + pkg/job-queue/Topics.php | 1 + pkg/psr-queue/ConnectionFactory.php | 1 + pkg/psr-queue/Consumer.php | 3 +- pkg/psr-queue/Context.php | 1 + pkg/psr-queue/DeliveryMode.php | 1 + pkg/psr-queue/Destination.php | 3 +- pkg/psr-queue/Exception.php | 3 +- pkg/psr-queue/ExceptionInterface.php | 1 + .../InvalidDeliveryModeException.php | 1 + pkg/psr-queue/InvalidDestinationException.php | 1 + pkg/psr-queue/InvalidMessageException.php | 1 + pkg/psr-queue/Message.php | 3 +- pkg/psr-queue/Processor.php | 1 + pkg/psr-queue/Producer.php | 1 + pkg/psr-queue/Queue.php | 3 +- pkg/psr-queue/Tests/ExceptionTest.php | 1 + .../InvalidDeliveryModeExceptionTest.php | 1 + .../Tests/InvalidDestinationExceptionTest.php | 1 + .../Tests/InvalidMessageExceptionTest.php | 1 + pkg/psr-queue/Topic.php | 3 +- pkg/stomp/BufferedStompClient.php | 1 + pkg/stomp/Client/ManagementClient.php | 1 + pkg/stomp/Client/RabbitMqStompDriver.php | 3 +- pkg/stomp/Client/StompDriver.php | 3 +- pkg/stomp/StompConnectionFactory.php | 1 + pkg/stomp/StompConsumer.php | 3 +- pkg/stomp/StompContext.php | 1 + pkg/stomp/StompDestination.php | 3 +- pkg/stomp/StompHeadersEncoder.php | 53 +++++++------- pkg/stomp/StompMessage.php | 1 + pkg/stomp/StompProducer.php | 1 + .../Symfony/RabbitMqStompTransportFactory.php | 1 + pkg/stomp/Symfony/StompTransportFactory.php | 3 +- pkg/stomp/Tests/BufferedStompClientTest.php | 3 +- .../Tests/Client/ManagementClientTest.php | 1 + .../Tests/Client/RabbitMqStompDriverTest.php | 3 +- pkg/stomp/Tests/Client/StompDriverTest.php | 3 +- .../Functional/StompCommonUseCasesTest.php | 5 +- .../StompConsumptionUseCasesTest.php | 1 + .../Tests/Functional/StompRpcUseCasesTest.php | 5 +- pkg/stomp/Tests/StompConsumerTest.php | 3 +- pkg/stomp/Tests/StompContextTest.php | 3 +- pkg/stomp/Tests/StompDestinationTest.php | 3 +- pkg/stomp/Tests/StompHeadersEncoderTest.php | 9 +++ pkg/stomp/Tests/StompMessageTest.php | 3 +- pkg/stomp/Tests/StompProducerTest.php | 3 +- .../RabbitMqStompTransportFactoryTest.php | 5 +- .../Symfony/StompTransportFactoryTest.php | 5 +- pkg/test/ClassExtensionTrait.php | 1 + pkg/test/RabbitmqAmqpExtension.php | 1 + pkg/test/RabbitmqManagmentExtensionTrait.php | 5 +- pkg/test/RabbitmqStompExtension.php | 1 + pkg/test/WriteAttributeTrait.php | 1 + 282 files changed, 466 insertions(+), 174 deletions(-) diff --git a/bin/pre-commit b/bin/pre-commit index 9e32fece8..4537cf91a 100755 --- a/bin/pre-commit +++ b/bin/pre-commit @@ -105,11 +105,10 @@ function runPhpCsFixer() $output = ''; $returnCode = null; exec(sprintf( - '%s %s fix %s --config=%s', + '%s %s fix %s', $phpBin, $phpCsFixerBin, - $projectRootDir.'/'.$file, - $projectRootDir.'/.php_cs' + $projectRootDir.'/'.$file ), $output, $returnCode); if ($returnCode) { diff --git a/pkg/amqp-ext/AmqpConnectionFactory.php b/pkg/amqp-ext/AmqpConnectionFactory.php index dfe36a35f..ab46fe0f0 100644 --- a/pkg/amqp-ext/AmqpConnectionFactory.php +++ b/pkg/amqp-ext/AmqpConnectionFactory.php @@ -1,4 +1,5 @@ bind($destination, $queue); return new AmqpConsumer($this, $queue); - } else { - return new AmqpConsumer($this, $destination); } + + return new AmqpConsumer($this, $destination); } public function close() diff --git a/pkg/amqp-ext/AmqpMessage.php b/pkg/amqp-ext/AmqpMessage.php index 044c4f19e..d5992237b 100644 --- a/pkg/amqp-ext/AmqpMessage.php +++ b/pkg/amqp-ext/AmqpMessage.php @@ -1,4 +1,5 @@ assertSame(null, $message->getBody()); + $this->assertNull($message->getBody()); $this->assertSame([], $message->getProperties()); $this->assertSame([], $message->getHeaders()); } diff --git a/pkg/amqp-ext/Tests/AmqpQueueTest.php b/pkg/amqp-ext/Tests/AmqpQueueTest.php index 9381c1def..56e234764 100644 --- a/pkg/amqp-ext/Tests/AmqpQueueTest.php +++ b/pkg/amqp-ext/Tests/AmqpQueueTest.php @@ -1,4 +1,5 @@ true]); - $meta = new QueueMetaRegistry($config, ['default' => []]); $driver = new RabbitMqDriver($context, $config, $meta); diff --git a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php index 45a884231..be0ef4fef 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php @@ -1,4 +1,5 @@ amqpContext->createConsumer($topic); //guard - $this->assertSame(null, $consumer->receive(1)); + $this->assertNull($consumer->receive(1)); $message = $this->amqpContext->createMessage(__METHOD__); diff --git a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php index 66705ae7f..76abbfce9 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php @@ -1,4 +1,5 @@ assertEquals('test message body', $processor->message->getBody()); } - private function getMessageProducer() - { - return $this->container->get('enqueue.client.message_producer'); - } - /** * @return string */ @@ -101,4 +97,9 @@ public static function getKernelClass() return AmqpAppKernel::class; } + + private function getMessageProducer() + { + return $this->container->get('enqueue.client.message_producer'); + } } diff --git a/pkg/enqueue-bundle/Tests/Functional/ContextTest.php b/pkg/enqueue-bundle/Tests/Functional/ContextTest.php index 557005797..f11a9b17a 100644 --- a/pkg/enqueue-bundle/Tests/Functional/ContextTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/ContextTest.php @@ -1,4 +1,5 @@ load(__DIR__.'/config/amqp-config.yml'); } + + protected function getContainerClass() + { + return parent::getContainerClass().'BundleAmqp'; + } } diff --git a/pkg/enqueue-bundle/Tests/Functional/app/AppKernel.php b/pkg/enqueue-bundle/Tests/Functional/app/AppKernel.php index 9c84fd9ee..e2ed065a3 100644 --- a/pkg/enqueue-bundle/Tests/Functional/app/AppKernel.php +++ b/pkg/enqueue-bundle/Tests/Functional/app/AppKernel.php @@ -1,4 +1,5 @@ load(__DIR__.'/config/config.yml'); } + + protected function getContainerClass() + { + return parent::getContainerClass().'BundleDefault'; + } } diff --git a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrineClearIdentityMapExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrineClearIdentityMapExtensionTest.php index c9b0c8901..7bf9eaa36 100644 --- a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrineClearIdentityMapExtensionTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrineClearIdentityMapExtensionTest.php @@ -1,4 +1,5 @@ reason = (string) $reason; } + /** + * @return string + */ + public function __toString() + { + return $this->status; + } + /** * @return string */ @@ -78,14 +87,6 @@ public function setReply(PsrMessage $reply = null) $this->reply = $reply; } - /** - * @return string - */ - public function __toString() - { - return $this->status; - } - /** * @param string $reason * diff --git a/pkg/enqueue/Router/Recipient.php b/pkg/enqueue/Router/Recipient.php index 94083a2b0..892c0e511 100644 --- a/pkg/enqueue/Router/Recipient.php +++ b/pkg/enqueue/Router/Recipient.php @@ -1,4 +1,5 @@ consumer->acknowledge($message); return $message; - } else { - $this->consumer->reject($message, true); } + $this->consumer->reject($message, true); } } diff --git a/pkg/enqueue/Rpc/RpcClient.php b/pkg/enqueue/Rpc/RpcClient.php index e8b4b6268..fad0bcd69 100644 --- a/pkg/enqueue/Rpc/RpcClient.php +++ b/pkg/enqueue/Rpc/RpcClient.php @@ -1,4 +1,5 @@ extension; + } + protected function configure() { parent::configure(); @@ -26,9 +32,4 @@ protected function execute(InputInterface $input, OutputInterface $output) { $this->extension = $this->getSetupBrokerExtension($input, new NullDriver(new NullContext(), Config::create())); } - - public function getExtension() - { - return $this->extension; - } } diff --git a/pkg/enqueue/Tests/Symfony/Client/ProduceMessageCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/ProduceMessageCommandTest.php index cd3bed816..6cbfbfc1d 100644 --- a/pkg/enqueue/Tests/Symfony/Client/ProduceMessageCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/ProduceMessageCommandTest.php @@ -1,4 +1,5 @@ extensions; + } + protected function configure() { parent::configure(); @@ -23,9 +29,4 @@ protected function execute(InputInterface $input, OutputInterface $output) { $this->extensions = $this->getLimitsExtensions($input, $output); } - - public function getExtensions() - { - return $this->extensions; - } } diff --git a/pkg/enqueue/Tests/Symfony/DefaultTransportFactoryTest.php b/pkg/enqueue/Tests/Symfony/DefaultTransportFactoryTest.php index 3fbc5c59a..917ad5d2b 100644 --- a/pkg/enqueue/Tests/Symfony/DefaultTransportFactoryTest.php +++ b/pkg/enqueue/Tests/Symfony/DefaultTransportFactoryTest.php @@ -1,4 +1,5 @@ assertInstanceOf(NullMessage::class, $message); - $this->assertSame(null, $message->getBody()); + $this->assertNull($message->getBody()); $this->assertSame([], $message->getHeaders()); $this->assertSame([], $message->getProperties()); } diff --git a/pkg/enqueue/Tests/Transport/Null/NullMessageTest.php b/pkg/enqueue/Tests/Transport/Null/NullMessageTest.php index d8d2569bc..ddf9cd2d5 100644 --- a/pkg/enqueue/Tests/Transport/Null/NullMessageTest.php +++ b/pkg/enqueue/Tests/Transport/Null/NullMessageTest.php @@ -1,4 +1,5 @@ assertSame(null, $message->getBody()); + $this->assertNull($message->getBody()); } public function testShouldNewMessageReturnEmptyProperties() diff --git a/pkg/enqueue/Tests/Transport/Null/NullProducerTest.php b/pkg/enqueue/Tests/Transport/Null/NullProducerTest.php index 39c05898f..1e90bf349 100644 --- a/pkg/enqueue/Tests/Transport/Null/NullProducerTest.php +++ b/pkg/enqueue/Tests/Transport/Null/NullProducerTest.php @@ -1,4 +1,5 @@ toString(); - } else { - return RhumsaaUuid::uuid4()->toString(); } + + return RhumsaaUuid::uuid4()->toString(); } } diff --git a/pkg/enqueue/Util/VarExport.php b/pkg/enqueue/Util/VarExport.php index 897c664f3..4a48afadd 100644 --- a/pkg/enqueue/Util/VarExport.php +++ b/pkg/enqueue/Util/VarExport.php @@ -1,4 +1,5 @@ isRoot() ? $job : $job->getRootJob(); $stopStatuses = [Job::STATUS_SUCCESS, Job::STATUS_FAILED, Job::STATUS_CANCELLED]; - if (in_array($rootJob->getStatus(), $stopStatuses)) { + if (in_array($rootJob->getStatus(), $stopStatuses, true)) { return; } $rootStopped = false; $this->jobStorage->saveJob($rootJob, function (Job $rootJob) use ($stopStatuses, &$rootStopped) { - if (in_array($rootJob->getStatus(), $stopStatuses)) { + if (in_array($rootJob->getStatus(), $stopStatuses, true)) { return; } @@ -47,7 +48,7 @@ public function calculate(Job $job) $rootJob->setStatus($status); - if (in_array($status, $stopStatuses)) { + if (in_array($status, $stopStatuses, true)) { $rootStopped = true; if (!$rootJob->getStoppedAt()) { $rootJob->setStoppedAt(new \DateTime()); diff --git a/pkg/job-queue/DependentJobContext.php b/pkg/job-queue/DependentJobContext.php index 6393eed5f..34deba656 100644 --- a/pkg/job-queue/DependentJobContext.php +++ b/pkg/job-queue/DependentJobContext.php @@ -1,4 +1,5 @@ jobStorage->findJobById($job->getId()); - if (!in_array($job->getStatus(), [Job::STATUS_NEW, Job::STATUS_RUNNING])) { + if (!in_array($job->getStatus(), [Job::STATUS_NEW, Job::STATUS_RUNNING], true)) { throw new \LogicException(sprintf( 'Can cancel only new or running jobs. id: "%s", status: "%s"', $job->getId(), diff --git a/pkg/job-queue/JobRunner.php b/pkg/job-queue/JobRunner.php index c0adb97b0..bfca429a6 100644 --- a/pkg/job-queue/JobRunner.php +++ b/pkg/job-queue/JobRunner.php @@ -1,4 +1,5 @@ wrapTransactionNestingLevel('rollBack'); } - /** - * @param int $level - */ - private function setTransactionNestingLevel($level) - { - $prop = new \ReflectionProperty('Doctrine\DBAL\Connection', '_transactionNestingLevel'); - $prop->setAccessible(true); - - return $prop->setValue($this, $level); - } - - /** - * @param string $method - * - * @throws \Exception - */ - private function wrapTransactionNestingLevel($method) - { - $e = null; - - $this->setTransactionNestingLevel($this->getPersistedTransactionNestingLevel()); - - try { - call_user_func(['parent', $method]); - } catch (\Exception $e) { - } - - $this->persistTransactionNestingLevel($this->getTransactionNestingLevel()); - - if ($e) { - throw $e; - } - } - /** * @param bool $connected */ @@ -161,4 +128,38 @@ protected function getConnectionId() { return md5(serialize($this->getParams())); } + + /** + * @param int $level + */ + private function setTransactionNestingLevel($level) + { + $prop = new \ReflectionProperty('Doctrine\DBAL\Connection', '_transactionNestingLevel'); + $prop->setAccessible(true); + + return $prop->setValue($this, $level); + } + + /** + * @param string $method + * + * @throws \Exception + */ + private function wrapTransactionNestingLevel($method) + { + $e = null; + + $this->setTransactionNestingLevel($this->getPersistedTransactionNestingLevel()); + + try { + call_user_func(['parent', $method]); + } catch (\Exception $e) { + } + + $this->persistTransactionNestingLevel($this->getTransactionNestingLevel()); + + if ($e) { + throw $e; + } + } } diff --git a/pkg/job-queue/Test/JobRunner.php b/pkg/job-queue/Test/JobRunner.php index fe2d3cb77..62d9f9a52 100644 --- a/pkg/job-queue/Test/JobRunner.php +++ b/pkg/job-queue/Test/JobRunner.php @@ -1,4 +1,5 @@ load(__DIR__.'/config/config.yml'); } + + protected function getContainerClass() + { + return parent::getContainerClass().'JobQueue'; + } } diff --git a/pkg/job-queue/Tests/JobProcessorTest.php b/pkg/job-queue/Tests/JobProcessorTest.php index 85c7f06f8..31ce0a7d8 100644 --- a/pkg/job-queue/Tests/JobProcessorTest.php +++ b/pkg/job-queue/Tests/JobProcessorTest.php @@ -1,12 +1,13 @@ $value) { + if (0 === strpos($key, self::PROPERTY_PREFIX)) { + $encodedProperties[substr($key, $prefixLength)] = $value; + } else { + $encodedHeaders[$key] = $value; + } + } + + $decodedHeaders = self::doDecode($encodedHeaders); + $decodedProperties = self::doDecode($encodedProperties); + + return [$decodedHeaders, $decodedProperties]; + } + /** * @param array $headers * @@ -72,32 +99,6 @@ private static function doEncode($headers = []) return $encoded; } - /** - * @param array $headers - * - * @return array [[headers], [properties]] - */ - public static function decode(array $headers = []) - { - $encodedHeaders = []; - $encodedProperties = []; - $prefixLength = strlen(self::PROPERTY_PREFIX); - - // separate headers/properties - foreach ($headers as $key => $value) { - if (0 === strpos($key, self::PROPERTY_PREFIX)) { - $encodedProperties[substr($key, $prefixLength)] = $value; - } else { - $encodedHeaders[$key] = $value; - } - } - - $decodedHeaders = self::doDecode($encodedHeaders); - $decodedProperties = self::doDecode($encodedProperties); - - return [$decodedHeaders, $decodedProperties]; - } - /** * @param array $headers * diff --git a/pkg/stomp/StompMessage.php b/pkg/stomp/StompMessage.php index 5eb1c0843..ed90f6317 100644 --- a/pkg/stomp/StompMessage.php +++ b/pkg/stomp/StompMessage.php @@ -1,4 +1,5 @@