Skip to content

Commit 4a2afaa

Browse files
committed
Automatically split on push and tag
1 parent 6fffa7a commit 4a2afaa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+316
-235
lines changed

composer.json

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
"require": {
2929
"php": "^7.4 || ^8.0",
3030
"simple-bus/message-bus": "^3.0.3",
31-
"symfony/config": "^4.4.17 || ^5.1.9",
32-
"symfony/dependency-injection": "^4.4.17 || ^5.1.9",
33-
"symfony/http-kernel": "^4.4 || ^5.1",
34-
"symfony/yaml": "^4.4 || ^5.1"
31+
"symfony/config": "^4.4.17 || ^5.2",
32+
"symfony/dependency-injection": "^4.4.17 || ^5.2",
33+
"symfony/http-kernel": "^4.4 || ^5.2",
34+
"symfony/yaml": "^4.4 || ^5.2"
3535
},
3636
"conflict": {
3737
"zendframework/zend-code": "<3.3.1"
@@ -40,13 +40,13 @@
4040
"doctrine/doctrine-bundle": "^2.2",
4141
"doctrine/orm": "^2.8",
4242
"ergebnis/composer-normalize": "^2.11",
43-
"ocramius/proxy-manager": "dev-allow-php-8 as 2.10.99",
43+
"ocramius/proxy-manager": "^2.11.1",
4444
"phpunit/phpunit": "^9.3",
4545
"simple-bus/doctrine-orm-bridge": "^5.0",
46-
"symfony/framework-bundle": "^4.4 || ^5.1",
47-
"symfony/monolog-bridge": "^4.4 || ^5.1",
46+
"symfony/framework-bundle": "^4.4 || ^5.2",
47+
"symfony/monolog-bridge": "^4.4 || ^5.2",
4848
"symfony/monolog-bundle": "^3.4",
49-
"symfony/proxy-manager-bridge": "^4.4 || ^5.1"
49+
"symfony/proxy-manager-bridge": "^4.4 || ^5.2"
5050
},
5151
"suggest": {
5252
"doctrine/doctrine-bundle": "For integration with Doctrine ORM",
@@ -68,13 +68,6 @@
6868
"SimpleBus\\SymfonyBridge\\Tests\\": "tests"
6969
}
7070
},
71-
"repositories": [
72-
{
73-
"type": "vcs",
74-
"url": "https://github.com/greg0ire/ProxyManager.git",
75-
"description": "Use fork until PHP 8 is supported https://github.com/Ocramius/ProxyManager/pull/628"
76-
}
77-
],
7871
"minimum-stability": "dev",
7972
"prefer-stable": true
8073
}

src/DependencyInjection/CommandBusConfiguration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
class CommandBusConfiguration implements ConfigurationInterface
99
{
10-
private $alias;
10+
private string $alias;
1111

12-
public function __construct($alias)
12+
public function __construct(string $alias)
1313
{
1414
$this->alias = $alias;
1515
}
1616

17-
public function getConfigTreeBuilder()
17+
public function getConfigTreeBuilder(): TreeBuilder
1818
{
1919
$treeBuilder = new TreeBuilder($this->alias);
2020
$rootNode = $treeBuilder->getRootNode();

src/DependencyInjection/CommandBusExtension.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,30 @@
99

1010
class CommandBusExtension extends ConfigurableExtension
1111
{
12-
private $alias;
12+
private string $alias;
1313

14-
public function __construct($alias)
14+
public function __construct(string $alias)
1515
{
1616
$this->alias = $alias;
1717
}
1818

19-
public function getAlias()
19+
public function getAlias(): string
2020
{
2121
return $this->alias;
2222
}
2323

24-
public function getConfiguration(array $config, ContainerBuilder $container)
24+
/**
25+
* @param mixed[] $config
26+
*/
27+
public function getConfiguration(array $config, ContainerBuilder $container): CommandBusConfiguration
2528
{
2629
return new CommandBusConfiguration($this->getAlias());
2730
}
2831

29-
protected function loadInternal(array $mergedConfig, ContainerBuilder $container)
32+
/**
33+
* @param mixed[] $mergedConfig
34+
*/
35+
protected function loadInternal(array $mergedConfig, ContainerBuilder $container): void
3036
{
3137
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
3238

src/DependencyInjection/Compiler/AddMiddlewareTags.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,34 @@
22

33
namespace SimpleBus\SymfonyBridge\DependencyInjection\Compiler;
44

5+
use LogicException;
56
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
67
use Symfony\Component\DependencyInjection\ContainerBuilder;
78

89
class AddMiddlewareTags implements CompilerPassInterface
910
{
10-
const MESSAGE_BUS_TAG = 'message_bus';
11+
private const MESSAGE_BUS_TAG = 'message_bus';
1112

12-
/**
13-
* @var string
14-
*/
15-
private $middlewareServiceId;
13+
private string $middlewareServiceId;
1614

1715
/**
18-
* @var array
16+
* @var string[]
1917
*/
20-
private $addTagForMessageBusesOfTypes;
18+
private array $addTagForMessageBusesOfTypes;
19+
20+
private int $middlewarePriority;
2121

2222
/**
23-
* @var int
23+
* @param string[] $addTagForMessageBusesOfTypes
2424
*/
25-
private $middlewarePriority;
26-
27-
public function __construct($middlewareServiceId, array $addTagForMessageBusesOfTypes, $middlewarePriority)
25+
public function __construct(string $middlewareServiceId, array $addTagForMessageBusesOfTypes, int $middlewarePriority)
2826
{
2927
$this->middlewareServiceId = $middlewareServiceId;
3028
$this->addTagForMessageBusesOfTypes = $addTagForMessageBusesOfTypes;
3129
$this->middlewarePriority = $middlewarePriority;
3230
}
3331

34-
public function process(ContainerBuilder $container)
32+
public function process(ContainerBuilder $container): void
3533
{
3634
if (!($container->has($this->middlewareServiceId))) {
3735
return;
@@ -67,10 +65,13 @@ public function process(ContainerBuilder $container)
6765
}
6866
}
6967

70-
private function getAttribute(array $tagAttributes, $attribute, $tag, $serviceId)
68+
/**
69+
* @param array<string, string> $tagAttributes
70+
*/
71+
private function getAttribute(array $tagAttributes, string $attribute, string $tag, string $serviceId): string
7172
{
7273
if (!isset($tagAttributes[$attribute])) {
73-
throw new \LogicException(sprintf('Tag "%s" of service "%s" should have an attribute "%s"', $tag, $serviceId, $attribute));
74+
throw new LogicException(sprintf('Tag "%s" of service "%s" should have an attribute "%s"', $tag, $serviceId, $attribute));
7475
}
7576

7677
return $tagAttributes[$attribute];

src/DependencyInjection/Compiler/AutoRegister.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,24 @@
22

33
namespace SimpleBus\SymfonyBridge\DependencyInjection\Compiler;
44

5+
use ReflectionClass;
6+
use ReflectionMethod;
7+
use ReflectionNamedType;
58
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
69
use Symfony\Component\DependencyInjection\ContainerBuilder;
710

811
final class AutoRegister implements CompilerPassInterface
912
{
10-
private $tagName;
11-
private $tagAttribute;
13+
private string $tagName;
14+
private string $tagAttribute;
1215

13-
public function __construct($tagName, $tagAttribute)
16+
public function __construct(string $tagName, string $tagAttribute)
1417
{
1518
$this->tagName = $tagName;
1619
$this->tagAttribute = $tagAttribute;
1720
}
1821

19-
public function process(ContainerBuilder $container)
22+
public function process(ContainerBuilder $container): void
2023
{
2124
foreach ($container->findTaggedServiceIds($this->tagName) as $serviceId => $tags) {
2225
foreach ($tags as $tagAttributes) {
@@ -33,9 +36,10 @@ public function process(ContainerBuilder $container)
3336
$definition = $container->getDefinition($serviceId);
3437

3538
// check if service id is class name
36-
$reflectionClass = new \ReflectionClass($definition->getClass() ?: $serviceId);
39+
/** @phpstan-ignore-next-line */
40+
$reflectionClass = new ReflectionClass($definition->getClass() ?: $serviceId);
3741

38-
$methods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC);
42+
$methods = $reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC);
3943

4044
$tagAttributes = [];
4145
foreach ($methods as $method) {
@@ -54,12 +58,17 @@ public function process(ContainerBuilder $container)
5458
$parameters = $method->getParameters();
5559

5660
// if no param, optional param or non-class param, skip
57-
if (1 !== count($parameters) || $parameters[0]->isOptional() || null === $parameters[0]->getType()) {
61+
if (1 !== count($parameters) || $parameters[0]->isOptional()) {
62+
continue;
63+
}
64+
65+
$type = $parameters[0]->getType();
66+
if (null === $type || !$type instanceof ReflectionNamedType) {
5867
continue;
5968
}
6069

6170
// get the class name
62-
$handles = $parameters[0]->getType()->getName();
71+
$handles = $type->getName();
6372

6473
$tagAttributes[] = [
6574
$this->tagAttribute => $handles,

src/DependencyInjection/Compiler/CollectServices.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22

33
namespace SimpleBus\SymfonyBridge\DependencyInjection\Compiler;
44

5+
use InvalidArgumentException;
56
use Symfony\Component\DependencyInjection\ContainerBuilder;
67

78
trait CollectServices
89
{
910
protected function collectServiceIds(
1011
ContainerBuilder $container,
11-
$tagName,
12-
$keyAttribute,
12+
string $tagName,
13+
string $keyAttribute,
1314
callable $callback
14-
) {
15+
): void {
1516
foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $tags) {
1617
foreach ($tags as $tagAttributes) {
1718
if (!isset($tagAttributes[$keyAttribute])) {
18-
throw new \InvalidArgumentException(sprintf('The attribute "%s" of tag "%s" of service "%s" is mandatory', $keyAttribute, $tagName, $serviceId));
19+
throw new InvalidArgumentException(sprintf('The attribute "%s" of tag "%s" of service "%s" is mandatory', $keyAttribute, $tagName, $serviceId));
1920
}
2021

2122
$key = $tagAttributes[$keyAttribute];

src/DependencyInjection/Compiler/ConfigureMiddlewares.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,29 @@
22

33
namespace SimpleBus\SymfonyBridge\DependencyInjection\Compiler;
44

5+
use SplPriorityQueue;
56
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
67
use Symfony\Component\DependencyInjection\ContainerBuilder;
78
use Symfony\Component\DependencyInjection\Reference;
89

910
class ConfigureMiddlewares implements CompilerPassInterface
1011
{
11-
private $mainBusId;
12-
private $busTag;
12+
private string $mainBusId;
13+
private string $busTag;
1314

14-
public function __construct($mainBusId, $busTag)
15+
public function __construct(string $mainBusId, string $busTag)
1516
{
1617
$this->mainBusId = $mainBusId;
1718
$this->busTag = $busTag;
1819
}
1920

20-
public function process(ContainerBuilder $container)
21+
public function process(ContainerBuilder $container): void
2122
{
2223
if (!$container->has($this->mainBusId)) {
2324
return;
2425
}
2526

26-
$middlewareIds = new \SplPriorityQueue();
27+
$middlewareIds = new SplPriorityQueue();
2728

2829
foreach ($container->findTaggedServiceIds($this->busTag) as $specializedBusId => $tags) {
2930
foreach ($tags as $tagAttributes) {

src/DependencyInjection/Compiler/RegisterHandlers.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ class RegisterHandlers implements CompilerPassInterface
1010
{
1111
use CollectServices;
1212

13-
private $callableServiceId;
14-
private $serviceLocatorId;
15-
private $tag;
16-
private $keyAttribute;
13+
private string $callableServiceId;
14+
private string $serviceLocatorId;
15+
private string $tag;
16+
private string $keyAttribute;
1717

1818
/**
1919
* @param string $callableServiceId The service id of the MessageHandlerMap
2020
* @param string $serviceLocatorId The service id of the ServiceLocator
2121
* @param string $tag The tag name of message handler services
2222
* @param string $keyAttribute The name of the tag attribute that contains the name of the handler
2323
*/
24-
public function __construct($callableServiceId, $serviceLocatorId, $tag, $keyAttribute)
24+
public function __construct(string $callableServiceId, string $serviceLocatorId, string $tag, string $keyAttribute)
2525
{
2626
$this->callableServiceId = $callableServiceId;
2727
$this->serviceLocatorId = $serviceLocatorId;
@@ -33,7 +33,7 @@ public function __construct($callableServiceId, $serviceLocatorId, $tag, $keyAtt
3333
* Search for message handler services and provide them as a constructor argument to the message handler map
3434
* service.
3535
*/
36-
public function process(ContainerBuilder $container)
36+
public function process(ContainerBuilder $container): void
3737
{
3838
if (!$container->has($this->callableServiceId)) {
3939
return;

src/DependencyInjection/Compiler/RegisterMessageRecorders.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88

99
class RegisterMessageRecorders implements CompilerPassInterface
1010
{
11-
private $aggregatorId;
12-
private $recorderTag;
11+
private string $aggregatorId;
12+
private string $recorderTag;
1313

1414
/**
1515
* @param string $aggregatorId The id of the service with class AggregatesRecordedMessages
1616
* @param string $recorderTag The tag name of message recorder services
1717
*/
18-
public function __construct($aggregatorId, $recorderTag)
18+
public function __construct(string $aggregatorId, string $recorderTag)
1919
{
2020
$this->aggregatorId = $aggregatorId;
2121
$this->recorderTag = $recorderTag;
2222
}
2323

24-
public function process(ContainerBuilder $container)
24+
public function process(ContainerBuilder $container): void
2525
{
2626
if (!$container->has($this->aggregatorId)) {
2727
return;

src/DependencyInjection/Compiler/RegisterSubscribers.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ class RegisterSubscribers implements CompilerPassInterface
1010
{
1111
use CollectServices;
1212

13-
private $callableServiceId;
14-
private $serviceLocatorId;
15-
private $tag;
16-
private $keyAttribute;
13+
private string $callableServiceId;
14+
private string $serviceLocatorId;
15+
private string $tag;
16+
private string $keyAttribute;
1717

1818
/**
1919
* @param string $callableServiceId The service id of the MessageSubscriberCollection
2020
* @param string $serviceLocatorId The service id of the ServiceLocator
2121
* @param string $tag The tag name of message subscriber services
2222
* @param string $keyAttribute The name of the tag attribute that contains the name of the subscriber
2323
*/
24-
public function __construct($callableServiceId, $serviceLocatorId, $tag, $keyAttribute)
24+
public function __construct(string $callableServiceId, string $serviceLocatorId, string $tag, string $keyAttribute)
2525
{
2626
$this->callableServiceId = $callableServiceId;
2727
$this->serviceLocatorId = $serviceLocatorId;
@@ -33,7 +33,7 @@ public function __construct($callableServiceId, $serviceLocatorId, $tag, $keyAtt
3333
* Search for message subscriber services and provide them as a constructor argument to the message subscriber
3434
* collection service.
3535
*/
36-
public function process(ContainerBuilder $container)
36+
public function process(ContainerBuilder $container): void
3737
{
3838
if (!$container->has($this->callableServiceId)) {
3939
return;

0 commit comments

Comments
 (0)