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
5 changes: 4 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ parameters:
- pkg/job-queue/Test/JobRunner.php
- pkg/job-queue/Tests/Functional/app/AppKernel.php
- pkg/rdkafka/RdKafkaConsumer.php

- pkg/async-event-dispatcher/DependencyInjection/Configuration.php
- pkg/enqueue-bundle/DependencyInjection/Configuration.php
- pkg/enqueue/Tests/Symfony/DependencyInjection/TransportFactoryTest.php
- pkg/simple-client/SimpleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('enqueue_async_event_dispatcher');
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$tb = new TreeBuilder('enqueue_async_event_dispatcher');
Comment thread
makasim marked this conversation as resolved.
Resolved
$rootNode = $tb->getRootNode();
} else {
$tb = new TreeBuilder();
$rootNode = $tb->root('enqueue_async_event_dispatcher');
}

$rootNode->children()
->scalarNode('context_service')->isRequired()->cannotBeEmpty()->end()
Expand Down
9 changes: 7 additions & 2 deletions pkg/enqueue-bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ public function __construct(bool $debug)

public function getConfigTreeBuilder(): TreeBuilder
{
$tb = new TreeBuilder();
$rootNode = $tb->root('enqueue');
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$tb = new TreeBuilder('enqueue');
$rootNode = $tb->getRootNode();
} else {
$tb = new TreeBuilder();
$rootNode = $tb->root('enqueue');
}

$rootNode
->requiresAtLeastOneElement()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Interop\Queue\ConnectionFactory;
use Interop\Queue\Context;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\Config\Definition\Processor;
Expand All @@ -37,8 +38,7 @@ public function testThrowIfEmptyNameGivenOnConstruction()

public function testShouldAllowAddConfigurationAsStringDsn()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());

Expand All @@ -59,8 +59,7 @@ public function testShouldAllowAddConfigurationAsStringDsn()
*/
public function testShouldAllowAddConfigurationAsDsnWithoutSlashes()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());

Expand All @@ -76,8 +75,7 @@ public function testShouldAllowAddConfigurationAsDsnWithoutSlashes()

public function testShouldSetNullTransportIfNullGiven()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());

Expand All @@ -93,8 +91,7 @@ public function testShouldSetNullTransportIfNullGiven()

public function testShouldSetNullTransportIfEmptyStringGiven()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());

Expand All @@ -110,8 +107,7 @@ public function testShouldSetNullTransportIfEmptyStringGiven()

public function testShouldSetNullTransportIfEmptyArrayGiven()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());

Expand All @@ -127,8 +123,7 @@ public function testShouldSetNullTransportIfEmptyArrayGiven()

public function testThrowIfEmptyDsnGiven()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());

Expand All @@ -140,8 +135,7 @@ public function testThrowIfEmptyDsnGiven()

public function testThrowIfFactoryClassAndFactoryServiceSetAtTheSameTime()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());

Expand All @@ -159,8 +153,7 @@ public function testThrowIfFactoryClassAndFactoryServiceSetAtTheSameTime()

public function testThrowIfConnectionFactoryClassUsedWithFactoryClassAtTheSameTime()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());

Expand All @@ -178,8 +171,7 @@ public function testThrowIfConnectionFactoryClassUsedWithFactoryClassAtTheSameTi

public function testThrowIfConnectionFactoryClassUsedWithFactoryServiceAtTheSameTime()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());
$processor = new Processor();
Expand All @@ -196,8 +188,7 @@ public function testThrowIfConnectionFactoryClassUsedWithFactoryServiceAtTheSame

public function testShouldAllowSetFactoryClass()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());
$processor = new Processor();
Expand All @@ -214,8 +205,7 @@ public function testShouldAllowSetFactoryClass()

public function testShouldAllowSetFactoryService()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());
$processor = new Processor();
Expand All @@ -232,8 +222,7 @@ public function testShouldAllowSetFactoryService()

public function testShouldAllowSetConnectionFactoryClass()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());
$processor = new Processor();
Expand All @@ -250,8 +239,7 @@ public function testShouldAllowSetConnectionFactoryClass()

public function testThrowIfExtraOptionGiven()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('foo');
list($tb, $rootNode) = $this->getRootNode();

$rootNode->append(TransportFactory::getConfiguration());
$processor = new Processor();
Expand Down Expand Up @@ -464,4 +452,20 @@ public function testThrowIfBuildRpcClientCalledButContextServiceDoesNotExist()
$this->expectExceptionMessage('The service "enqueue.transport.default.context" does not exist.');
$transport->buildRpcClient($container, []);
}

/**
* @return [TreeBuilder, NodeDefinition]
*/
private function getRootNode(): array
{
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$tb = new TreeBuilder('foo');

return [$tb, $tb->getRootNode()];
}

$tb = new TreeBuilder();

return [$tb, $tb->root('foo')];
}
}
9 changes: 7 additions & 2 deletions pkg/simple-client/SimpleClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,13 @@ public function build(array $configs): void

private function createConfiguration(): NodeInterface
{
$tb = new TreeBuilder();
$rootNode = $tb->root('enqueue');
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$tb = new TreeBuilder('enqueue');
$rootNode = $tb->getRootNode();
} else {
$tb = new TreeBuilder();
$rootNode = $tb->root('enqueue');
}

$rootNode
->beforeNormalization()
Expand Down