10
10
/**
11
11
* Trait InteractsWithInject
12
12
* @package think\annotation\traits
13
- * @property App $app
13
+ * @property App $app
14
14
* @property Reader $reader
15
15
*/
16
16
trait InteractsWithInject
@@ -29,7 +29,7 @@ protected function getDocReader()
29
29
protected function autoInject ()
30
30
{
31
31
if ($ this ->app ->config ->get ('annotation.inject.enable ' , true )) {
32
- $ this ->app ->resolving (function ($ object ) {
32
+ $ this ->app ->resolving (function ($ object, $ app ) {
33
33
34
34
if ($ this ->isInjectClass (get_class ($ object ))) {
35
35
@@ -42,12 +42,12 @@ protected function autoInject()
42
42
$ annotation = $ this ->reader ->getPropertyAnnotation ($ refProperty , Inject::class);
43
43
if ($ annotation ) {
44
44
if ($ annotation ->value ) {
45
- $ value = $ this -> app ->make ($ annotation ->value );
45
+ $ value = $ app ->make ($ annotation ->value );
46
46
} else {
47
47
//获取@var类名
48
48
$ propertyClass = $ reader ->getPropertyClass ($ refProperty );
49
49
if ($ propertyClass ) {
50
- $ value = $ this -> app ->make ($ propertyClass );
50
+ $ value = $ app ->make ($ propertyClass );
51
51
}
52
52
}
53
53
@@ -62,7 +62,7 @@ protected function autoInject()
62
62
}
63
63
64
64
if ($ refObject ->hasMethod ('__injected ' )) {
65
- $ this -> app ->invokeMethod ([$ object , '__injected ' ]);
65
+ $ app ->invokeMethod ([$ object , '__injected ' ]);
66
66
}
67
67
}
68
68
});
0 commit comments