Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 4696a0a

Browse files
committed
Merge branch 'hotfix/164'
Close #164 Fix #163
2 parents ecef1bc + f74f79c commit 4696a0a

File tree

3 files changed

+97
-1
lines changed

3 files changed

+97
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ All notable changes to this project will be documented in this file, in reverse
2222

2323
### Fixed
2424

25-
- Nothing.
25+
- [#164](https://github.com/zendframework/zend-code/pull/164) fixes indentation in multi-level arrays generated by `ValueGenerator`.
2626

2727
## 3.3.1 - 2018-08-13
2828

src/Generator/ValueGenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ public function generate()
361361
}
362362

363363
$curValue = new self($curValue, $newType, self::OUTPUT_MULTIPLE_LINE, $this->getConstants());
364+
$curValue->setIndentation($this->indentation);
364365
}
365366
}
366367

test/Generator/ValueGeneratorTest.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,85 @@ public function complexArray()
225225
return $this->generateArrayData($longOutput, $value);
226226
}
227227

228+
/**
229+
* Data provider for testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes test
230+
*/
231+
public function complexArrayWCustomIndent(): array
232+
{
233+
$value = [
234+
'5bcf08a0a5d20' => [
235+
'5bcf08a0a5d65' => [
236+
'5bcf08a0a5d9f' => [
237+
'5bcf08a0a5dd8' => [
238+
'5bcf08a0a5e11' => [
239+
'5bcf08a0a5e4f' => '5bcf08a0a5e8c',
240+
'5bcf08a0a5eca' => '5bcf08a0a5f05',
241+
'5bcf08a0a5f43' => '5bcf08a0a5f7f',
242+
'5bcf08a0a5fbd' => '5bcf08a0a5ff8',
243+
],
244+
],
245+
'5bcf08a0a603a' => [],
246+
'5bcf08a0a6062' => '5bcf08a0a609f',
247+
'5bcf08a0a60dc' => [
248+
'5bcf08a0a611b' => '5bcf08a0a6158',
249+
'5bcf08a0a6197' => [
250+
'5bcf08a0a61d7' => '5bcf08a0a6212',
251+
'5bcf08a0a6250' => '5bcf08a0a628c',
252+
'5bcf08a0a62cb' => '5bcf08a0a6306',
253+
],
254+
'5bcf08a0a6345' => [
255+
'5bcf08a0a637e' => '5bcf08a0a63b4',
256+
'5bcf08a0a63ee' => '5bcf08a0a642a',
257+
],
258+
'5bcf08a0a6449' => '5bcf08a0a6485',
259+
],
260+
],
261+
], '5bcf08a0a64c8' => '5bcf08a0a6540',
262+
'5bcf08a0a657f' => '5bcf08a0a65bf',
263+
],
264+
];
265+
266+
$longOutput = <<<EOS
267+
array(
268+
'5bcf08a0a5d20' => array(
269+
'5bcf08a0a5d65' => array(
270+
'5bcf08a0a5d9f' => array(
271+
'5bcf08a0a5dd8' => array(
272+
'5bcf08a0a5e11' => array(
273+
'5bcf08a0a5e4f' => '5bcf08a0a5e8c',
274+
'5bcf08a0a5eca' => '5bcf08a0a5f05',
275+
'5bcf08a0a5f43' => '5bcf08a0a5f7f',
276+
'5bcf08a0a5fbd' => '5bcf08a0a5ff8',
277+
),
278+
),
279+
'5bcf08a0a603a' => array(
280+
281+
),
282+
'5bcf08a0a6062' => '5bcf08a0a609f',
283+
'5bcf08a0a60dc' => array(
284+
'5bcf08a0a611b' => '5bcf08a0a6158',
285+
'5bcf08a0a6197' => array(
286+
'5bcf08a0a61d7' => '5bcf08a0a6212',
287+
'5bcf08a0a6250' => '5bcf08a0a628c',
288+
'5bcf08a0a62cb' => '5bcf08a0a6306',
289+
),
290+
'5bcf08a0a6345' => array(
291+
'5bcf08a0a637e' => '5bcf08a0a63b4',
292+
'5bcf08a0a63ee' => '5bcf08a0a642a',
293+
),
294+
'5bcf08a0a6449' => '5bcf08a0a6485',
295+
),
296+
),
297+
),
298+
'5bcf08a0a64c8' => '5bcf08a0a6540',
299+
'5bcf08a0a657f' => '5bcf08a0a65bf',
300+
),
301+
)
302+
EOS;
303+
304+
return $this->generateArrayData($longOutput, $value);
305+
}
306+
228307
/**
229308
* Data provider for testPropertyDefaultValueCanHandleArrayWithUnsortedKeys test
230309
*
@@ -338,6 +417,22 @@ public function testPropertyDefaultValueCanHandleComplexArrayOfTypes($type, arra
338417
self::assertEquals($expected, $valueGenerator->generate());
339418
}
340419

420+
/**
421+
* @dataProvider complexArrayWCustomIndent
422+
*/
423+
public function testPropertyDefaultValueCanHandleComplexArrayWCustomIndentOfTypes(
424+
string $type,
425+
array $value,
426+
string $expected
427+
): void {
428+
$valueGenerator = new ValueGenerator();
429+
$valueGenerator->setType($type);
430+
$valueGenerator->setValue($value);
431+
$valueGenerator->setIndentation("\t");
432+
433+
self::assertEquals($expected, $valueGenerator->generate());
434+
}
435+
341436
/**
342437
* @group 6023
343438
*

0 commit comments

Comments
 (0)