diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig/Writer/PhpFormatter.php b/lib/internal/Magento/Framework/App/DeploymentConfig/Writer/PhpFormatter.php index b62f841d526aa..b419b3827e5ff 100644 --- a/lib/internal/Magento/Framework/App/DeploymentConfig/Writer/PhpFormatter.php +++ b/lib/internal/Magento/Framework/App/DeploymentConfig/Writer/PhpFormatter.php @@ -1,6 +1,6 @@ formatData($data, $comments) . "\n);\n"; + } + return " $value) { - $comment = ' '; if (!empty($comments[$key])) { - $comment = " /**\n * " . str_replace("\n", "\n * ", var_export($comments[$key], true)) . "\n */\n"; + $elements[] = $prefix . '/**'; + $elements[] = $prefix . ' * For the section: ' . $key; + + foreach (explode("\n", $comments[$key]) as $commentLine) { + $elements[] = $prefix . ' * ' . $commentLine; + } + + $elements[] = $prefix . " */"; + } + + $elements[] = $prefix . var_export($key, true) . ' => ' . + (!is_array($value) ? var_export($value, true) . ',' : ''); + + if (is_array($value)) { + $elements[] = $prefix . 'array ('; + $elements[] = $this->formatData($value, [], ' ' . $prefix); + $elements[] = $prefix . '),'; } - $space = is_array($value) ? " \n" : ' '; - $elements[] = $comment . var_export($key, true) . ' =>' . $space . var_export($value, true); } - return "assertEquals($expectedResult, $formatter->format($data, $comments)); } + /** + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ public function formatWithCommentDataProvider() { $array = [ @@ -45,9 +47,9 @@ public function formatWithCommentDataProvider() ]; $comments1 = ['ns2' => 'comment for namespace 2']; $comments2 = [ - 'ns1' => 'comment for namespace 1', - 'ns2' => "comment for namespace 2.\nNext comment for namespace 2", - 'ns3' => 'comment for namespace 3', + 'ns1' => 'comment for\' namespace 1', + 'ns2' => "comment for namespace 2.\nNext comment for' namespace 2", + 'ns3' => 'comment for" namespace 3', 'ns4' => 'comment for namespace 4', 'ns5' => 'comment for unexisted namespace 5', ]; @@ -68,7 +70,8 @@ public function formatWithCommentDataProvider() ), ), /** - * 'comment for namespace 2' + * For the section: ns2 + * comment for namespace 2 */ 'ns2' => array ( @@ -78,7 +81,7 @@ public function formatWithCommentDataProvider() ), ), 'ns3' => 'just text', - 'ns4' => 'just text' + 'ns4' => 'just text', ); TEXT; @@ -86,7 +89,8 @@ public function formatWithCommentDataProvider() array ( @@ -102,8 +106,9 @@ public function formatWithCommentDataProvider() ), ), /** - * 'comment for namespace 2. - * Next comment for namespace 2' + * For the section: ns2 + * comment for namespace 2. + * Next comment for' namespace 2 */ 'ns2' => array ( @@ -113,13 +118,15 @@ public function formatWithCommentDataProvider() ), ), /** - * 'comment for namespace 3' + * For the section: ns3 + * comment for" namespace 3 */ 'ns3' => 'just text', /** - * 'comment for namespace 4' + * For the section: ns4 + * comment for namespace 4 */ - 'ns4' => 'just text' + 'ns4' => 'just text', ); TEXT;