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

fix(manager/composer): respect the PHP override in composer.json #13657

Merged
merged 8 commits into from Jan 20, 2022
5 changes: 5 additions & 0 deletions lib/manager/composer/types.ts
Expand Up @@ -8,6 +8,11 @@ export interface Repo {
}
export interface ComposerConfig {
type?: string;
config?: {
internalsystemerror marked this conversation as resolved.
Show resolved Hide resolved
platform?: {
php?: string;
internalsystemerror marked this conversation as resolved.
Show resolved Hide resolved
};
};
/**
* A repositories field can be an array of Repo objects or an object of repoName: Repo
* Also it can be a boolean (usually false) to disable packagist.
Expand Down
12 changes: 12 additions & 0 deletions lib/manager/composer/utils.spec.ts
Expand Up @@ -18,6 +18,18 @@ describe('manager/composer/utils', () => {
).toEqual({ php: '>=5.3.2', composer: '1.1.0' });
});

it('returns platform php version', () => {
expect(
extractContraints(
{
config: { platform: { php: '7.4.27' } },
require: { php: '~7.4 || ~8.0' },
},
{}
)
).toEqual({ php: '7.4.27' });
});

it('returns from require-dev', () => {
expect(
extractContraints(
Expand Down
4 changes: 3 additions & 1 deletion lib/manager/composer/utils.ts
Expand Up @@ -69,7 +69,9 @@ export function extractContraints(
const res: Record<string, string> = { composer: '1.*' };

// extract php
if (composerJson.require?.php) {
if (composerJson.config?.platform?.php) {
res.php = composerJson.config?.platform?.php;
rarkins marked this conversation as resolved.
Show resolved Hide resolved
} else if (composerJson.require?.php) {
res.php = composerJson.require?.php;
rarkins marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down