mollie / mollie-api-php

Mollie API client for PHP
http://www.mollie.com
BSD 2-Clause "Simplified" License
552 stars 191 forks source link

[v2.67.1] `mollie-api-php.zip` composer platform_check PHP >= 7.2 #720

Closed Gummy47 closed 5 months ago

Gummy47 commented 5 months ago

Specifications

Describe the issue

Hi mollie team,

I'm looking into implementing Mollie in some legacy code in PHP 7.0. Seeing in the repo's description that PHP >= 7.0 is required, I tried my luck with the manual zip (no composer available for me), but when including the autoload, it includes some platform_check.php that specifically checks that PHP's version is >= 7.2 :

<?php

// platform_check.php @generated by Composer

$issues = array();

if (!(PHP_VERSION_ID >= 70200)) {
    $issues[] = 'Your Composer dependencies require a PHP version ">= 7.2.0". You are running ' . PHP_VERSION . '.';
}

if ($issues) {
    if (!headers_sent()) {
        header('HTTP/1.1 500 Internal Server Error');
    }
    if (!ini_get('display_errors')) {
        if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
            fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
        } elseif (!headers_sent()) {
            echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
        }
    }
    trigger_error(
        'Composer detected issues in your platform: ' . implode(' ', $issues),
        E_USER_ERROR
    );
}

I guess this is expected and the support has been ramped up to >=7.2 and the repo's readme has not been updated?

While commenting the platform check in the autoloader no longer breaks and does load the classes correctly, it then fails on syntax errors :

PHP Parse error:  syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in /vagrant/server/vendor/mollie/src/MollieApiClient.php on line 52"

Which is expected since PHP 7.1 : image

Given that upgrading PHP is not an option on my end, unfortunately, can I fallback to an older release? Thank you for your help.

Gummy47 commented 5 months ago

Looking a bit in the release tags, it seems PHP support under 7.2 has been dropped since v.2.47.0 : https://github.com/mollie/mollie-api-php/releases/tag/v2.47.0

I guess someone just forgot to update the readme then.

EDIT : can confirm the problems are gone with the manual install release v2.47.0. Can i use this for legacy code or is it deprecated (for security reasons and/or structural/endpoint changes)? I can always resort to curl calls but i'd prefer using a wrapper.

sandervanhooft commented 5 months ago

Hi @Gummy47 ,

You're right, we overlooked the readme while updating the php dependency. Thanks for reporting!

PHP 7.2 has been EOL (End Of Life) for a very long time now (source) so it's strongly recommended to upgrade as it's not receiving any security patches anymore. It's not possible to upgrade in some cases, I get that.

So your workaround with the v2.47.0 release is fine, as long as you note it will not receive any security or feature updates anymore.