From b63ed639d89eaa23230f27ecd0a997c42d2496f0 Mon Sep 17 00:00:00 2001 From: diosmosis Date: Wed, 18 Nov 2015 05:04:01 -0800 Subject: [PATCH] When generating .travis.yml files, cut off a PHP version's patch before using it in the php: section if the version w/ patch is not known to exist on travis. Uses whitelist. --- generator/Generator.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/generator/Generator.php b/generator/Generator.php index 6c286eb..0489360 100644 --- a/generator/Generator.php +++ b/generator/Generator.php @@ -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[] */ @@ -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(); @@ -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); + } } \ No newline at end of file