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;
    }
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;
    }
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 ; }
Ensure all the PHP versions in composer.json are marked as maintained versions.

@param array $composerJson       The contents of the composer.json.

@param array $maintainedVersions The currently maintained version list.

@return bool
Ensure all the PHP versions in composer . json are marked as maintained versions .