Skip to content

Commit

Permalink
Improvements to standards task
Browse files Browse the repository at this point in the history
  • Loading branch information
billtomczak committed Jun 10, 2022
1 parent a782ae6 commit aa0b294
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/tasks/StandardsFixesTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,41 @@ function ($tag) {
foreach ($manifestHeaders as $header => &$value) {
$regex = sprintf('#(\s+)<%1$s>.*</%1$s>#', $header);
if (preg_match($regex, $manifestString, $match)) {
if (
in_array($header, ['creationDate', 'version'])
&& $this->manifest == $manifestPath
) {
// Set defaults for these when updating the primary extension
$this->manifestHeaders[$header] = trim($match[0]);
}

$divider = $match[1];
if ($value === null) {
// No default, copy to replacement string as-is
$value = $divider . trim($match[0]);

} else {
// Force to default
$value = $divider . $value;
}

$manifestString = str_replace($match[0], '', $manifestString);

} elseif ($value) {
// Force to default
$value = $divider . $value;

} elseif (in_array($header, ['name', 'description', 'copyright'])) {
// Require these
if ($header == 'copyright') {
// Replicate copyright from primary manifest
$mainManifest = $this->tryXmlFunctions(function () {
return simplexml_load_file($this->manifest);
});

$value = (string)$mainManifest->copyright;
}
$value = sprintf($divider . '<%1$s>%2$s</%1$s>', $header, $value ?? '');
}
}

Expand Down

0 comments on commit aa0b294

Please sign in to comment.