Skip to content

fix: update composer.json and CI patch for PHP < 8.1 compatibility #5

fix: update composer.json and CI patch for PHP < 8.1 compatibility

fix: update composer.json and CI patch for PHP < 8.1 compatibility #5

Workflow file for this run

name: CI Legacy PHP
on: [push, pull_request]
permissions:
contents: read
jobs:
tests-legacy:
name: Tests PHP ${{ matrix.php-version }}
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: bcmath
- name: Install Composer dependencies (PHP 7.2+)
if: matrix.php-version >= '7.2'
run: composer install --no-interaction --no-cache
- name: Install dependencies manually (PHP 5.4-5.5)
if: matrix.php-version == '5.4' || matrix.php-version == '5.5'
run: |
# For PHP 5.4-5.5, use phpseclib 2.x which supports PHP 5.3+
mkdir -p vendor/phpseclib/phpseclib
git clone --depth 1 --branch 2.0 https://github.com/phpseclib/phpseclib.git vendor/phpseclib/phpseclib
# Create a simple autoloader for phpseclib 2.x
echo '<?php
spl_autoload_register(function ($class) {
$prefix = "phpseclib\\";
$base_dir = __DIR__ . "/vendor/phpseclib/phpseclib/phpseclib/";
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
$relative_class = substr($class, $len);
$file = $base_dir . str_replace("\\", "/", $relative_class) . ".php";
if (file_exists($file)) {
require $file;
}
});
// Also try without namespace for phpseclib 2.x
spl_autoload_register(function ($class) {
$file = __DIR__ . "/vendor/phpseclib/phpseclib/phpseclib/" . str_replace("_", "/", $class) . ".php";
if (file_exists($file)) {
require $file;
}
});
// Include the bcmath polyfill
require_once __DIR__ . "/lib/bcmath.php";' > autoload.php
- name: Install dependencies manually (PHP 5.6-7.1)
if: matrix.php-version == '5.6' || matrix.php-version == '7.0' || matrix.php-version == '7.1'
run: |
# For PHP 5.6+, use phpseclib 3.x
mkdir -p vendor/phpseclib/phpseclib
git clone --depth 1 --branch 3.0 https://github.com/phpseclib/phpseclib.git vendor/phpseclib/phpseclib
# Create a simple autoloader for phpseclib 3.x
echo '<?php
spl_autoload_register(function ($class) {
$prefix = "phpseclib3\\";
$base_dir = __DIR__ . "/vendor/phpseclib/phpseclib/phpseclib/";
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
$relative_class = substr($class, $len);
$file = $base_dir . str_replace("\\", "/", $relative_class) . ".php";
if (file_exists($file)) {
require $file;
}
});
// Include the bcmath polyfill
require_once __DIR__ . "/lib/bcmath.php";' > autoload.php
- name: Run tests with simple test runner
run: php tests/simple-test-runner.php
- name: Show PHP version
run: php -v
strategy:
fail-fast: false
matrix:
php-version: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']