Skip to content

Commit afcfb4d

Browse files
authored
refactor(container): rename #[Lazy] to #[Proxy] (#1180)
1 parent 9fb3dd4 commit afcfb4d

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/Tempest/Container/src/GenericContainer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ private function autowire(string $className, mixed ...$params): object
358358

359359
foreach ($classReflector->getProperties() as $property) {
360360
if ($property->hasAttribute(Inject::class) && ! $property->isInitialized($instance)) {
361-
if ($property->hasAttribute(Lazy::class)) {
361+
if ($property->hasAttribute(Proxy::class)) {
362362
$property->set($instance, $property->getType()->asClass()->getReflection()->newLazyProxy(
363363
fn () => $this->get($property->getType()->getName()),
364364
));
@@ -404,7 +404,7 @@ private function autowireDependency(ParameterReflector $parameter, ?string $tag,
404404
}
405405

406406
// Support lazy initialization
407-
$lazy = $parameter->hasAttribute(Lazy::class);
407+
$lazy = $parameter->hasAttribute(Proxy::class);
408408
// Loop through each type until we hit a match.
409409
foreach ($parameter->getType()->split() as $type) {
410410
try {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
* The container may then decide to do lazy initialization
1313
*/
1414
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_PARAMETER)]
15-
final readonly class Lazy
15+
final readonly class Proxy
1616
{
1717
}

src/Tempest/Container/tests/Fixtures/ClassWithLazySlowDependency.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
namespace Tempest\Container\Tests\Fixtures;
55

6-
use Tempest\Container\Lazy;
6+
use Tempest\Container\Proxy;
77

88
final readonly class ClassWithLazySlowDependency
99
{
1010
public function __construct(
11-
#[Lazy]
11+
#[Proxy]
1212
public SlowDependency $dependency,
1313
) {}
1414
}

src/Tempest/Container/tests/Fixtures/ClassWithLazySlowPropertyDependency.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
namespace Tempest\Container\Tests\Fixtures;
55

66
use Tempest\Container\Inject;
7-
use Tempest\Container\Lazy;
7+
use Tempest\Container\Proxy;
88

99
final class ClassWithLazySlowPropertyDependency
1010
{
1111
#[Inject]
12-
#[Lazy]
12+
#[Proxy]
1313
private(set) SlowDependency $dependency;
1414

1515
public function __construct() {}

0 commit comments

Comments
 (0)