Skip to content

Commit 7cc531d

Browse files
committed
Refine interceptor binding logic for weaved instances.
Ensure bindings are only set on instances implementing WeavedInterface. Replaces direct property access with method call `_setBindings` to improve encapsulation and maintainability.
1 parent d94b78b commit 7cc531d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/di/NewInstance.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Ray\Di;
66

77
use Ray\Aop\Bind as AopBind;
8+
use Ray\Aop\WeavedInterface;
89
use ReflectionClass;
910
use ReflectionException;
1011

@@ -95,9 +96,8 @@ public function accept(VisitorInterface $visitor): void
9596
private function postNewInstance(Container $container, object $instance): object
9697
{
9798
// bind dependency injected interceptors
98-
if ($this->bind instanceof AspectBind) {
99-
assert(isset($instance->bindings));
100-
$instance->bindings = $this->bind->inject($container);
99+
if ($this->bind instanceof AspectBind && $instance instanceof WeavedInterface) {
100+
$instance->_setBindings($this->bind->inject($container));
101101
}
102102

103103
// setter injection

0 commit comments

Comments
 (0)