From 5e5689467f1f223dc3c794937a265f09e12bb856 Mon Sep 17 00:00:00 2001 From: zfs Date: Sun, 15 Dec 2013 22:58:54 +0100 Subject: [PATCH 1/3] Prettified output of Zend\Code\Genator\ValueGenerator for multi-line arrays --- library/Zend/Code/Generator/ValueGenerator.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/library/Zend/Code/Generator/ValueGenerator.php b/library/Zend/Code/Generator/ValueGenerator.php index 6150da8b6b8..a54e42e1f2b 100644 --- a/library/Zend/Code/Generator/ValueGenerator.php +++ b/library/Zend/Code/Generator/ValueGenerator.php @@ -351,12 +351,8 @@ public function generate() break; case self::TYPE_ARRAY: $output .= 'array('; - $curArrayMultiblock = false; - if (count($value) > 1) { - $curArrayMultiblock = true; - if ($this->outputMode == self::OUTPUT_MULTIPLE_LINE) { - $output .= self::LINE_FEED . str_repeat($this->indentation, $this->arrayDepth + 1); - } + if ($this->outputMode == self::OUTPUT_MULTIPLE_LINE) { + $output .= self::LINE_FEED . str_repeat($this->indentation, $this->arrayDepth + 1); } $outputParts = array(); $noKeyIndex = 0; @@ -384,8 +380,8 @@ public function generate() ? self::LINE_FEED . str_repeat($this->indentation, $this->arrayDepth + 1) : ' '; $output .= implode(',' . $padding, $outputParts); - if ($curArrayMultiblock == true && $this->outputMode == self::OUTPUT_MULTIPLE_LINE) { - $output .= self::LINE_FEED . str_repeat($this->indentation, $this->arrayDepth + 1); + if ($this->outputMode == self::OUTPUT_MULTIPLE_LINE) { + $output .= self::LINE_FEED . str_repeat($this->indentation, $this->arrayDepth); } $output .= ')'; break; From 0413da7532bc8e28e18527af18ac1ad9875cfb90 Mon Sep 17 00:00:00 2001 From: Ralf Eggert Date: Mon, 16 Dec 2013 07:01:02 +0100 Subject: [PATCH 2/3] Corrected ValueGeneratorTest --- .../Code/Generator/ValueGeneratorTest.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tests/ZendTest/Code/Generator/ValueGeneratorTest.php b/tests/ZendTest/Code/Generator/ValueGeneratorTest.php index efc3f82a10c..5be5c945f21 100644 --- a/tests/ZendTest/Code/Generator/ValueGeneratorTest.php +++ b/tests/ZendTest/Code/Generator/ValueGeneratorTest.php @@ -40,9 +40,15 @@ public function testPropertyDefaultValueCanHandleStrings() public function testPropertyDefaultValueCanHandleArray() { + $expectedSource = <<setValue(array('foo')); - $this->assertEquals('array(\'foo\')', $valueGenerator->generate()); + $this->assertEquals($expectedSource, $valueGenerator->generate()); } public function testPropertyDefaultValueCanHandleUnquotedString() @@ -95,10 +101,10 @@ public function testPropertyDefaultValueCanHandleComplexArrayOfTypes() 'baz1', 'baz2', 'constant2' => ArrayObject::STD_PROP_LIST - ) - ), + ) + ), PHP_EOL - ) + ) EOS; $valueGenerator = new ValueGenerator(); @@ -127,7 +133,7 @@ public function testPropertyDefaultValueCanHandleArrayWithUnsortedKeys() 'c', 7 => 'd', 3 => 'e' - ) + ) EOS; $this->assertEquals($expectedSource, $valueGenerator->generate()); From c28f71ab7ff13d120dd929f6eced31218dc7e7c3 Mon Sep 17 00:00:00 2001 From: Ralf Eggert Date: Mon, 16 Dec 2013 21:17:40 +0100 Subject: [PATCH 3/3] Corrected another failing test --- tests/ZendTest/Code/Generator/PropertyGeneratorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ZendTest/Code/Generator/PropertyGeneratorTest.php b/tests/ZendTest/Code/Generator/PropertyGeneratorTest.php index bd688ce16d3..e855320c4f8 100644 --- a/tests/ZendTest/Code/Generator/PropertyGeneratorTest.php +++ b/tests/ZendTest/Code/Generator/PropertyGeneratorTest.php @@ -105,7 +105,7 @@ public function testPropertyMultilineValue() 'null' => null, 'true' => true, 'bar\'s' => 'bar\'s' - ); + ); EOS; $property = new PropertyGenerator('myFoo', $targetValue);