Skip to content

Commit 82ae839

Browse files
author
Jeremiah VALERIE
committed
refactor
1 parent 267651e commit 82ae839

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/Generator/AbstractTypeGenerator.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,17 @@ protected function varExport($var, $default = null, array $compilerNames = [])
151151
// handle multi-line strings
152152
$lines = explode("\n", $string);
153153
if (count($lines) > 1) {
154-
$firstLine = array_shift($lines) . "'" . ' . "\n"';
155-
$lastLine = "'" . array_pop($lines);
156-
$lines = array_map(function ($s) {
157-
return "'" . $s . "'" . ' . "\n"';
158-
}, $lines);
154+
$firstLine = sprintf('%s\' . "\n"', array_shift($lines));
155+
$lastLine = sprintf("'%s", array_pop($lines));
156+
$lines = array_map(
157+
function ($line) {
158+
return sprintf('\'%s\' . "\n"', $line);
159+
},
160+
$lines
161+
);
159162
array_unshift($lines, $firstLine);
160163
array_push($lines, $lastLine);
161-
$string = implode(" . ", $lines);
164+
$string = implode(' . ', $lines);
162165
}
163166

164167
return $string;

src/Generator/TypeGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ protected function generateDeprecationReason(array $value)
5555

5656
protected function generateDefaultValue(array $value)
5757
{
58-
if (!array_key_exists('defaultValue', $value)) {
58+
$key = 'defaultValue';
59+
if (!array_key_exists($key, $value)) {
5960
return '';
6061
}
61-
$defaultValue = $this->varExportFromArrayValue($value, 'defaultValue');
6262

63-
return "\n".'<spaces>\'defaultValue\' => '.$defaultValue.',';
63+
return sprintf("\n<spaces>'%s' => %s,", $key, $this->varExportFromArrayValue($value, $key));
6464
}
6565

6666
protected function generateType(array $value)

0 commit comments

Comments
 (0)