nemiah / phpFinTS

PHP library to communicate with FinTS/HBCI servers
MIT License
130 stars 42 forks source link

PHP 8.1 changes #364

Closed fbett closed 2 years ago

fbett commented 2 years ago

There are some changes needed for PHP 8.1:

The biggest commit is about:

All changes should be full compatible to previous PHP versions:

fbett commented 2 years ago

I'm sorry for all the commits, but it was much harder to get a successfully TRAVIS PHP 8.1 result as thought at the beginning. PHP CS FIXER on version 2 has problem using PHP 8.1: The result differs when running using PHP 8.0 or lower:

Runtime: PHP 8.0.15 Loaded config default from ".php-cs-fixer.php". ......F...... Legend: ?-unknown, I-invalid file syntax (file ignored), S-skipped (cached or empty file), .-no changes, F-fixed, E-error 1) phpFinTS/lib/Fhp/MT940/MT940.php (unary_operator_spaces)

Runtime: PHP 8.1.2 Loaded config default from ".php-cs-fixer.php". ......F...... Legend: ?-unknown, I-invalid file syntax (file ignored), S-skipped (cached or empty file), .-no changes, F-fixed, E-error 1) phpFinTS/lib/Fhp/MT940/MT940.php (function_typehint_space)

Using PHP 8.0 or lower, PHP CS FIXER will remove the spaces between the reference parameter sign and the parameter name, in line 197 of phpFinTS/lib/Fhp/MT940/MT940.php: protected function extractStructuredDataFromRemittanceLines($descriptionLines, string &$gvc, array &$rawLines, array $transaction): array Using PHP 8.1, PHP CS FIXER will add spaces: protected function extractStructuredDataFromRemittanceLines($descriptionLines, string & $gvc, array & $rawLines, array $transaction): array

I tested also a small upgrade to V2.19.x, but the problem also exists there. I made a migration to V3 using the migration guide. The only downside from my view is:

fbett commented 2 years ago

I don't understand, what was the loop that this fixes?

Example:

Philipp91 commented 2 years ago
  • BaseAction::unserialize called $this-> unserialize (DialogInitialization::unserialize)

But this doesn't happen? BaseAction::unserialize calls some __unserialize function (be it on $this or self) and not another (non-magic) unserialize.

fbett commented 2 years ago
  • BaseAction::unserialize called $this-> unserialize (DialogInitialization::unserialize)

But this doesn't happen? BaseAction::unserialize calls some __unserialize function (be it on $this or self) and not another (non-magic) unserialize.

Oh, yes, the last call was wrong.

Philipp91 commented 2 years ago

Oh right, makes sense. Thanks for the explanation.