j4mie / idiorm

A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5.
http://j4mie.github.com/idiormandparis/
2.01k stars 369 forks source link

Annotations for PHP 8.1 compatibility and GitHub actions CI #373

Closed treffynnon closed 2 years ago

treffynnon commented 2 years ago
yan12125 commented 2 years ago

Two steps allow tests to run with phpunit 8.5 and php 8.1:

For the first step, source-level compatibility for newer and older phpunit can be achieved by

+if (!class_exists('PHPUnit_Framework_TestCase')) {
+    class_alias('\PHPUnit\Framework\TestCase', 'PHPUnit_Framework_TestCase');
+}

However, for the second step, source-level compatibility seems impossible for both newer and older PHP. PHP >= 8.0 requires compatible return types [1], while PHP < 7.0 does not recognize return types [2]. I'm afraid idiorm needs to use a magic like sed -i 's#: void##' test/*.php before running tests for older PHP versions.

[1] https://php.watch/versions/8.0/lsp-errors [2] https://www.php.net/manual/en/migration70.new-features.php

treffynnon commented 2 years ago

Nice - thanks for your help - I think we have a PR we can merge now.

yan12125 commented 2 years ago

Glad to help :)