@@ -32,8 +32,8 @@ class Container implements ContainerInterface {
32
32
* > $bindings The classname as key with array value of its concrete and whether to make it singleton or not.
33
33
*/
34
34
public function __construct (
35
- private array $ context = array () ,
36
- private array $ bindings = array () ,
35
+ private array $ context = [] ,
36
+ private array $ bindings = [] ,
37
37
) {}
38
38
39
39
/**
@@ -42,7 +42,7 @@ public function __construct(
42
42
* @template T of object
43
43
*/
44
44
public function set ( string $ id , string |callable |null $ concrete = null ): void {
45
- $ this ->bindings [ $ id ] = array ( $ concrete ?? $ id , false ) ;
45
+ $ this ->bindings [ $ id ] = [ $ concrete ?? $ id , false ] ;
46
46
}
47
47
48
48
/**
@@ -51,7 +51,7 @@ public function set( string $id, string|callable|null $concrete = null ): void {
51
51
* @template T of object
52
52
*/
53
53
public function setShared ( string $ id , string |callable |null $ concrete = null ): void {
54
- $ this ->bindings [ $ id ] = array ( $ concrete ?? $ id , true ) ;
54
+ $ this ->bindings [ $ id ] = [ $ concrete ?? $ id , true ] ;
55
55
}
56
56
57
57
/**
@@ -77,7 +77,7 @@ public function resolve( string $id, array $args, ?ReflectionClass $reflector =
77
77
return $ this ->instances [ $ id ]; // @phpstan-ignore-line
78
78
}
79
79
80
- [$ concrete , $ shared ] = $ this ->bindings [ $ id ] ?? array ( $ id , false ) ;
80
+ [$ concrete , $ shared ] = $ this ->bindings [ $ id ] ?? [ $ id , false ] ;
81
81
82
82
if ( is_callable ( $ concrete ) ) {
83
83
$ resolved = $ concrete ( $ this , $ args );
@@ -99,7 +99,7 @@ public function resolve( string $id, array $args, ?ReflectionClass $reflector =
99
99
}
100
100
101
101
$ resolved = $ reflector ->newInstanceArgs (
102
- array ( ...$ args , ...$ this ->getContextual ( $ id , ...$ constructor ->getParameters () ) )
102
+ [ ...$ args , ...$ this ->getContextual ( $ id , ...$ constructor ->getParameters () ) ]
103
103
);
104
104
105
105
$ resolved instanceof $ id || $ this ->unresolvableEntry ( $ id );
@@ -126,7 +126,7 @@ public function isInstance( string $id ): bool {
126
126
* @return T
127
127
* @template T of object
128
128
*/
129
- public function get ( string $ id , array $ args = array () ): mixed {
129
+ public function get ( string $ id , array $ args = [] ): mixed {
130
130
try {
131
131
return $ this ->resolve ( $ id , $ args );
132
132
} catch ( Exception $ e ) {
@@ -158,12 +158,12 @@ public function give( string $concrete ): void {
158
158
/** @return array<string,mixed> $resolved */
159
159
private function getContextual ( string $ id , ReflectionParameter ...$ params ): array {
160
160
if ( ! $ contextual = ( $ this ->context [ $ id ] ?? null ) ) {
161
- return array () ;
161
+ return [] ;
162
162
}
163
163
164
- $ dependencies = array () ;
164
+ $ dependencies = [] ;
165
165
$ paramTypeHints = array_reduce ( $ params , $ this ->toParamTypeByName ( ... ), $ dependencies );
166
- $ resolved = array () ;
166
+ $ resolved = [] ;
167
167
168
168
foreach ( $ paramTypeHints as $ paramName => $ abstract ) {
169
169
( $ concrete = ( $ contextual [ $ abstract ] ?? null ) )
@@ -180,7 +180,7 @@ private function getContextual( string $id, ReflectionParameter ...$params ): ar
180
180
private function toParamTypeByName ( array $ carry , ReflectionParameter $ param ): array {
181
181
$ type = ( $ t = $ param ->getType () ) instanceof ReflectionNamedType ? $ t ->getName () : '' ;
182
182
183
- return array ( ...$ carry , ...array ( $ param ->name => $ type ) ) ;
183
+ return [ ...$ carry , ...[ $ param ->name => $ type ] ] ;
184
184
}
185
185
186
186
private function unresolvableEntry ( string $ id ): never {
0 commit comments