Skip to content

Conversation

@al1357
Copy link

@al1357 al1357 commented Oct 2, 2025

Env
Magento: 2.4.7-p7
PHP: 8.2.29
Module: unzerdev/magento2 4.0.0

Problem
The code uses array_last() which is only available in PHP 8.5. The package declares compatibility with PHP 7.4 / 8.1 / 8.2 / 8.3 / 8.4, so this throws a fatal on ≤8.4.

Fix
Replace array_last($arr) with ($arr === []) ? null : $arr[\array_key_last($arr)], which preserves the same semantics (null for empty arrays) and works on PHP 7.4–8.4.

Notes
array_last() was introduced in PHP 8.5. Ref: php.watch / RFC.

Tested locally on PHP 8.2; no behavior change besides removing fatal.

No public API changes.

PHP 8.2 error message
main.CRITICAL: Error: Call to undefined function Unzer\PAPI\Model\Command\array_last() in /magento2/vendor/unzerdev/magento2/Model/Command/TransactionSynchronizer.php:42

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.

1 participant