1
1
<?php
2
+
2
3
namespace mle86 \Value \Tests ;
3
4
4
5
use mle86 \Value \AbstractValue ;
@@ -23,19 +24,19 @@ class ValueTest extends TestCase
23
24
protected static $ tw2 ;
24
25
25
26
26
- public function validInputs () { return [
27
+ public static function validInputs (): array { return [
27
28
["41111 " ],
28
29
["42020 " ],
29
30
]; }
30
31
31
- public function invalidInputs () { return [
32
+ public static function invalidInputs (): array { return [
32
33
[811 ],
33
34
["z " ],
34
35
[array ("41111 " )],
35
36
[null ],
36
37
]; }
37
38
38
- public function validInputs9 () { return [
39
+ public static function validInputs9 (): array { return [
39
40
["91111 " ],
40
41
["92020 " ],
41
42
["93330 " ],
@@ -44,13 +45,12 @@ public function validInputs9() { return [
44
45
45
46
public function testClassExists ()
46
47
{
47
- $ class = 'mle86 \\Value \\AbstractValue ' ;
48
- $ interface = 'mle86 \\Value \\Value ' ;
48
+ $ class = 'mle86 \\Value \\AbstractValue ' ;
49
49
50
50
$ this ->assertTrue (class_exists ($ class ),
51
51
"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! " );
54
54
}
55
55
56
56
/**
@@ -111,9 +111,8 @@ public function testCrossInvalidInitializer($initializer)
111
111
112
112
/**
113
113
* @depends testConstructor
114
- * @return TestWrapper4
115
114
*/
116
- public function testValue ()
115
+ public function testValue (): TestWrapper4
117
116
{
118
117
$ vi = self ::validInputs ();
119
118
$ initializer = $ vi [0 ][0 ];
@@ -200,9 +199,8 @@ public function testConstructorWithInstance()
200
199
201
200
/**
202
201
* @depends testConstructor9
203
- * @return TestWrapper9
204
202
*/
205
- public function testWrap ()
203
+ public function testWrap (): TestWrapper9
206
204
{
207
205
$ vi = self ::validInputs9 ();
208
206
$ v = $ vi [0 ][0 ];
@@ -249,9 +247,8 @@ public function testWrapCrossInvalid($initializer)
249
247
250
248
/**
251
249
* @depends testWrap
252
- * @return TestWrapper9
253
250
*/
254
- public function testRewrap (TestWrapper9 $ tw )
251
+ public function testRewrap (TestWrapper9 $ tw ): TestWrapper9
255
252
{
256
253
$ tx = $ tw ;
257
254
TestWrapper9::wrap ($ tx );
@@ -282,14 +279,14 @@ public function testRewrapInvalid(TestWrapper9 $tx)
282
279
public function testWrapArray ()
283
280
{
284
281
$ vi = self ::validInputs ();
285
- $ a = array (
282
+ $ a = [
286
283
'k1 ' => $ vi [0 ][0 ],
287
284
'kk22 ' => $ vi [1 ][0 ],
288
285
0 => self ::$ tw1 , // includes an instance
289
- ) ;
286
+ ] ;
290
287
291
288
$ orig_a = $ a ;
292
- $ this ->assertTrue ((array_keys ($ a ) === array ( 'k1 ' , 'kk22 ' , 0 ) ));
289
+ $ this ->assertTrue ((array_keys ($ a ) === [ 'k1 ' , 'kk22 ' , 0 ] ));
293
290
294
291
$ ret = TestWrapper4::wrapArray ($ a );
295
292
/** @type TestWrapper4[] $a */
@@ -301,7 +298,7 @@ public function testWrapArray()
301
298
302
299
$ this ->assertSame (count ($ orig_a ), count ($ a ),
303
300
"wrapArray() changed the array size! " );
304
- $ this ->assertSame (array_keys ($ a ), array ( 'k1 ' , 'kk22 ' , 0 ) ,
301
+ $ this ->assertSame (array_keys ($ a ), [ 'k1 ' , 'kk22 ' , 0 ] ,
305
302
"wrapArray() did not preserve array indices! " );
306
303
307
304
$ this ->assertTrue (
@@ -322,10 +319,10 @@ public function testWrapArray()
322
319
*/
323
320
public function testWrapArray_empty ()
324
321
{
325
- $ e = array () ;
322
+ $ e = [] ;
326
323
$ ret = TestWrapper9::wrapArray ($ e );
327
324
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! " );
329
326
$ this ->assertSame ($ e , $ ret , "wrapArray([]) handled its argument correctly, but returned something else! " );
330
327
}
331
328
@@ -337,11 +334,11 @@ public function testWrapArray_invalids($invalid_initializer)
337
334
{
338
335
$ vi = self ::validInputs9 ();
339
336
340
- $ a = array (
337
+ $ a = [
341
338
$ vi [0 ][0 ],
342
339
$ invalid_initializer ,
343
340
'j ' => $ vi [2 ][0 ],
344
- ) ;
341
+ ] ;
345
342
346
343
$ orig_a = $ a ;
347
344
@@ -389,12 +386,12 @@ public function testWrapOrNull()
389
386
*/
390
387
public function testWrapOrNullArray ()
391
388
{
392
- $ vi = self ::validInputs ();
393
- $ a = array (
389
+ $ vi = self ::validInputs ();
390
+ $ a = [
394
391
'k1 ' => $ vi [0 ][0 ],
395
392
'k2 ' => null ,
396
393
'k3 ' => $ vi [1 ][0 ],
397
- ) ;
394
+ ] ;
398
395
$ orig_a = $ a ;
399
396
400
397
TestWrapper4::wrapOrNullArray ($ a );
@@ -412,7 +409,7 @@ public function testWrapOrNullArray()
412
409
}
413
410
414
411
415
- public function additionalPropertyValues () { return [
412
+ public static function additionalPropertyValues (): array { return [
416
413
[0 ],
417
414
[\PHP_INT_MAX ],
418
415
[false ],
@@ -424,9 +421,8 @@ public function additionalPropertyValues() { return [
424
421
* Tries to instantiate a wrapper object from an extended class, i.e. it has additional properties (for whatever reason).
425
422
*
426
423
* @depends testConstructor
427
- * @return ExtTestWrapper4
428
424
*/
429
- public function testExtendedObject ()
425
+ public function testExtendedObject (): ExtTestWrapper4
430
426
{
431
427
$ vi = self ::validInputs ();
432
428
0 commit comments