Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When generating .travis.yml files, cut off a PHP version's patch if not known to exist on travis #17

Merged
merged 1 commit into from
Nov 18, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ abstract class Generator
const DEFAULT_MINIMUM_PHP_VERSION_TO_TEST = '5.3.3';
const DEFAULT_MAXIMUM_PHP_VERSION_TO_TEST = '5.6';

private static $knownMinorPhpVersionsOnTravis = array('5.3.3');

/**
* @var string[]
*/
Expand Down Expand Up @@ -126,7 +128,8 @@ protected function configureView()
$this->view->setGenerateYmlCommand($thisConsoleCommand);

if (!empty($this->phpVersions)) {
$this->view->setPhpVersions($this->phpVersions);
$phpVersions = $this->getPhpVersionsKnownToExistOnTravis();
$this->view->setPhpVersions($phpVersions);
}

$outputYmlPath = $this->getTravisYmlOutputPath();
Expand Down Expand Up @@ -255,4 +258,24 @@ private function setMinimumPhpVersionFromPhpVersions()
usort($phpVersions, 'version_compare');
$this->minimumPhpVersion = reset($phpVersions);
}

private function getPhpVersionsKnownToExistOnTravis()
{
$self = $this;
return array_map(function ($version) use ($self) {
if (in_array($version, Generator::$knownMinorPhpVersionsOnTravis)
|| substr_count($version, ".") < 2
) {
return $version;
} else {
$parts = explode('.', $version, 3);
$parts = array($parts[0], $parts[1]);
$versionWithoutPatch = implode('.', $parts);

$self->log("info", "Version '$version' is not known to be available on travis, using '$versionWithoutPatch'.");

return $versionWithoutPatch;
}
}, $this->phpVersions);
}
}