Skip to content

Commit

Permalink
[DependencyInjection]: Added type to @method declaration, move values…
Browse files Browse the repository at this point in the history
… to constants
  • Loading branch information
fractalzombie committed Aug 15, 2022
1 parent ad264d4 commit 399d6cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Compiler/AbstractRegisterAttributePass.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*
* @author Mykhailo Shtanko <fractalzombie@gmail.com>
*
* @method register(ContainerBuilder $container, \ReflectionClass $reflectionClass, \Attribute $attribute): void
* @method void register(ContainerBuilder $container, \ReflectionClass $reflectionClass, \Attribute $attribute)
*/
abstract class AbstractRegisterAttributePass implements CompilerPassInterface
{
Expand Down
7 changes: 5 additions & 2 deletions Helper/DefinitionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#[Immutable]
final class DefinitionHelper
{
private const SERVICE_PREFIX = '@';
private const EMPTY_STRING = '';

private function __construct()
{
}
Expand All @@ -30,8 +33,8 @@ public static function mapDefinitionArguments(ContainerBuilder $container, array
{
$definitionsById = HashMap::collect($arguments)
->filter(static fn (Entry $e) => \is_string($e->value))
->filter(static fn (Entry $e) => str_contains($e->value, '@'))
->map(static fn (Entry $e) => str_replace('@', '', $e->value))
->filter(static fn (Entry $e) => str_contains($e->value, self::SERVICE_PREFIX))
->map(static fn (Entry $e) => str_replace(self::SERVICE_PREFIX, self::EMPTY_STRING, $e->value))
->filter(static fn (Entry $e) => $container->hasDefinition($e->value))
->map(static fn (Entry $e) => new Reference((string) $e->value))
->toAssocArray()
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 399d6cb

Please sign in to comment.