Skip to content

Commit 2cd25f2

Browse files
committed
[Config] Builder: Remove typehints and allow for EnvConfigurator
1 parent aa6e8fd commit 2cd25f2

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

Loader/Configurator/AbstractConfigurator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

14+
use Symfony\Component\Config\Loader\ParamConfigurator;
1415
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
1516
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
1617
use Symfony\Component\DependencyInjection\Definition;
@@ -83,7 +84,7 @@ public static function processValue($value, $allowServices = false)
8384
return $def;
8485
}
8586

86-
if ($value instanceof EnvConfigurator) {
87+
if ($value instanceof ParamConfigurator) {
8788
return (string) $value;
8889
}
8990

Loader/Configurator/ContainerConfigurator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

14+
use Symfony\Component\Config\Loader\ParamConfigurator;
1415
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
1516
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
1617
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
@@ -96,9 +97,9 @@ final public function withPath(string $path): self
9697
/**
9798
* Creates a parameter.
9899
*/
99-
function param(string $name): string
100+
function param(string $name): ParamConfigurator
100101
{
101-
return '%'.$name.'%';
102+
return new ParamConfigurator($name);
102103
}
103104

104105
/**

Loader/Configurator/EnvConfigurator.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

14-
class EnvConfigurator
14+
use Symfony\Component\Config\Loader\ParamConfigurator;
15+
16+
class EnvConfigurator extends ParamConfigurator
1517
{
1618
/**
1719
* @var string[]
@@ -23,10 +25,7 @@ public function __construct(string $name)
2325
$this->stack = explode(':', $name);
2426
}
2527

26-
/**
27-
* @return string
28-
*/
29-
public function __toString()
28+
public function __toString(): string
3029
{
3130
return '%env('.implode(':', $this->stack).')%';
3231
}

Loader/PhpFileLoader.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ private function executeCallback(callable $callback, ContainerConfigurator $cont
128128
}
129129
}
130130

131+
// Force load ContainerConfigurator to make env(), param() etc available.
132+
class_exists(ContainerConfigurator::class);
133+
131134
$callback(...$arguments);
132135

133136
/** @var ConfigBuilderInterface $configBuilder */

0 commit comments

Comments
 (0)