Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: php
sudo: false

php:
- 7.0
- 7.1
- 7.2
- nightly
Expand Down
2 changes: 0 additions & 2 deletions build/cs-ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
<ruleset name="ConsistenceCodingStandard">
<rule ref="../vendor/consistence/coding-standard/Consistence/ruleset.xml">
<exclude name="PEAR.WhiteSpace.ObjectOperatorIndent.Incorrect"/><!-- structuring Symfony configuration tree needs indentation -->
<exclude name="SlevomatCodingStandard.Classes.ClassConstantVisibility"/><!-- requires 7.1+ -->
<exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/><!-- requires PHP 7.1+ -->
</rule>
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
}
],
"require": {
"php": "~7.1",
"doctrine/doctrine-bundle": "~1.3",
"php-amqplib/rabbitmq-bundle": "~1.9",
"psr/log": "~1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Configuration implements \Symfony\Component\Config\Definition\ConfigurationInterface
{

const PARAMETER_CUSTOM_CONNECTION_CLASS = 'custom_connection_class';
public const PARAMETER_CUSTOM_CONNECTION_CLASS = 'custom_connection_class';

/** @var string */
private $rootNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class RabbitMqDatabaseTransactionProducerExtension
implements \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface
{

const ALIAS = 'rabbit_mq_database_transaction_producer';
public const ALIAS = 'rabbit_mq_database_transaction_producer';

const CONTAINER_PARAMETER_CUSTOM_CONNECTION_CLASS = 'rabbit_mq_database_transaction_producer_bundle.custom_connection_class';
public const CONTAINER_PARAMETER_CUSTOM_CONNECTION_CLASS = 'rabbit_mq_database_transaction_producer_bundle.custom_connection_class';

const CONTAINER_SERVICE_DATABASE_CONNECTION = 'rabbit_mq_database_transaction_producer_bundle.database_connection';
const CONTAINER_SERVICE_LOGGER = 'rabbit_mq_database_transaction_producer_bundle.logger';
public const CONTAINER_SERVICE_DATABASE_CONNECTION = 'rabbit_mq_database_transaction_producer_bundle.database_connection';
public const CONTAINER_SERVICE_LOGGER = 'rabbit_mq_database_transaction_producer_bundle.logger';

const DOCTRINE_EXTENSION_ALIAS = 'doctrine';
public const DOCTRINE_EXTENSION_ALIAS = 'doctrine';

public function prepend(ContainerBuilder $container)
public function prepend(ContainerBuilder $container): void
{
$config = $this->getMergedConfig($container);
if ($config[Configuration::PARAMETER_CUSTOM_CONNECTION_CLASS]) {
Expand All @@ -44,7 +44,7 @@ public function prepend(ContainerBuilder $container)
* @param mixed[] $mergedConfig
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
protected function loadInternal(array $mergedConfig, ContainerBuilder $container)
protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void
{
$container->setParameter(
self::CONTAINER_PARAMETER_CUSTOM_CONNECTION_CLASS,
Expand Down Expand Up @@ -76,7 +76,7 @@ public function getAlias(): string
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
* @return mixed[]
*/
private function getMergedConfig(ContainerBuilder $container)
private function getMergedConfig(ContainerBuilder $container): array
{
$configs = $container->getExtensionConfig($this->getAlias());
return $this->processConfiguration($this->getConfiguration([], $container), $configs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class DoctrineExtensionNotFoundException extends \Exception
{

public function __construct(\Throwable $previous = null)
public function __construct(?\Throwable $previous = null)
{
parent::__construct('Could not find registered `doctrine` extension', 0, $previous);
}
Expand Down
7 changes: 2 additions & 5 deletions src/Doctrine/Connection/AfterCommitCallbacksConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
interface AfterCommitCallbacksConnection
{

public function addAfterCommitCallback(Closure $callback);
public function addAfterCommitCallback(Closure $callback): void;

/**
* @return bool
*/
public function isTransactionActive();
public function isTransactionActive(): bool;

}
13 changes: 9 additions & 4 deletions src/Doctrine/Connection/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Connection
/** @var \Psr\Log\LoggerInterface */
private $logger;

public function setLogger(LoggerInterface $logger)
public function setLogger(LoggerInterface $logger): void
{
if ($this->logger !== null) {
throw new \VasekPurchart\RabbitMqDatabaseTransactionProducerBundle\Doctrine\Connection\ConnectionLoggerAlreadyInitializedException();
Expand All @@ -27,7 +27,12 @@ public function setLogger(LoggerInterface $logger)
$this->logger = $logger;
}

public function commit()
public function isTransactionActive(): bool
{
return parent::isTransactionActive();
}

public function commit(): void
{
parent::commit();
if (!$this->isTransactionActive()) {
Expand All @@ -53,15 +58,15 @@ public function commit()
}
}

public function rollBack()
public function rollBack(): void
{
parent::rollBack();
if (!$this->isTransactionActive() || $this->isRollbackOnly()) {
$this->afterCommitCallbacks = [];
}
}

public function addAfterCommitCallback(Closure $callback)
public function addAfterCommitCallback(Closure $callback): void
{
if ($this->logger === null) {
throw new \VasekPurchart\RabbitMqDatabaseTransactionProducerBundle\Doctrine\Connection\ConnectionRequiresLoggerException();
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Connection/ConnectionCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class ConnectionCompilerPass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
{

public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (
!$container->hasParameter(RabbitMqDatabaseTransactionProducerExtension::CONTAINER_PARAMETER_CUSTOM_CONNECTION_CLASS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class ConnectionLoggerAlreadyInitializedException extends \Exception
{

public function __construct(\Throwable $previous = null)
public function __construct(?\Throwable $previous = null)
{
parent::__construct('Logger has been already initialized', 0, $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class ConnectionRequiresLoggerException extends \Exception
{

public function __construct(\Throwable $previous = null)
public function __construct(?\Throwable $previous = null)
{
parent::__construct('Connection requires logger for logging callback exceptions', 0, $previous);
}
Expand Down
4 changes: 2 additions & 2 deletions src/RabbitMq/Producer/DatabaseTransactionProducer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public function __construct(
* @param string $routingKey
* @param mixed[] $additionalProperties
*/
public function publish($messageBody, $routingKey = '', $additionalProperties = [])
public function publish($messageBody, $routingKey = '', $additionalProperties = []): void
{
if (!$this->databaseConnection->isTransactionActive()) {
$this->wrappedProducer->publish($messageBody, $routingKey, $additionalProperties);
return;
}

$this->databaseConnection->addAfterCommitCallback(function () use ($messageBody, $routingKey, $additionalProperties) {
$this->databaseConnection->addAfterCommitCallback(function () use ($messageBody, $routingKey, $additionalProperties): void {
$this->wrappedProducer->publish($messageBody, $routingKey, $additionalProperties);
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/RabbitMq/Producer/ProducerCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
class ProducerCompilerPass implements \Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
{

const RABBIT_MQ_EXTENSION_PRODUCER_TAG = 'old_sound_rabbit_mq.producer';
public const RABBIT_MQ_EXTENSION_PRODUCER_TAG = 'old_sound_rabbit_mq.producer';

public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
foreach ($container->findTaggedServiceIds(self::RABBIT_MQ_EXTENSION_PRODUCER_TAG) as $id => $attributes) {
$originalDefinition = $container->getDefinition($id);
Expand Down
2 changes: 1 addition & 1 deletion src/RabbitMqDatabaseTransactionProducerBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RabbitMqDatabaseTransactionProducerBundle extends \Symfony\Component\HttpK
*
* @param \Symfony\Component\DependencyInjection\ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
parent::build($container);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class RabbitMqDatabaseTransactionProducerExtensionTest extends \Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase
{

public function setUp()
public function setUp(): void
{
parent::setUp();
$this->setParameter('kernel.debug', true);
Expand All @@ -21,15 +21,15 @@ public function setUp()
/**
* @return \Symfony\Component\DependencyInjection\Extension\ExtensionInterface[]
*/
protected function getContainerExtensions()
protected function getContainerExtensions(): array
{
return [
new DoctrineExtension(),
new RabbitMqDatabaseTransactionProducerExtension(),
];
}

public function testDependsOnDoctrineBundle()
public function testDependsOnDoctrineBundle(): void
{
$containerBuilder = new ContainerBuilder();
$extension = new RabbitMqDatabaseTransactionProducerExtension();
Expand All @@ -39,7 +39,7 @@ public function testDependsOnDoctrineBundle()
$extension->prepend($containerBuilder);
}

public function testRegisterCustomConnectionClass()
public function testRegisterCustomConnectionClass(): void
{
$this->loadExtensions();

Expand All @@ -51,7 +51,7 @@ public function testRegisterCustomConnectionClass()
$this->assertSame(Connection::class, $doctrineConfig[0]['dbal']['wrapper_class']);
}

public function testLoadExtension()
public function testLoadExtension(): void
{
$this->loadExtensions();

Expand All @@ -61,7 +61,7 @@ public function testLoadExtension()
);
}

public function testTurnOffDefaultConnectionIntegration()
public function testTurnOffDefaultConnectionIntegration(): void
{
$this->loadExtensions([
'rabbit_mq_database_transaction_producer' => [
Expand All @@ -78,7 +78,7 @@ public function testTurnOffDefaultConnectionIntegration()
/**
* @param mixed[] $configuration format: extensionAlias(string) => configuration(mixed[])
*/
private function loadExtensions(array $configuration = [])
private function loadExtensions(array $configuration = []): void
{
$configurations = [];
foreach ($this->container->getExtensions() as $extensionAlias => $extension) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Doctrine/Connection/ConnectionCompilerPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
class ConnectionCompilerPassTest extends \Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase
{

protected function registerCompilerPass(ContainerBuilder $container)
protected function registerCompilerPass(ContainerBuilder $container): void
{
$container->addCompilerPass(new ConnectionCompilerPass());
}

public function testSetLoggerForConnection()
public function testSetLoggerForConnection(): void
{
$connectionDefinition = new Definition(Connection::class);
$this->setDefinition(
Expand Down Expand Up @@ -46,7 +46,7 @@ public function testSetLoggerForConnection()
);
}

public function testDoNothingWhenCustomConnectionClassIsSpecified()
public function testDoNothingWhenCustomConnectionClassIsSpecified(): void
{
$connectionDefinition = new Definition(Connection::class);
$this->setDefinition(
Expand Down
Loading