66
77use Ray \Aop \AbstractMatcher ;
88use Ray \Aop \Matcher ;
9+ use Ray \Aop \Pointcut ;
910use Ray \Aop \PriorityPointcut ;
1011
1112abstract class AbstractModule
@@ -21,7 +22,7 @@ abstract class AbstractModule
2122 protected $ lastModule ;
2223
2324 /**
24- * @var Container
25+ * @var ? Container
2526 */
2627 private $ container ;
2728
@@ -30,6 +31,7 @@ public function __construct(
3031 ) {
3132 $ this ->lastModule = $ module ;
3233 $ this ->activate ();
34+ assert ($ this ->container instanceof Container);
3335 if ($ module instanceof self) {
3436 $ this ->container ->merge ($ module ->getContainer ());
3537 }
@@ -53,14 +55,12 @@ public function install(self $module) : void
5355 */
5456 public function override (self $ module ) : void
5557 {
56- $ module ->getContainer ()->merge ($ this ->container );
58+ $ module ->getContainer ()->merge ($ this ->getContainer () );
5759 $ this ->container = $ module ->getContainer ();
5860 }
5961
6062 /**
61- * Return container
62- *
63- * @psalm-suppress DocblockTypeContradiction
63+ * Return activated container
6464 */
6565 public function getContainer () : Container
6666 {
@@ -74,26 +74,28 @@ public function getContainer() : Container
7474 /**
7575 * Bind interceptor
7676 *
77- * @param string[] $interceptors
77+ * @param array<class- string<\Ray\Aop\MethodInterceptor>> $interceptors
7878 */
7979 public function bindInterceptor (AbstractMatcher $ classMatcher , AbstractMatcher $ methodMatcher , array $ interceptors ) : void
8080 {
8181 $ pointcut = new Pointcut ($ classMatcher , $ methodMatcher , $ interceptors );
82- $ this ->container ->addPointcut ($ pointcut );
82+ $ this ->getContainer () ->addPointcut ($ pointcut );
8383 foreach ($ interceptors as $ interceptor ) {
84- (new Bind ($ this ->container , $ interceptor ))->to ($ interceptor )->in (Scope::SINGLETON );
84+ (new Bind ($ this ->getContainer () , $ interceptor ))->to ($ interceptor )->in (Scope::SINGLETON );
8585 }
8686 }
8787
8888 /**
8989 * Bind interceptor early
90+ *
91+ * @param array<class-string<\Ray\Aop\MethodInterceptor>> $interceptors
9092 */
9193 public function bindPriorityInterceptor (AbstractMatcher $ classMatcher , AbstractMatcher $ methodMatcher , array $ interceptors ) : void
9294 {
9395 $ pointcut = new PriorityPointcut ($ classMatcher , $ methodMatcher , $ interceptors );
94- $ this ->container ->addPointcut ($ pointcut );
96+ $ this ->getContainer () ->addPointcut ($ pointcut );
9597 foreach ($ interceptors as $ interceptor ) {
96- (new Bind ($ this ->container , $ interceptor ))->to ($ interceptor )->in (Scope::SINGLETON );
98+ (new Bind ($ this ->getContainer () , $ interceptor ))->to ($ interceptor )->in (Scope::SINGLETON );
9799 }
98100 }
99101
@@ -116,12 +118,14 @@ public function rename(string $interface, string $newName, string $sourceName =
116118 /**
117119 * Configure binding
118120 *
119- * @psalm-suppress MissingReturnType
121+ * @return void
120122 */
121123 abstract protected function configure ();
122124
123125 /**
124126 * Bind interface
127+ *
128+ * @phpstan-param class-string|string $interface
125129 */
126130 protected function bind (string $ interface = '' ) : Bind
127131 {
0 commit comments