Skip to content

Commit

Permalink
Better generated PHP files code style (#31)
Browse files Browse the repository at this point in the history
Generated PHP files with source and translations now respect better code standards:

New line at end of file.
Coma after the last item of array.
  • Loading branch information
MichaelHoste authored May 12, 2022
1 parent 8c5a702 commit 6d3b19a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PrettyVarExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function call($var, array $opts = [])
. ($indexed ? '' : str_pad($key, $maxLength) . ' => ')
. $this->call($value, array_merge($opts, ['indent' => $opts['indent'] . $opts['tab']]));
}
return "[\n" . implode(",\n", $r) . "\n" . $opts['indent'] . "]";
return "[\n" . implode(",\n", $r) . ",\n" . $opts['indent'] . "]";
case 'boolean':
return $var ? 'true' : 'false';
case 'NULL':
Expand Down
2 changes: 2 additions & 0 deletions src/SourceSaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ public function call($sourceEdit, $sourceLocale)

$translations = $this->applySourceEditInTranslations($translations, $sourceEdit);

// Leave the extra newline at the end
$fileContent = <<<'EOT'
<?php
return {{translations}};

EOT;

$prettyTranslationsExport = $this->prettyVarExport->call($translations, ['array-align' => true]);
Expand Down
2 changes: 2 additions & 0 deletions src/TranslationSaver.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,11 @@ private function save($locale, $group, $translations)

$this->filesystem->makeDirectory($dir, 0777, true, true);

// Leave the extra newline at the end
$fileContent = <<<'EOT'
<?php
return {{translations}};

EOT;

$prettyTranslationsExport = $this->prettyVarExport->call($translations, ['array-align' => true]);
Expand Down

0 comments on commit 6d3b19a

Please sign in to comment.