11<?php
2+
23namespace mle86 \Value \Tests ;
34
45use mle86 \Value \AbstractValue ;
@@ -23,19 +24,19 @@ class ValueTest extends TestCase
2324 protected static $ tw2 ;
2425
2526
26- public function validInputs () { return [
27+ public static function validInputs (): array { return [
2728 ["41111 " ],
2829 ["42020 " ],
2930 ]; }
3031
31- public function invalidInputs () { return [
32+ public static function invalidInputs (): array { return [
3233 [811 ],
3334 ["z " ],
3435 [array ("41111 " )],
3536 [null ],
3637 ]; }
3738
38- public function validInputs9 () { return [
39+ public static function validInputs9 (): array { return [
3940 ["91111 " ],
4041 ["92020 " ],
4142 ["93330 " ],
@@ -44,13 +45,12 @@ public function validInputs9() { return [
4445
4546 public function testClassExists ()
4647 {
47- $ class = 'mle86 \\Value \\AbstractValue ' ;
48- $ interface = 'mle86 \\Value \\Value ' ;
48+ $ class = 'mle86 \\Value \\AbstractValue ' ;
4949
5050 $ this ->assertTrue (class_exists ($ class ),
5151 "Class {$ class } not found! " );
52- $ this ->assertTrue (is_a ($ class , $ interface , true ),
53- "Class { $ class} does not implement the { $ interface } interface! " );
52+ $ this ->assertTrue (is_a (AbstractValue:: class, Value::class , true ),
53+ "Class " .AbstractValue:: class. " does not implement the " .Value::class. " interface! " );
5454 }
5555
5656 /**
@@ -111,9 +111,8 @@ public function testCrossInvalidInitializer($initializer)
111111
112112 /**
113113 * @depends testConstructor
114- * @return TestWrapper4
115114 */
116- public function testValue ()
115+ public function testValue (): TestWrapper4
117116 {
118117 $ vi = self ::validInputs ();
119118 $ initializer = $ vi [0 ][0 ];
@@ -200,9 +199,8 @@ public function testConstructorWithInstance()
200199
201200 /**
202201 * @depends testConstructor9
203- * @return TestWrapper9
204202 */
205- public function testWrap ()
203+ public function testWrap (): TestWrapper9
206204 {
207205 $ vi = self ::validInputs9 ();
208206 $ v = $ vi [0 ][0 ];
@@ -249,9 +247,8 @@ public function testWrapCrossInvalid($initializer)
249247
250248 /**
251249 * @depends testWrap
252- * @return TestWrapper9
253250 */
254- public function testRewrap (TestWrapper9 $ tw )
251+ public function testRewrap (TestWrapper9 $ tw ): TestWrapper9
255252 {
256253 $ tx = $ tw ;
257254 TestWrapper9::wrap ($ tx );
@@ -282,14 +279,14 @@ public function testRewrapInvalid(TestWrapper9 $tx)
282279 public function testWrapArray ()
283280 {
284281 $ vi = self ::validInputs ();
285- $ a = array (
282+ $ a = [
286283 'k1 ' => $ vi [0 ][0 ],
287284 'kk22 ' => $ vi [1 ][0 ],
288285 0 => self ::$ tw1 , // includes an instance
289- ) ;
286+ ] ;
290287
291288 $ orig_a = $ a ;
292- $ this ->assertTrue ((array_keys ($ a ) === array ( 'k1 ' , 'kk22 ' , 0 ) ));
289+ $ this ->assertTrue ((array_keys ($ a ) === [ 'k1 ' , 'kk22 ' , 0 ] ));
293290
294291 $ ret = TestWrapper4::wrapArray ($ a );
295292 /** @type TestWrapper4[] $a */
@@ -301,7 +298,7 @@ public function testWrapArray()
301298
302299 $ this ->assertSame (count ($ orig_a ), count ($ a ),
303300 "wrapArray() changed the array size! " );
304- $ this ->assertSame (array_keys ($ a ), array ( 'k1 ' , 'kk22 ' , 0 ) ,
301+ $ this ->assertSame (array_keys ($ a ), [ 'k1 ' , 'kk22 ' , 0 ] ,
305302 "wrapArray() did not preserve array indices! " );
306303
307304 $ this ->assertTrue (
@@ -322,10 +319,10 @@ public function testWrapArray()
322319 */
323320 public function testWrapArray_empty ()
324321 {
325- $ e = array () ;
322+ $ e = [] ;
326323 $ ret = TestWrapper9::wrapArray ($ e );
327324
328- $ this ->assertSame (array () , $ e , "wrapArray() did not leave an empty array untouched! " );
325+ $ this ->assertSame ([] , $ e , "wrapArray() did not leave an empty array untouched! " );
329326 $ this ->assertSame ($ e , $ ret , "wrapArray([]) handled its argument correctly, but returned something else! " );
330327 }
331328
@@ -337,11 +334,11 @@ public function testWrapArray_invalids($invalid_initializer)
337334 {
338335 $ vi = self ::validInputs9 ();
339336
340- $ a = array (
337+ $ a = [
341338 $ vi [0 ][0 ],
342339 $ invalid_initializer ,
343340 'j ' => $ vi [2 ][0 ],
344- ) ;
341+ ] ;
345342
346343 $ orig_a = $ a ;
347344
@@ -389,12 +386,12 @@ public function testWrapOrNull()
389386 */
390387 public function testWrapOrNullArray ()
391388 {
392- $ vi = self ::validInputs ();
393- $ a = array (
389+ $ vi = self ::validInputs ();
390+ $ a = [
394391 'k1 ' => $ vi [0 ][0 ],
395392 'k2 ' => null ,
396393 'k3 ' => $ vi [1 ][0 ],
397- ) ;
394+ ] ;
398395 $ orig_a = $ a ;
399396
400397 TestWrapper4::wrapOrNullArray ($ a );
@@ -412,7 +409,7 @@ public function testWrapOrNullArray()
412409 }
413410
414411
415- public function additionalPropertyValues () { return [
412+ public static function additionalPropertyValues (): array { return [
416413 [0 ],
417414 [\PHP_INT_MAX ],
418415 [false ],
@@ -424,9 +421,8 @@ public function additionalPropertyValues() { return [
424421 * Tries to instantiate a wrapper object from an extended class, i.e. it has additional properties (for whatever reason).
425422 *
426423 * @depends testConstructor
427- * @return ExtTestWrapper4
428424 */
429- public function testExtendedObject ()
425+ public function testExtendedObject (): ExtTestWrapper4
430426 {
431427 $ vi = self ::validInputs ();
432428
0 commit comments