Ensure proper PHP versions have been set in .travis.yml.

@param array $travisYml The contents of the .travis.yml.

@return bool
559523
public function validatePhpVersionTravisYml($travisYml)
    {
        if (!isset($travisYml['php'])) {
            $this->output->writeln(
                '<info>No PHP version mentioned in .travis.yml!</info>'
            );

            return true;
        }

        if (!is_array($travisYml['php'])) {
            $this->output->writeln(
                '<error>PHP version mentioned in .travis.yml must be an array!</error>'
            );

            return false;
        }

        $versionParser = new VersionParser();
        foreach ($travisYml['php'] as $version) {
            try {
                if ('nightly' === $version) {
                    continue;
                }
                $versionParser->parseConstraints($version);
            } catch (\Exception $e) {
                $this->output->writeln('<error>' . $e->getMessage() . '</error>');

                return false;
            }
        }

        return true;
    }
1019773
public function ensureSymlinkExists($sourcePath, $symlinkPath)
    {
        if (!is_link($symlinkPath)) {
            $this->ensureDirectoryExists(dirname($symlinkPath));

            return symlink($sourcePath, $symlinkPath);
        }

        return false;
    }
444562
protected function check_database_version(array $checkThis) {
		$data = $this->get_database_version();
		$versionString = $data['version_string'];
		
		if ($versionString == $checkThis['version_string']) {
			$retval = TRUE;
		} else {
			$retval = FALSE;
		}
		
		if (!$retval) {
			$this->do_log("Version check failed, versionString=(" . $versionString . "), checkVersion=(" . $this->newVersion . ")", 'FATAL');
		}
		
		return($retval);
	}
199480
public function checkPhpVersion() {
		$phpVesion = $this->_modelConfigInstaller->getPhpVersionConfig();
		if (empty($phpVesion)) {
			return null;
		}

		$result = true;
		foreach ($phpVesion as $phpVesionItem) {
			if (!is_array($phpVesionItem)) {
				continue;
			}

			$phpVesionItem += ['', null];
			list($version, $operator) = $phpVesionItem;
			if (empty($operator)) {
				$operator = '==';
			}

			$checkResult = false;
			if (!empty($version)) {
				$checkResult = version_compare(PHP_VERSION, $version, $operator);
			}
			if (!$checkResult) {
				$result = false;
			}
		}

		return $result;
	}
357191
protected function processVersion(PHP_CodeSniffer_File $phpcsFile, array $tags)
	{
		$tokens = $phpcsFile->getTokens();

		foreach ($tags as $tag)
		{
			$content = $tokens[($tag)]['code'];

			if ($content === '@version')
			{
				$error = '@version tag in file comment in not required; consider removing or using @since';
				$data  = array($content);
				$phpcsFile->addWarning($error, $tag, 'IncludedVersion', $data);
			}
		}
	}
635093
private static function registerSymfonyYaml()
    {
        if (
            ! isset(self::$classMap['yaml'])
            and ! isset(self::$classMap['yml'])
            and class_exists(self::SYMFONY_YAML)
        ) {
            self::registerExtension('yaml', self::YAML_ADAPTER);
            self::registerExtension('yml', self::YAML_ADAPTER);
        }
    }
821984
public function detectFalsyFunction(): bool
    {
        $file = file_get_contents($this->path);

        if (preg_match('/&warn\.deprecated\.function-(\d+-\d+-\d+)\.removed-(\d+-\d+-\d+)/', $file, $matches)) {
            $removedVersion = $matches[2];
            [$major, $minor] = explode('-', $removedVersion);
            if ($major < 7 || ($major == 7 && $minor == 0)) {
                // Ignore function if it was removed before PHP 7.1
                return false;
            }
        }
        if (preg_match('/&warn\.removed\.function-(\d+-\d+-\d+)/', $file, $matches) && isset($matches[2])) {
            $removedVersion = $matches[2];
            [$major, $minor] = explode('-', $removedVersion);
            if ($major < 7 || ($major == 7 && $minor == 0)) {
                // Ignore function if it was removed before PHP 7.1
                return false;
            }
        }

        if (preg_match('/&false;\s+on\s+error/m', $file)) {
            return true;
        }
        if (preg_match('/&false;\s+on\s+failure/m', $file)) {
            return true;
        }
        if (preg_match('/&false;\s+otherwise/m', $file) && !preg_match('/(returns\s+&true;|&true;\s+on\s+success|&true;\s+if)/im', $file)) {
            return true;
        }
        if (preg_match('/may\s+return\s+&false;/m', $file) && !preg_match('/(returns\s+&true;|&true;\s+on\s+success|&true;\s+if)/im', $file)) {
            return true;
        }
        if (preg_match('/&false;\s+if\s+an\s+error\s+occurred/m', $file)) {
            return true;
        }
        if (preg_match('/&return.success;/m', $file)) {
            return true;
        }
        if (preg_match('/&return.nullorfalse;/m', $file)) {
            return true;
        }
        if (preg_match('/&return.falseforfailure;/m', $file)) {
            return true;
        }
        if (preg_match('/&date.datetime.return.modifiedobjectorfalseforfailure;/m', $file)) {
            return true;
        }
        if (preg_match('/ or &false; \\(and generates an error/m', $file)) {
            return true;
        }
        if (preg_match('/&false;\s+if\s+the\s+number\s+of\s+elements\s+for\s+each\s+array\s+isn\'t\s+equal/m', $file)) {
            return true;
        }
        if (preg_match('/If\s+the\s+call\s+fails,\s+it\s+will\s+return\s+&false;/m', $file)) {
            return true;
        }
        if (preg_match('/Upon\s+failure,?\s+\<function\>[\w_]{1,15}?\<\/function\>\s+returns\s+&false;/m', $file)) {
            return true;
        }

        return false;
    }
1193800
public static function phpVersion($version)
    {
        static $phpVerisons = [];

        $version = (string)$version;

        if (!isset($phpVerisons[$version])) {
            $phpVerisons[$version] = version_compare(PHP_VERSION, $version, '>=');
        }
        return $phpVerisons[$version];
    }
1270201
public function validateNoUnmaintainedPhpVersionsInComposer($composerJson, $maintainedVersions)
    {
        if (empty($composerJson['require']['php'])) {
            return true;
        }

        $versionParser       = new VersionParser();
        $constraintsComposer = $versionParser->parseConstraints($composerJson['require']['php']);
        $versionOk           = false;
        // Second pass - check all maintainedVersions against the composer.json constraint.
        foreach ($maintainedVersions as $maintainedVersion) {
            if ('nightly' === $maintainedVersion) {
                continue;
            }

            $constraintsMaintainedVersion = $versionParser->parseConstraints($maintainedVersion . '.9999999.9999999');
            if ($constraintsComposer->matches($constraintsMaintainedVersion)) {
                $versionOk = true;

                break;
            }
        }

        if (!$versionOk) {
            $this->output->writeln(
                sprintf(
                    '<error>composer.json specifies PHP version "%s" but only "%s" are actively maintained.</error>',
                    $constraintsComposer->getPrettyString(),
                    implode(', ', $maintainedVersions)
                )
            );

            return false;
        }

        return true;
    }
183215
public function isVersioned()
    {
        if (!$this->ObjectClass || !class_exists($this->ObjectClass)) {
            return false;
        }
        /** @var Versioned|DataObject $singleton */
        $singleton = DataObject::singleton($this->ObjectClass);
        return $singleton->hasExtension(Versioned::class) && $singleton->hasStages();
    }
621581
public function supportsBelow($phpVersion)
    {
        if (
            !is_null(PHP_CodeSniffer::getConfigData('testVersion'))
            &&
            version_compare(PHP_CodeSniffer::getConfigData('testVersion'), $phpVersion) <= 0
        ) {
            return true;
        } else {
            return false;
        }
    }
1143385
public static function isSupportedShell()
    {
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            return false !== getenv('ANSICON') || 'ON' === getenv('ConEmuANSI') || 'xterm' === getenv('TERM');
        }

        return defined('STDOUT') && function_exists('posix_isatty') && posix_isatty(STDOUT);
    }
1256017
private function hasUnmigratedVersions()
    {
        $needsToRun = false;

        foreach ($this->availableVersions as $migration) {
            $isTargetMigrated = in_array($migration->getVersion(), $this->migratedVersions);

            if ($isTargetMigrated) {
                continue;
            }

            $needsToRun = true;
            break;
        }

        return $needsToRun;
    }
689110
public function isOld($key, $config)
    {
        if (substr_count($key, ',') < 2) {
            return true;
        }
        list($version, $hash, $revision) = explode(',', $key, 3);
        $compare = version_compare($version, $config->version);
        // version mismatch, is always old
        if ($compare != 0) {
            return true;
        }
        // versions match, ids match, check revision number
        if ($hash == $config->getBatchSerial($this->type) &&
            $revision < $config->get($this->type . '.DefinitionRev')) {
            return true;
        }
        return false;
    }
402694
public function do_gc($ttl)
    {
        $dir = $this->alias->resolve($this->_dir);
        if (is_dir($dir)) {
            $this->_clean($dir);
        }

        return true;
    }
255345
public function setVersion(string $version): bool
    {
        $supportedVersions = $this->getSupportedVersions();

        if (in_array($version, $supportedVersions, true)) {
            $this->_version = $version;

            return true;
        } else {
            throw new NotSupportedException("Version `$version` is not supported in " . __CLASS__ . "! Supported versions: " . implode(' - ', $supportedVersions));
        }
    }
1194776
private function _checkStructureVersion()
    {
        $result = $this->_query("SELECT num FROM version");
        if (!$result) return false;
        $row = @sqlite_fetch_array($result);
        if (!$row) {
            return false;
        }
        if (((int) $row['num']) != 1) {
            // old cache structure
            $this->_log('Zend_Cache_Backend_Sqlite::_checkStructureVersion() : old cache structure version detected => the cache is going to be dropped');
            return false;
        }
        return true;
    }