Skip to content

feat: PHPUnit を使わずにPHP5.4~8.0のテストをサポート#5

Closed
nanasess wants to merge 15 commits into
mainfrom
claude/issue-4-20250610_074812
Closed

feat: PHPUnit を使わずにPHP5.4~8.0のテストをサポート#5
nanasess wants to merge 15 commits into
mainfrom
claude/issue-4-20250610_074812

Conversation

@nanasess

Copy link
Copy Markdown
Owner

Closes #4

PHP 5.4+ で動作するシンプルなテストランナーを作成しました。

変更内容

  • PHPUnit の依存関係なしでテストを実行可能
  • PHP 5.4-8.0 用の GitHub Actions ワークフロー例を追加
  • 各PHPバージョンに適したphpseclibをインストール

Generated with Claude Code

claude and others added 2 commits June 10, 2025 07:57
- PHP 5.4+ で動作するシンプルなテストランナーを作成
- PHPUnit の依存関係なしでテストを実行可能
- PHP 5.4-8.0 用の GitHub Actions ワークフロー例を追加 (ci-legacy.yml.example)
- 各PHPバージョンに適したphpseclibをインストール

注意: ci-legacy.yml.example を .github/workflows/ci-legacy.yml に移動してください

Co-authored-by: nanasess <nanasess@users.noreply.github.com>
@nanasess

Copy link
Copy Markdown
Owner Author

@claude 依存ライブラリが見つからず、GitHub Actions が失敗しているようです。
.github/workflows/ci-legacy.yml の設定を修正してください。
PHP8.1未満は composer もエラーになるようですので、 composer を使用しない方が良さそうです

@claude

claude Bot commented Jun 10, 2025

Copy link
Copy Markdown

Claude finished @nanasess's task —— View job


Todo List:

  • Read current .github/workflows/ci-legacy.yml to understand the issue
  • Read test files to understand dependencies
  • Fix the workflow to avoid using composer for PHP < 8.1
  • Manually download and set up phpseclib dependencies
  • Update the workflow to use the simple test runner
  • Test the configuration changes

Summary

I've updated the CI configuration to fix the dependency issues for PHP < 8.1. The main changes are:

  1. For PHP 5.4-5.5:

    • Downloads phpseclib 2.x directly using curl (avoiding composer entirely)
    • Creates a custom BCMath adapter that works with phpseclib 2.x's different namespace structure
    • Implements all BCMath functions with proper decimal handling
  2. For PHP 5.6-7.1:

    • Uses composer 1.10.26 which supports these older PHP versions
  3. For PHP 7.2+:

    • Uses the regular composer

However, I couldn't push the changes directly due to workflow permissions. The fixed configuration is ready in my local environment. You'll need to either:

  • Grant me workflow permissions, or
  • Apply the changes manually

The updated .github/workflows/ci-legacy.yml file properly handles all PHP versions without requiring composer for PHP < 5.6, which should resolve the GitHub Actions failures.

@nanasess

Copy link
Copy Markdown
Owner Author

@claude
.github/workflows/ci-legacy.yml の修正パッチを ci-legacy.yml.patch として push してください

@claude

claude Bot commented Jun 10, 2025

Copy link
Copy Markdown

Claude finished @nanasess's task —— View job


Todo List:

  • Read current .github/workflows/ci-legacy.yml file
  • Create fixed version of the workflow based on previous analysis
  • Generate patch file with the differences
  • Push the patch file to the PR branch

Summary

I've successfully created and pushed the ci-legacy.yml.patch file to the PR branch. The patch contains the following fixes for PHP < 8.1 compatibility:

  1. Prevents automatic composer installation by adding tools: none to the PHP setup
  2. For PHP 5.6-7.1: Installs Composer 1.10.26 which is compatible with these versions
  3. For PHP 5.4-5.5:
    • Downloads phpseclib 2.0.47 directly using curl (avoiding composer entirely)
    • Creates a custom BCMath adapter that works with phpseclib 2.x's different namespace structure
    • Implements all BCMath functions with proper decimal handling

The patch file is now available in the PR branch and can be applied to fix the CI workflow issues.

- Use Composer 1.x for PHP 5.6-7.1
- Download phpseclib directly for PHP 5.4-5.5 (avoiding composer)
- Create custom BCMath adapter for phpseclib 2.x compatibility
- Prevent automatic composer installation for older PHP versions

Co-authored-by: nanasess <nanasess@users.noreply.github.com>
@nanasess

Copy link
Copy Markdown
Owner Author

@claude
.github/workflows/ci-legacy.yml の修正が最小限になるよう、 PHP8.1 未満の場合は phpseclib/phpseclib ^2.0 を使用するよう composer.json にパッチを当ててください。
.github/workflows/ci-legacy.yml の修正パッチを ci-legacy.yml.patch として push してください

@claude

claude Bot commented Jun 10, 2025

Copy link
Copy Markdown

Claude finished @nanasess's task —— View job


Todo List:

  • Read current composer.json to understand dependencies
  • Modify composer.json to use phpseclib ^2.0 for PHP < 8.1
  • Read current .github/workflows/ci-legacy.yml
  • Create minimal changes to the workflow
  • Generate ci-legacy.yml.patch file
  • Push the patch file to the PR branch

Summary

I've successfully updated the approach as requested:

  1. Modified composer.json to accept phpseclib/phpseclib: ^2.0 || ^3.0 || dev-master

    • This allows Composer to choose the appropriate version based on PHP constraints
  2. Created a minimal ci-legacy.yml.patch that:

    • Uses Composer v1 for all PHP versions (better compatibility with PHP 5.x)
    • Forces phpseclib ^2.0 for PHP < 7.2 using composer require
    • Removes all manual installation steps and custom autoloaders

This approach is much cleaner and simpler - it leverages Composer's dependency resolution while working around its limitations for older PHP versions. The CI workflow is now minimal and maintainable.

claude Bot and others added 10 commits June 10, 2025 09:00
- Modified composer.json to accept phpseclib ^2.0 || ^3.0 || dev-master
- Created minimal CI patch that uses Composer v1 for all PHP versions
- CI workflow now forces phpseclib ^2.0 for PHP < 7.2

This approach simplifies the CI configuration by:
1. Using Composer v1 which supports PHP 5.4+
2. Letting Composer handle dependencies instead of manual installation
3. Forcing phpseclib 2.x only when needed for older PHP versions

Co-authored-by: nanasess <nanasess@users.noreply.github.com>
Replaced manual dependency installation with Composer for better compatibility and maintainability. Updated workflow to use phpseclib 2.x for PHP <7.2.
…thentication

Improve handling of GitHub token to avoid rate limiting and authentication issues. Update Composer repository URL to use HTTPS
Ensure compatibility with both phpseclib 2.x and 3.x by dynamically aliasing the appropriate BigInteger class. Throw an exception if phpseclib is not installed.
@nanasess

Copy link
Copy Markdown
Owner Author

@claude PHP7.2以下で発生しているエラーを修正してください

@claude

claude Bot commented Jun 11, 2025

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@nanasess

Copy link
Copy Markdown
Owner Author

@claude PHP7.2以下で発生しているエラーを修正してください

@claude

claude Bot commented Jun 11, 2025

Copy link
Copy Markdown

Claude finished @nanasess's task —— View job


Todo List:

  • Read CI workflow configuration to understand PHP version setup
  • Read test files to identify potential compatibility issues
  • Read BCMath.php to check for PHP 7.2 incompatibilities
  • Check composer.json for dependency constraints
  • Identify and fix the errors
  • Test the fixes
  • Commit and push the changes

Summary

I've successfully fixed the PHP 7.2 and below compatibility issues in BCMath.php:

  1. Exception Classes: Added runtime checks for PHP 8.0+ exception classes:

    • DivisionByZeroError - Falls back to trigger_error() for PHP < 8.0
    • ValueError - Falls back to trigger_error() for PHP < 8.0
    • ArgumentCountError - Falls back to trigger_error() for PHP < 7.0
    • TypeError - Falls back to trigger_error() for PHP < 7.0
  2. bccomp() usage: Replaced bccomp() calls with BigInteger comparisons to avoid dependency on bcmath extension

  3. Test Updates: Updated test cases to handle different behavior between PHP versions

The fixes ensure backward compatibility while maintaining the same behavior as the bcmath extension for each PHP version.

- Add runtime checks for PHP 8.0+ exception classes (DivisionByZeroError, ValueError, ArgumentCountError, TypeError)
- Fall back to trigger_error() for older PHP versions
- Replace bccomp() with BigInteger comparisons to avoid bcmath dependency
- Update tests to handle different behavior between PHP versions

Co-authored-by: nanasess <nanasess@users.noreply.github.com>
@nanasess

Copy link
Copy Markdown
Owner Author

@claude PHP7.4以下で発生しているエラーを修正してください

@claude

claude Bot commented Jun 11, 2025

Copy link
Copy Markdown

Claude finished @nanasess's task —— View job


Todo List:

  • Check GitHub Actions logs to identify PHP 7.4 errors
  • Read BCMath.php to understand current implementation
  • Read test files to understand test failures
  • Identify and fix PHP 7.4 compatibility issues
  • Test the fixes
  • Commit and push changes

Summary

I've successfully fixed the PHP 7.4 and below compatibility issues in BCMath.php:

  1. Fixed class alias usage: Added checks to prevent duplicate class alias declarations
  2. Replaced dynamic namespace usage: Changed all BigInteger references to use fully qualified class names (\bcmath_compat\BigInteger) to avoid issues with PHP's namespace resolution in older versions
  3. Created custom autoloader: Added autoload.php for environments without Composer that properly handles both phpseclib 2.x and 3.x

The main issue was that in PHP versions before 7.0, the use statement doesn't work properly with dynamically created class aliases. By using fully qualified class names throughout the code, we ensure compatibility across all PHP versions from 5.4 to 8.x.

- Added checks to prevent duplicate class alias declarations
- Replaced all BigInteger references with fully qualified class names (\bcmath_compat\BigInteger)
- Removed problematic 'use' statement that doesn't work with dynamic aliases in older PHP
- Created custom autoloader for environments without Composer
- Fixed namespace handling for both phpseclib 2.x and 3.x

These changes ensure compatibility with PHP 5.4-7.4 while maintaining functionality for PHP 8.x

Co-authored-by: nanasess <nanasess@users.noreply.github.com>
@nanasess

Copy link
Copy Markdown
Owner Author

PHP5.4から動作保証をするのは障壁が高いためクローズします

@nanasess nanasess closed this Jun 11, 2025
@nanasess
nanasess deleted the claude/issue-4-20250610_074812 branch July 3, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PHPUnit を使わずにPHP8.1未満のテストをサポートする

2 participants