Skip to content

Conversation

@byjg
Copy link
Owner

@byjg byjg commented Nov 9, 2025

This PR upgrades the project to support PHP 8.1-8.4 and modernizes the development toolchain with PHPUnit 10/11 and Psalm static analysis.

Summary

This major version upgrade aligns the project with modern PHP standards and dependencies, particularly upgrading to byjg/jwt-wrapper 6.0. All tests pass and static analysis is clean.

Major Changes

Dependency Updates

  • PHP: >=8.0>=8.1 <8.5
  • byjg/jwt-wrapper: 4.9.*^6.0
  • phpunit/phpunit: 5.7.*|7.4.*|^9.6^10|^11
  • vimeo/psalm: Added ^5.9|^6.12 for static analysis

Configuration Files

  • phpunit.xml.dist: Upgraded to PHPUnit 10+ format with strict error handling

    • Replaced <filter><whitelist> with <source><include>
    • Added failOnWarning, failOnNotice, failOnDeprecation attributes
    • Added detailed display settings for deprecations, errors, notices, and warnings
  • psalm.xml: Added static analysis configuration (error level 4)

  • .gitignore: Added phpunit.coverage.xml, phpunit.report.xml, *.bak

  • composer.json: Added scripts for test and psalm commands

  • GitHub Actions: Updated test matrix to PHP 8.1, 8.2, 8.3, 8.4

Code Changes

  • Updated namespace imports for jwt-wrapper 6.0 compatibility
  • Converted PHPUnit data providers to static methods (PHPUnit 10+ requirement)
  • Converted @dataProvider annotations to PHP 8 attributes
  • Added #[Override] attributes to interface method implementations
  • Fixed return types to match SessionHandlerInterface requirements

Breaking Changes

Component Before (Master) After (6.0) Impact
PHP Version >=8.0 >=8.1 <8.5 PHP 8.0 is no longer supported
jwt-wrapper Namespace ByJG\Util\* ByJG\JwtWrapper\* Import statements must be updated
JwtKeySecret Class ByJG\Util\JwtKeySecret ByJG\JwtWrapper\JwtHashHmacSecret Class renamed in dependency
JwtRsaKey Class ByJG\Util\JwtRsaKey ByJG\JwtWrapper\JwtOpenSSLKey Class renamed in dependency
JwtWrapper::createJwtData() Accepts string Accepts array API signature changed in dependency
PHPUnit 5.7/7.4/9.6 ^10|^11 Test suite requires PHPUnit 10+
SessionHandlerInterface::gc() Returns bool Returns int|false Return type updated to match PHP 8.1+ interface

Compatibility Notes

For Library Users

If you're upgrading from version 5.x to 6.0:

  1. PHP Version: Ensure your project runs on PHP 8.1 or higher
  2. No API Changes: The public API of JwtSession remains unchanged
  3. Dependency Impact: The internal dependency changes are transparent to end users
  4. Session Compatibility: Existing JWT sessions remain compatible

For Contributors

If you're developing/testing this library:

  1. PHPUnit: Tests now use PHPUnit 10/11 with strict error handling
  2. Static Analysis: Run composer psalm to check code quality
  3. PHP 8.1+ Features: Code uses modern PHP features (attributes, typed properties)

Testing

All tests pass on PHP 8.1, 8.2, 8.3, and 8.4:

  • ✅ 54 tests, 54 assertions
  • ✅ Psalm static analysis: 0 errors
  • ✅ No deprecation warnings

Migration Guide

For projects using this library, update your composer.json:

{
    "require": {
        "php": ">=8.1",
        "byjg/jwt-session": "^6.0"
    }
}

* Update legacy configuration files

- Update phpunit.xml.dist to PHPUnit 10+ format with new attributes and source tag
- Create psalm.xml with static analysis configuration
- Update composer.json: PHP >=8.1 <8.5, byjg/jwt-wrapper ^6.0, phpunit ^10|^11, vimeo/psalm ^5.9|^6.12
- Add composer scripts for test and psalm
- Update GitHub workflow to test PHP 8.1-8.4
- Update .gitignore with additional patterns

* Fix compatibility with jwt-wrapper 6.0

- Update namespace imports from ByJG\Util to ByJG\JwtWrapper
- Update class names: JwtKeySecret -> JwtHashHmacSecret, JwtRsaKey -> JwtOpenSSLKey
- Update JwtWrapper::createJwtData() call to pass array instead of string
- Make test data providers static for PHPUnit 10+ compatibility
- Convert @dataProvider annotations to PHP attributes
- Suppress unserialize warnings in session parser (expected behavior)

* Fix psalm static analysis errors

- Add #[Override] attributes to SessionHandlerInterface methods
- Fix gc() return type from bool to int|false per interface
- Remove redundant null coalescing for getCookiePath() calls

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants