@@ -27,7 +27,7 @@ class AppTest
2727 */
2828 function test_array_access_with_provider ()
2929 {
30- $ app = new App ([], function ($ name ) { return 'foo ' == $ name ? 'bar ' : null ; } );
30+ $ app = new App ([], fn ($ name ) => 'foo ' == $ name ? 'bar ' : null );
3131
3232 $ this ->assertEquals ('bar ' , $ app ['foo ' ]);
3333 }
@@ -54,7 +54,7 @@ function test_config()
5454 */
5555 function test_invoke_with_provider ()
5656 {
57- $ app = new App ([], function () { return 'bar ' ; } );
57+ $ app = new App ([], fn () => 'bar ' );
5858
5959 $ this ->assertEquals ('bar ' , $ app ('foo ' ));
6060 }
@@ -76,38 +76,28 @@ function test_provider_and_scope()
7676 {
7777 $ app = new App ([
7878 Arg::SERVICES => [
79- 'var3 ' => function () { return 'foobar ' ; } ,
79+ 'var3 ' => fn () => 'foobar ' ,
8080 'var2 ' => [Config::class, new Args (['var3 ' => new Plugin ('var3 ' )])],
81- 'bat ' => function ($ var2 ) {
82- return $ var2 ['var3 ' ];
83- },
81+ 'bat ' => fn ($ var2 ) => $ var2 ['var3 ' ],
8482 Config::class => Config::class,
85- 'v3 ' => function () { return '6 ' ; } ,
83+ 'v3 ' => fn () => '6 ' ,
8684 'v2 ' => [Config::class, new Args (['v3 ' => new Plugin ('v3 ' )])],
87- 'var4 ' => function ($ v2 ) { return $ v2 ['v3 ' ]; } ,
85+ 'var4 ' => fn ($ v2 ) => $ v2 ['v3 ' ],
8886 'code ' => 1 ,
8987 'foo ' => new Plugins ([
9088 'home ' => 9 ,
9189 'var2 ' => new Plugin (Config::class, [new Args (['var3 ' => new Provide ('var4 ' )])]),
92- Config::class => function ($ argv ) {
93- return new Config ($ argv );
94- },
90+ Config::class => fn ($ argv ) => new Config ($ argv ),
9591 'code ' => 2 ,
9692 'bar ' => new Plugins ([
9793 'code ' => 5 ,
9894 Config::class => new Provide (Config::class), //Provide from parent
99- 'test ' => function ($ bat , $ code , $ home , $ var2 , Config $ config ) {
100- return function ($ param , $ param2 , Config $ config ) use ($ bat , $ code , $ home , $ var2 ) {
101- return $ bat . $ code . $ home . $ param . $ var2 ['var3 ' ] . $ param2 ;
102- };
103- },
104- 'baz ' => function () {
105- return function ($ param2 ) {
106- /** @var \Mvc5\Service\Plugin $this */
107-
108- return $ this ->call ('test ' , ['param ' => '3 ' , 'param2 ' => $ param2 ]);
109- };
110- }
95+ 'test ' => fn ($ bat , $ code , $ home , $ var2 , Config $ config ) =>
96+ fn ($ param , $ param2 , Config $ config ) =>
97+ $ bat . $ code . $ home . $ param . $ var2 ['var3 ' ] . $ param2 ,
98+ 'baz ' => fn () => fn ($ param2 ) => $ this ->call ('test ' , ['param ' => '3 ' , 'param2 ' => $ param2 ])
99+
100+
111101 ])
112102 ])
113103 ]
@@ -129,9 +119,7 @@ function test_scope()
129119 {
130120 $ app = new App ([
131121 'services ' => [
132- 'bar ' => function () {
133- return $ this ;
134- },
122+ 'bar ' => fn () => $ this ,
135123 'foo ' => new Plugin ('bar ' )
136124 ]
137125 ], null , true );
@@ -149,9 +137,7 @@ function test_custom_scope()
149137
150138 $ app = new App ([
151139 'services ' => [
152- 'bar ' => function () {
153- return $ this ;
154- },
140+ 'bar ' => fn () => $ this ,
155141 'foo ' => new Plugin ('bar ' )
156142 ]
157143 ], null , $ config );
@@ -167,12 +153,8 @@ function test_callable_closure_scope()
167153 {
168154 $ app = new App ([
169155 'services ' => [
170- 'bar ' => new Callback (function () {
171- return $ this ;
172- }),
173- 'foo ' => new Invoke (function () {
174- return $ this ;
175- }),
156+ 'bar ' => new Callback (fn () => $ this ),
157+ 'foo ' => new Invoke (fn () => $ this ),
176158 ]
177159 ], null , true );
178160
@@ -189,12 +171,8 @@ function test_callable_closure_custom_scope()
189171
190172 $ app = new App ([
191173 'services ' => [
192- 'bar ' => new Callback (function () {
193- return $ this ;
194- }),
195- 'foo ' => new Invoke (function () {
196- return $ this ;
197- }),
174+ 'bar ' => new Callback (fn () => $ this ),
175+ 'foo ' => new Invoke (fn () => $ this ),
198176 ]
199177 ], null , $ config );
200178
@@ -209,12 +187,8 @@ function test_callable_closure_without_scope()
209187 {
210188 $ app = new App ([
211189 'services ' => [
212- 'bar ' => new Callback (function () {
213- return $ this ;
214- }),
215- 'foo ' => new Invoke (function () {
216- return $ this ;
217- }),
190+ 'bar ' => new Callback (fn () => $ this ),
191+ 'foo ' => new Invoke (fn () => $ this ),
218192 ]
219193 ]);
220194
0 commit comments