Skip to content

Commit 632bf79

Browse files
committed
Bringing back compatibility with past PHP versions since the changes from #127 are pretty simple to include. Included also PHP 7.0 support back, since the PHP 8.4 compatibility changes from #121 were possible to achieve another way. Updated Github workflow to include more PHP versions. Adjusted loophp/phposinfo package compatibility adjustment from #127 to be autoloader based, since the change from pull request didn't work with the testsuite. Managed to also adjust the testsuite to take into account the autoloader customisation. Fixed also issues in the testsuite where all package names were prefixed with __ even though only a handful of packages were supposed to be affected. Adjusted the testsuite to understand Composer 1 and 2 outputs again, but flipped the intention of .output to be based on latest Composer rather than 1 like earlier. Updated dependency whitelists based on the older versions, looks like symfony/console has lots of incompatibilities that have been suppressed with function_exists and autoloader workarounds.
1 parent 66353ae commit 632bf79

File tree

58 files changed

+840
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+840
-32
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Incorrect error: src/OsInfo.php,124,25,PHPCompatibility.Extensions.RemovedExtensions.famRemoved
2+
Graceful usage: src/OsInfo.php,179,23,PHPCompatibility.Constants.NewConstants.php_os_familyFound
3+
Graceful usage: src/OsInfo.php,180,50,PHPCompatibility.Constants.NewConstants.php_os_familyFound
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Graceful usage: src/OsInfo.php,18,11,PHPCompatibility.Constants.NewConstants.php_os_familyFound
2+
Incorrect error: src/OsInfo.php,134,25,PHPCompatibility.Extensions.RemovedExtensions.famRemoved
3+
Incorrect error: src/OsInfo.php,170,23,PHPCompatibility.Extensions.RemovedExtensions.famRemoved
4+
Graceful usage: src/OsInfo.php,238,21,PHPCompatibility.Constants.NewConstants.php_os_familyFound
5+
Graceful usage: src/OsInfo.php,239,49,PHPCompatibility.Constants.NewConstants.php_os_familyFound
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Graceful usage: Terminal.php,106,66,PHPCompatibility.FunctionUse.NewFunctions.sapi_windows_vt100_supportFound
2+
Graceful usage: Helper/QuestionHelper.php,163,14,PHPCompatibility.FunctionUse.NewFunctions.sapi_windows_cp_setFound
3+
Graceful usage: Output/StreamOutput.php,102,21,PHPCompatibility.FunctionUse.NewFunctions.sapi_windows_vt100_supportFound
4+
Graceful usage: Output/StreamOutput.php,109,21,PHPCompatibility.FunctionUse.NewFunctions.stream_isattyFound
5+
Incorrect error: Tests/Command/CommandTest.php,428,26,PHPCompatibility.FunctionDeclarations.NewClosure.ThisFoundOutsideClass
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Graceful usage: Terminal.php,106,66,PHPCompatibility.FunctionUse.NewFunctions.sapi_windows_vt100_supportFound
2+
Graceful usage: Helper/ProgressBar.php,276,31,PHPCompatibility.FunctionUse.NewFunctions.is_countableFound
3+
Graceful usage: Helper/QuestionHelper.php,488,49,PHPCompatibility.FunctionUse.NewFunctions.stream_isattyFound
4+
Graceful usage: Output/StreamOutput.php,107,21,PHPCompatibility.FunctionUse.NewFunctions.sapi_windows_vt100_supportFound
5+
Graceful usage: Output/StreamOutput.php,114,21,PHPCompatibility.FunctionUse.NewFunctions.stream_isattyFound
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Graceful usage: Completion/CompletionInput.php,120,74,PHPCompatibility.FunctionUse.NewFunctions.array_key_lastFound
2+
Graceful usage: Helper/ProgressBar.php,301,31,PHPCompatibility.FunctionUse.NewFunctions.is_countableFound
3+
Graceful usage: Helper/Table.php,810,51,PHPCompatibility.FunctionUse.NewFunctions.mb_str_splitFound
4+
Graceful usage: Input/ArgvInput.php,176,47,PHPCompatibility.FunctionUse.NewFunctions.array_key_firstFound

.github/workflows/ci.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@ name: CI
22

33
on:
44
pull_request:
5-
types: [opened, synchronize, reopened]
5+
types: [ opened, synchronize, reopened ]
66

77
jobs:
88
build:
99
runs-on: ubuntu-latest
1010
strategy:
1111
fail-fast: false
1212
matrix:
13-
versions: [ {php: "7.4", composer: 2.3.10}, {php: "8.0", composer: 2.3.10}, {php: "8.1", composer: 2.3.10}, {php: "8.2", composer: 2.7.7}, {php: "8.3", composer: 2.7.7}, {php: "8.4", composer: 2.8.9} ]
13+
versions: [
14+
{ php: "7.0", composer: 1.10.27 },
15+
{ php: "7.1", composer: 1.10.27 },
16+
{ php: "7.2", composer: 1.10.27 },
17+
{ php: "7.3", composer: 2.2.25 },
18+
{ php: "7.4", composer: 2.3.10 },
19+
{ php: "8.0", composer: 2.3.10 },
20+
{ php: "8.1", composer: 2.3.10 },
21+
{ php: "8.2", composer: 2.7.7 },
22+
{ php: "8.3", composer: 2.7.7 },
23+
{ php: "8.4", composer: 2.8.9 }
24+
]
1425
steps:
1526
- uses: actions/checkout@v3
1627

bin/analyse-dependencies

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ script_root=$(dirname $(test -L ${script_path} && readlink -f ${script_path} ||
99
source ${script_root}/lib/output.sh
1010

1111
package="vaimo/composer-patches-local"
12-
13-
if [ "${1}" != "current" ] ; then
14-
versions="7.4.33 8.0.30 8.1.32 8.2.28 8.3.22 8.4.7"
15-
else
16-
versions=$(php -r 'echo phpversion();'|cut -d '-' -f1)
17-
fi
12+
versions=$(php -r 'echo phpversion();'|cut -d '-' -f1)
1813

1914
bin/bootstrap-test-env
2015

@@ -219,10 +214,8 @@ is_production_dependency()
219214
_title "CHECK VIABILITY WITH" "PHP ${version_mm}" "code compatibility of required dependencies"
220215
_line '=' 80
221216

222-
composer config platform.php ${version}
223-
composer config --no-plugins allow-plugins.vaimo/composer-patches-local true
224-
225-
if ! composer update --ansi ; then
217+
composer config --no-plugins platform.php ${version}
218+
if ! composer update --no-plugins --ansi ; then
226219
exit 1
227220
fi
228221

bin/bootstrap-test-env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ if [ ! -L test/modules/${name}/src ] ; then
1414
fi
1515

1616
cp composer.json test/modules/${name} 2>/dev/null
17+
cp compatibility.php test/modules/${name} 2>/dev/null
1718

1819
sed -i.org 's|'${name}'"|'${name}'-local"|g' test/modules/${name}/composer.json
1920
rm test/modules/${name}/composer.json.org 2>/dev/null

bin/test

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,13 @@ assert_scenario_output() {
284284
local output_filters="${scenario_root}/.filters"
285285

286286
if _is_macosx ; then
287-
if [ "${composer_major}" = "2" ] && [ -f ${expected_output_file}-v2-darwin ] ; then
287+
if [ "${composer_major}" = "1" ] && [ -f ${expected_output_file}-v1-darwin ] ; then
288288
expected_output_file="${expected_output_file}-v2-darwin"
289289
elif [ -f ${expected_output_file}-darwin ] ; then
290290
expected_output_file="${expected_output_file}-darwin"
291291
fi
292-
elif [ "${composer_major}" = "2" ] && [ -f ${expected_output_file}-v2 ] ; then
293-
expected_output_file="${expected_output_file}-v2"
292+
elif [ "${composer_major}" = "1" ] && [ -f ${expected_output_file}-v1 ] ; then
293+
expected_output_file="${expected_output_file}-v1"
294294
fi
295295

296296
if [ ! -f ${output_file} ] ; then
@@ -326,6 +326,9 @@ assert_scenario_output() {
326326
|grep -v "^Nothing to modify in lock file" \
327327
|grep -v "^Warning: The lock file is not up to date with the latest changes in" \
328328
|grep -v "^Debug: " \
329+
|grep -v "^You are using Composer 1 which is deprecated." \
330+
|grep -v "^Warning from https://repo.packagist.org: Support for Composer 1" \
331+
|grep -v "^Package symfony/debug is abandoned" \
329332
|sed 's/ *$//g' \
330333
> output.txt
331334

@@ -394,7 +397,7 @@ process_assertions() {
394397
apply_patches() {
395398
local args=${1}
396399
local out_file=${2}
397-
400+
398401
local command="composer ${args} --ansi"
399402

400403
if [ "${VERBOSE}" == "1" ] ; then
@@ -407,7 +410,7 @@ apply_patches() {
407410

408411
cols=$(tput cols)
409412
rows=$(tput lines)
410-
413+
411414
(
412415
eval "${command}; return \${PIPESTATUS[0]}"
413416
)
@@ -491,7 +494,7 @@ reset_packages() {
491494
local lock_path="${installation_root}/composer.lock"
492495

493496
if [ -f ${install_info_path} ] ; then
494-
filters=$(grep -r "@package" ${scenarios_root}|sed 's/.*@package\(.*\)/\1/g'|sort|uniq|tr '\n' '|'|tr -d ' '|tr -d '\r')
497+
filters=$(grep -r "@package" ${scenarios_root}|sed 's/.*@package\(.*\)/\1/g'|sort|uniq|tr '\n' '|'|tr -d ' '|tr -d '\r'|sed 's/|$//g')
495498
perl -i.org -pe "s%(\s\"name\":\s\")(${filters}|vaimo/composer-patches-target)(.*)\",%\1__\2\3\",%g" \
496499
${install_info_path}
497500

compatibility.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/**
4+
* Copyright © Vaimo Group. All rights reserved.
5+
* See LICENSE_VAIMO.txt for license details.
6+
*/
7+
8+
namespace {
9+
// Backwards-compatibility for loophp/osinfo namespace change
10+
if (!class_exists('loophp\phposinfo\OsInfo') && class_exists('drupol\phposinfo\OsInfo')) {
11+
class_alias('drupol\phposinfo\OsInfo', 'loophp\phposinfo\OsInfo');
12+
class_alias('drupol\phposinfo\OsInfoInterface', 'loophp\phposinfo\OsInfoInterface');
13+
class_alias('drupol\phposinfo\Enum\Enum', 'loophp\phposinfo\Enum\Enum');
14+
class_alias('drupol\phposinfo\Enum\Family', 'loophp\phposinfo\Enum\Family');
15+
class_alias('drupol\phposinfo\Enum\FamilyName', 'loophp\phposinfo\Enum\FamilyName');
16+
class_alias('drupol\phposinfo\Enum\Os', 'loophp\phposinfo\Enum\Os');
17+
class_alias('drupol\phposinfo\Enum\OsName', 'loophp\phposinfo\Enum\OsName');
18+
}
19+
}

0 commit comments

Comments
 (0)