Skip to content

Commit 34a4876

Browse files
committed
fixing non-php jobs
1 parent e77878b commit 34a4876

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

.github/get-php-matrix.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@
1717
*
1818
* For example: ">=7.2.5" becomes "7.2"
1919
*/
20-
function extractPhpMinorVersion($versionConstraint) {
21-
$fullPhpVersion = preg_replace('/[^0-9.]/', '', $versionConstraint);
20+
function extractPhpMinorVersion(array $composerData): ?string
21+
{
22+
if (!isset($composerData['require'])) {
23+
return null;
24+
}
25+
26+
if (!isset($composerData['require']['php'])) {
27+
throw new \Exception(sprintf('Missing "php" requirement for package "%s"', $composerData['name']));
28+
}
29+
30+
$fullPhpVersion = preg_replace('/[^0-9.]/', '', $composerData['require']['php']);
2231
$parts = explode('.', $fullPhpVersion);
2332

2433
return sprintf('%s.%s', $parts[0], $parts[1]);
@@ -27,9 +36,12 @@ function extractPhpMinorVersion($versionConstraint) {
2736
const MAX_PHP_VERSION = '8.0';
2837

2938
foreach ($finder as $file) {
30-
// get the minimum PHP version supported
31-
$phpRequirement = (json_decode($file->getContents(), true))['require']['php'];
32-
$phpVersion = extractPhpMinorVersion($phpRequirement);
39+
$phpVersion = extractPhpMinorVersion(json_decode($file->getContents(), true));
40+
41+
if (!$phpVersion) {
42+
// some packages have no php code
43+
continue;
44+
}
3345

3446
$directory = $file->getPathInfo()->getPathname();
3547
$packagePath = substr($directory, strpos($directory, '../src/') + 7);

src/Swup/composer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
"conflict": {
2121
"symfony/flex": "<1.13"
2222
},
23-
"require": {
24-
"php": ">=7.2.5"
25-
},
2623
"extra": {
2724
"branch-alias": {
2825
"dev-main": "1.3-dev"

0 commit comments

Comments
 (0)