Skip to content

Commit c10a38c

Browse files
committed
refactor: renamed getComposerPhpVersion func to match config naming more closely
1 parent e6015c0 commit c10a38c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/options.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const CATEGORY_PHP = "PHP";
77
* Detect the minimum PHP version from the composer.json file
88
* @return {string|null} The PHP version to use in the composer.json file, null when not found
99
*/
10-
function getComposerPhpVer() {
10+
function getComposerPhpVersion() {
1111
// Try to find composer.json
1212
const currentDir = process.cwd();
1313
let composerPath = null;
@@ -60,14 +60,14 @@ function getComposerPhpVer() {
6060
return null;
6161
}
6262

63-
export { getComposerPhpVer };
63+
export { getComposerPhpVersion };
6464

6565
export default {
6666
phpVersion: {
6767
since: "0.13.0",
6868
category: CATEGORY_PHP,
6969
type: "choice",
70-
default: getComposerPhpVer() ?? "8.3",
70+
default: getComposerPhpVersion() ?? "8.3",
7171
description: "Minimum target PHP version.",
7272
choices: [
7373
{ value: "5.0" },

tests/composer-version/composer-version.spec.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getComposerPhpVer } from "../../src/options.mjs";
1+
import { getComposerPhpVersion } from "../../src/options.mjs";
22
import fs from "fs";
33
import path from "path";
44
import os from "os";
@@ -51,7 +51,7 @@ describe("getComposerPhpVer", () => {
5151

5252
process.chdir(emptyDir);
5353

54-
expect(getComposerPhpVer()).toBe(null);
54+
expect(getComposerPhpVersion()).toBe(null);
5555
});
5656

5757
test.each([
@@ -76,7 +76,7 @@ describe("getComposerPhpVer", () => {
7676
fs.writeFileSync(tempComposerPath, composerContent);
7777

7878

79-
expect(getComposerPhpVer()).toBe(expected);
79+
expect(getComposerPhpVersion()).toBe(expected);
8080
});
8181

8282
test("returns null when composer.json has no PHP requirement", () => {
@@ -95,7 +95,7 @@ describe("getComposerPhpVer", () => {
9595

9696
process.chdir(tempDir);
9797

98-
expect(getComposerPhpVer()).toBe(null);
98+
expect(getComposerPhpVersion()).toBe(null);
9999
});
100100

101101
test("returns null when composer.json has invalid PHP requirement", () => {
@@ -113,7 +113,7 @@ describe("getComposerPhpVer", () => {
113113

114114
process.chdir(tempDir);
115115

116-
expect(getComposerPhpVer()).toBe(null);
116+
expect(getComposerPhpVersion()).toBe(null);
117117
});
118118

119119
test("finds composer.json in parent directory when in nested child folder", () => {
@@ -141,7 +141,7 @@ describe("getComposerPhpVer", () => {
141141

142142
process.chdir(nestedDir3);
143143

144-
expect(getComposerPhpVer()).toBe("8.1");
144+
expect(getComposerPhpVersion()).toBe("8.1");
145145
});
146146

147147
test("finds composer.json in intermediate parent directory", () => {
@@ -170,7 +170,7 @@ describe("getComposerPhpVer", () => {
170170

171171
process.chdir(nestedDir3);
172172

173-
expect(getComposerPhpVer()).toBe("7.2");
173+
expect(getComposerPhpVersion()).toBe("7.2");
174174
});
175175

176176
test("returns null when composer.json is malformed", () => {
@@ -189,6 +189,6 @@ describe("getComposerPhpVer", () => {
189189

190190
process.chdir(tempDir);
191191

192-
expect(getComposerPhpVer()).toBe(null);
192+
expect(getComposerPhpVersion()).toBe(null);
193193
});
194194
});

0 commit comments

Comments
 (0)