Skip to content

Conversation

@simbig
Copy link
Contributor

@simbig simbig commented Aug 22, 2025

  • Added automated tests
  • Documented for all relevant versions
  • Updated the changelog

Resolves #43

Changes

This PR enables PHP 8.1 features while maintaining backward compatibility with PHP 7.4/8.0 through automated downgrade releases.

Main Changes

  • PHP requirement: Main package now requires ^8.1
  • PHP 8.1 features used: readonly properties, native union type syntax (int|false)
  • Automated downgrade: When a new version is tagged, GitHub Actions automatically creates a .74 suffixed tag with PHP 7.4 compatible code

How it works

  1. Development uses PHP 8.1+ features in the main codebase
  2. CI validates the downgraded code works on PHP 7.4
  3. On release, Rector automatically downgrades src/ to PHP 7.4
  4. A separate tag (e.g., v6.0.0.74) is published with the downgraded code

For PHP 7.4/8.0 users

composer require mll-lab/php-utils:v6.0.0.74

Breaking changes

  • Minimum PHP version changed from ^7.4 || ^8 to ^8.1 (use .74 releases for older PHP versions)

@simbig simbig linked an issue Aug 22, 2025 that may be closed by this pull request
Simon Bigelmayr and others added 27 commits August 22, 2025 22:35
- Update GitHub Actions versions (checkout@v4, composer-install@v3)
- Use PHP 8.3 for running Rector (better compatibility)
- Add workflow permissions for pushing tags
- Translate German comments to English
- Simplify build/composer-php-74.json (production-only dependencies)
- Add CHANGELOG entry for v6.0.0
- Document PHP 7.4/8.0 support in README

Resolves #43

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…mpatibility

Resolved conflicts:
- CHANGELOG.md: Added v6.0.0 entry above new master releases
- validate.yml: Kept PHP 8.1+ matrix for main tests, used downgraded-build-validate for PHP 7.4

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Tests the downgraded code with both lowest and highest dependency
versions to ensure compatibility across the full dependency range.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Composer doesn't have a --prefer-highest option. The highest
dependencies are the default behavior, so we only need to add
--prefer-lowest --prefer-stable for the lowest matrix.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
The validation workflow needs PHPUnit to run tests on the
downgraded code. Added require-dev with PHPUnit 9.x and
orchestra/testbench (compatible with PHP 7.4).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Remove orchestra/testbench (requires PHP 8.0+ for latest versions,
  and older versions require Laravel with security advisories)
- Add audit config to ignore known security advisory PKSA-8qx3-n5y5-vvnd
- PHPUnit alone is sufficient for running the downgraded tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
PHPStan integration tests require the PHPStan testing framework
which is not included in the downgraded dependencies. These tests
verify PHPStan rules, not the library's core functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Exclude tests that require:
- PHPStan: testing framework not in downgraded deps
- Enum: PHP 8.1+ native feature, cannot be downgraded
- FluidXPlate: requires graphql-php-scalars (optional)
- Qiaxcel: requires phpspreadsheet (optional)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Simon Bigelmayr and others added 4 commits December 12, 2025 14:48
Require illuminate/support ^8.77 or higher because the tests use
Collection::firstOrFail() which was added in version 8.77.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
These tests use Collection::firstOrFail() which was added in
Laravel 9. Laravel 9 requires PHP 8.0+, making this method
unavailable when running on PHP 7.4 with Laravel 8.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
PHPUnit 9.x (used with lowest dependencies) doesn't understand
#[DataProvider] attributes - only @dataProvider annotations.

Changes:
- Restore both annotation and attribute on test methods
- Add DowngradeAttributeToAnnotationRector for PHP 7.4 builds

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@simbig
Copy link
Contributor Author

simbig commented Dec 15, 2025

@spawnia schau dir bitte den draft hier mal an. Was denkst du darüber?
Würde gerne in einem split-PR nur das feature enablen, wenn das konzeptionell passt. Jedoch vorerst ohne den code für alles zu upgraden um ggf. logik-Änderungen vorzubeugen und nicht alles auf einmal umzustellen.


- uses: ramsey/composer-install@v3

# Downgrade /src to PHP 7.4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bitte Lärm-Kommentare wegräumen.

Comment on lines +30 to +31
php-version: ["8.1", "8.2", "8.3", "8.4"]
dependencies: [lowest, highest]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Die bisherige Syntax ist schon ok, bitte generell so lassen und Diff minimieren.

dependencies:
- lowest
- highest
php-version: ["8.1", "8.2", "8.3", "8.4"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warum nicht mehr auf PHP 8.0 testen?

Comment on lines +124 to +128
rm -rf tests/PHPStan # Requires PHPStan testing framework
rm -rf tests/Enum # PHP 8.1+ enums cannot be downgraded
rm -rf tests/FluidXPlate # Requires graphql-php-scalars (optional)
rm -rf tests/Qiaxcel # Requires phpspreadsheet (optional)
rm -rf tests/LightcyclerExportSheet # Uses Collection::firstOrFail (Laravel 9+)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entweder alle alignen oder keine. Bin für keine, also nur ein Leerzeichen vor dem #

rm -rf tests/Qiaxcel # Requires phpspreadsheet (optional)
rm -rf tests/LightcyclerExportSheet # Uses Collection::firstOrFail (Laravel 9+)
- name: "Setup PHP 7.4"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ist für mich sowas wie ein redundanter Kommentar, weg damit


### Migration

Users on PHP 7.4 or 8.0 should use the `.74` tagged releases:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha! Also sollte wohl auch PHP 8 darauf getestet werden. Sehe ich auch in der Zukunft als für uns relevant, wegen diesem einen Legacy-Projekt das nicht genannt werden darf und wohl schrittweise updated würde.

composer require mll-lab/php-utils:v6.0.0.74
```

These releases are automatically downgraded using [Rector](https://getrector.org) and published alongside each main release.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gibt es dafür von Rector Docs?

$reversedParts = array_reverse($parts);

return implode($reversedParts);
return implode('', $reversedParts);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diese Änderung können wir gleich machen, oder?

/** @var TCoordinateSystem */
public CoordinateSystem $coordinateSystem;

/** @param TCoordinateSystem $coordinateSystem */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@var - auch an anderen Stellen

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wir schreiben den Changelog inzwischen nicht mehr von Hand, sondern lassen diesen per Semantic Release erstellen. Daher muss die Commit-Nachricht so vorbereitet werden dass sie die Breaking Changes erfasst.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Enable PHP 8.1 Features with Backward Compatibility

3 participants