Skip to content

Commit c067912

Browse files
authored
Merge pull request #13 from linna/b1.0.0
Restore b1.0.0
2 parents b1f0193 + 7d60140 commit c067912

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

composer.json

+5
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,10 @@
2626
"psr-4": {
2727
"Linna\\": "src/"
2828
}
29+
},
30+
"autoload-dev": {
31+
"psr-4": {
32+
"Linna\\Tests\\": "tests/"
33+
}
2934
}
3035
}

src/TypedArray.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class TypedArray extends ArrayObject
6565
public function __construct(string $type, array $array = [])
6666
{
6767
//single class, multi type support :)
68-
if (!isset($this->allowedTypes[$type])) {
68+
if (empty($this->allowedTypes[$type])) {
6969
throw new InvalidArgumentException(__CLASS__.': '.$type.' type passed to '.__METHOD__.' not supported.');
7070
}
7171

tests/TypedArrayTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*/
1010
declare(strict_types=1);
1111

12+
namespace Linna\Tests;
13+
1214
use Linna\TypedArray;
1315
use PHPUnit\Framework\TestCase;
1416

@@ -283,8 +285,6 @@ public function testIteratorClass()
283285
$arrayAsParam = ['a','b','c','d','e','f','g','h','i'];
284286
$array = new TypedArray('string', $arrayAsParam);
285287

286-
foreach ($array as $key => $value) {
287-
$this->assertEquals($value, $arrayAsParam[$key]);
288-
}
288+
$this->assertEquals($arrayAsParam, iterator_to_array($array));
289289
}
290290
}

tests/TypedObjectArrayTest.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
*/
1010
declare(strict_types=1);
1111

12+
namespace Linna\Tests;
13+
1214
use Linna\TypedObjectArray;
15+
use ArrayObject;
16+
use SplStack;
1317
use PHPUnit\Framework\TestCase;
1418

1519
/**
@@ -113,8 +117,6 @@ public function testIteratorClass()
113117

114118
$array = new TypedObjectArray(ArrayObject::class, $arrayAsParam);
115119

116-
foreach ($array as $key => $value) {
117-
$this->assertEquals($value, $arrayAsParam[$key]);
118-
}
120+
$this->assertEquals($arrayAsParam, iterator_to_array($array));
119121
}
120122
}

0 commit comments

Comments
 (0)