Skip to content

Commit fa0ef67

Browse files
s3b4stianStyleCIBot
authored andcommitted
Apply fixes from StyleCI
1 parent d1edabc commit fa0ef67

File tree

4 files changed

+106
-89
lines changed

4 files changed

+106
-89
lines changed

src/TypedObjectArray.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class TypedObjectArray extends ArrayObject
3535
*/
3636
public function __construct(string $type, array $array = [])
3737
{
38-
if (!class_exists($type)){
39-
throw new InvalidArgumentException('Type passed to '.__CLASS__.' must be an existing class');
38+
if (!class_exists($type)) {
39+
throw new InvalidArgumentException('Type passed to '.__CLASS__.' must be an existing class');
4040
}
41-
41+
4242
//check elements of passed array
4343
//I will find another method
4444
foreach ($array as $element) {

tests/TypedArrayTest.php

Lines changed: 87 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@
1313
use PHPUnit\Framework\TestCase;
1414

1515
/**
16-
* Typed Array Test
16+
* Typed Array Test.
1717
*/
1818
class TypedArrayTest extends TestCase
1919
{
2020
/**
2121
* Provide allowed types.
22-
*
22+
*
2323
* @return array
2424
*/
25-
function allowedTypeProvider()
25+
public function allowedTypeProvider()
2626
{
2727
return [
2828
['array'],
@@ -34,7 +34,7 @@ function allowedTypeProvider()
3434
['string'],
3535
];
3636
}
37-
37+
3838
/**
3939
* Test new instance.
4040
*
@@ -44,7 +44,7 @@ public function testCreateInstance($type)
4444
{
4545
$this->assertInstanceOf(TypedArray::class, (new TypedArray($type)));
4646
}
47-
47+
4848
/**
4949
* Test new instance with not allowed type.
5050
*
@@ -54,26 +54,27 @@ public function testCreateInstanceWithNotAllowedType()
5454
{
5555
$this->assertInstanceOf(TypedArray::class, (new TypedArray('notAllowedType')));
5656
}
57-
58-
57+
5958
/**
6059
* Provide arrays of right typed values.
61-
*
60+
*
6261
* @return array
6362
*/
64-
function rightTypedArrayProvider()
63+
public function rightTypedArrayProvider()
6564
{
6665
return [
67-
['array', [[1],[2]]],
66+
['array', [[1], [2]]],
6867
['bool', [true, false]],
69-
['callable', [function(){}, function(){}]],
68+
['callable', [function () {
69+
}, function () {
70+
}]],
7071
['float', [1.1, 2.2]],
7172
['int', [1, 2]],
72-
['object', [(object)['name' => 'foo'], (object)['name' => 'bar']]],
73+
['object', [(object) ['name' => 'foo'], (object) ['name' => 'bar']]],
7374
['string', ['a', 'b']],
7475
];
7576
}
76-
77+
7778
/**
7879
* Test new instance passing right typed array to constructor.
7980
*
@@ -83,67 +84,77 @@ public function testCreateInstanceWithRightTypedArray($type, $array)
8384
{
8485
$this->assertInstanceOf(TypedArray::class, (new TypedArray($type, $array)));
8586
}
86-
87+
8788
/**
8889
* Provide arrays of wrong typed values.
89-
*
90+
*
9091
* @return array
9192
*/
92-
function wrongTypedArrayProvider()
93+
public function wrongTypedArrayProvider()
9394
{
9495
return [
9596
['array', [true, false]],
96-
['array', [function(){}, function(){}]],
97+
['array', [function () {
98+
}, function () {
99+
}]],
97100
['array', [1.1, 2.2]],
98101
['array', [1, 2]],
99-
['array', [(object)['name' => 'foo'], (object)['name' => 'bar']]],
102+
['array', [(object) ['name' => 'foo'], (object) ['name' => 'bar']]],
100103
['array', ['a', 'b']],
101-
102-
['bool', [[1],[2]]],
103-
['bool', [function(){}, function(){}]],
104+
105+
['bool', [[1], [2]]],
106+
['bool', [function () {
107+
}, function () {
108+
}]],
104109
['bool', [1.1, 2.2]],
105110
['bool', [1, 2]],
106-
['bool', [(object)['name' => 'foo'], (object)['name' => 'bar']]],
111+
['bool', [(object) ['name' => 'foo'], (object) ['name' => 'bar']]],
107112
['bool', ['a', 'b']],
108-
109-
['callable', [[1],[2]]],
113+
114+
['callable', [[1], [2]]],
110115
['callable', [true, false]],
111116
['callable', [1.1, 2.2]],
112117
['callable', [1, 2]],
113-
['callable', [(object)['name' => 'foo'], (object)['name' => 'bar']]],
114-
['callable', ['a', 'b']],
115-
116-
['float', [[1],[2]]],
118+
['callable', [(object) ['name' => 'foo'], (object) ['name' => 'bar']]],
119+
['callable', ['a', 'b']],
120+
121+
['float', [[1], [2]]],
117122
['float', [true, false]],
118-
['float', [function(){}, function(){}]],
123+
['float', [function () {
124+
}, function () {
125+
}]],
119126
['float', [1, 2]],
120-
['float', [(object)['name' => 'foo'], (object)['name' => 'bar']]],
127+
['float', [(object) ['name' => 'foo'], (object) ['name' => 'bar']]],
121128
['float', ['a', 'b']],
122-
123-
['int', [[1],[2]]],
129+
130+
['int', [[1], [2]]],
124131
['int', [true, false]],
125-
['int', [function(){}, function(){}]],
132+
['int', [function () {
133+
}, function () {
134+
}]],
126135
['int', [1.1, 2.2]],
127-
['int', [(object)['name' => 'foo'], (object)['name' => 'bar']]],
136+
['int', [(object) ['name' => 'foo'], (object) ['name' => 'bar']]],
128137
['int', ['a', 'b']],
129-
130-
['object', [[1],[2]]],
138+
139+
['object', [[1], [2]]],
131140
['object', [true, false]],
132141
//skip this because closure pass as object
133142
//['object', [function(){}, function(){}]],
134143
['object', [1.1, 2.2]],
135144
['object', [1, 2]],
136145
['object', ['a', 'b']],
137-
138-
['string', [[1],[2]]],
146+
147+
['string', [[1], [2]]],
139148
['string', [true, false]],
140-
['string', [function(){}, function(){}]],
149+
['string', [function () {
150+
}, function () {
151+
}]],
141152
['string', [1.1, 2.2]],
142153
['string', [1, 2]],
143-
['string', [(object)['name' => 'foo'], (object)['name' => 'bar']]],
154+
['string', [(object) ['name' => 'foo'], (object) ['name' => 'bar']]],
144155
];
145156
}
146-
157+
147158
/**
148159
* Test new instance passing array with invalid element to constructor.
149160
*
@@ -154,25 +165,26 @@ public function testCreateInstanceWithWrongTypedArray($type, $array)
154165
{
155166
$this->assertInstanceOf(TypedArray::class, (new TypedArray($type, $array)));
156167
}
157-
168+
158169
/**
159170
* Provide values of right types.
160-
*
171+
*
161172
* @return array
162173
*/
163-
function rightTypedValueProvider()
174+
public function rightTypedValueProvider()
164175
{
165176
return [
166-
['array',[1]],
177+
['array', [1]],
167178
['bool', true],
168-
['callable', function(){}],
179+
['callable', function () {
180+
}],
169181
['float', 1.1],
170182
['int', 1],
171-
['object',(object)['name' => 'foo']],
183+
['object', (object) ['name' => 'foo']],
172184
['string', 'a'],
173185
];
174186
}
175-
187+
176188
/**
177189
* Test assign to array a right typed value.
178190
*
@@ -185,67 +197,72 @@ public function testAssignrRightTypedValueToArray($type, $value)
185197

186198
$this->assertEquals(1, $array->count());
187199
}
188-
200+
189201
/**
190202
* Provide values of wrong types.
191-
*
203+
*
192204
* @return array
193205
*/
194-
function wrongTypedValueProvider()
206+
public function wrongTypedValueProvider()
195207
{
196208
return [
197209
['array', true],
198-
['array', function(){}],
210+
['array', function () {
211+
}],
199212
['array', 1.1],
200213
['array', 1],
201-
['array', (object)['name' => 'foo']],
214+
['array', (object) ['name' => 'foo']],
202215
['array', 'a'],
203-
216+
204217
['bool', [1]],
205-
['bool', function(){}],
218+
['bool', function () {
219+
}],
206220
['bool', 1.1],
207221
['bool', 1],
208-
['bool', (object)['name' => 'foo']],
222+
['bool', (object) ['name' => 'foo']],
209223
['bool', 'a'],
210-
224+
211225
['callable', [1]],
212226
['callable', true],
213227
['callable', 1.1],
214228
['callable', 1],
215-
['callable', (object)['name' => 'foo']],
216-
['callable', 'a'],
217-
229+
['callable', (object) ['name' => 'foo']],
230+
['callable', 'a'],
231+
218232
['float', [1]],
219233
['float', true],
220-
['float', function(){}],
234+
['float', function () {
235+
}],
221236
['float', 1],
222-
['float', (object)['name' => 'foo']],
237+
['float', (object) ['name' => 'foo']],
223238
['float', 'a'],
224-
239+
225240
['int', [1]],
226241
['int', true],
227-
['int', function(){}],
242+
['int', function () {
243+
}],
228244
['int', 1.1],
229-
['int', (object)['name' => 'foo']],
245+
['int', (object) ['name' => 'foo']],
230246
['int', 'a', 'b'],
231-
247+
232248
['object', [1]],
233249
['object', true],
234250
//skip this because closure pass as object
235251
//['object',[function(){}, function(){}]],
236252
['object', 1.1],
237253
['object', 1],
238254
['object', 'a'],
239-
255+
240256
['string', [1]],
241257
['string', true],
242-
['string', function(){}],
258+
['string', function () {
259+
}],
243260
['string', 1.1],
244261
['string', 1],
245-
['string', (object)['name' => 'foo']],
262+
['string', (object) ['name' => 'foo']],
246263
];
247264
}
248-
265+
249266
/**
250267
* Test assign to array a wrong typed value.
251268
*

0 commit comments

Comments
 (0)