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

Commit

Permalink
Merge branch 'hotfix/#7135-remove-deprecated-preg-operations-from-cla…
Browse files Browse the repository at this point in the history
…ssmap-generator' into develop

Close #7135
Forward port #7135
  • Loading branch information
Ocramius committed Jan 18, 2015
2 parents cb98e7e + 542c11f commit 99e0bc0
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bin/classmap_generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@
// Exchange "array (" width "array("
$content = str_replace('array (', 'array(', $content);

// Identing array content
$content = preg_replace('(\n )', "\n ", $content);

// Align "=>" operators to match coding standard
preg_match_all('(\n\s+([^=]+)=>)', $content, $matches, PREG_SET_ORDER);
$maxWidth = 0;
Expand All @@ -228,7 +231,11 @@
$maxWidth = max($maxWidth, strlen($match[1]));
}

$content = preg_replace('(\n\s+([^=]+)=>)e', "'\n \\1' . str_repeat(' ', " . $maxWidth . " - strlen('\\1')) . '=>'", $content);
$content = preg_replace_callback('(\n\s+([^=]+)=>)', function ($matches) {
global $maxWidth;

return str_replace(' =>', str_repeat(' ', $maxWidth - strlen($matches[1])) . ' =>', $matches[0]);
}, $content);

// Make the file end by EOL
$content = rtrim($content, "\n") . "\n";
Expand Down

0 comments on commit 99e0bc0

Please sign in to comment.