plan2net / webp

Create a WebP copy for images (TYPO3 CMS)
GNU General Public License v3.0
60 stars 33 forks source link

V4.3 breaks with syntax error on PHP < 8.1 #99

Closed cschnell closed 5 months ago

cschnell commented 5 months ago

Hi, The 4.x tags claim to support PHP versions >= 7.2, see https://github.com/plan2net/webp/blob/0a7c3cd2e221065f0521b9ab1168dfa8ba1693a6/composer.json#L22

The change in https://github.com/plan2net/webp/commit/899fe99d49860be61f37b6d1404a90daf3ebaaf8 however uses a language construct ("First class callable") introduced in PHP 8.1

So this change breaks 1) the PHP requirements 2) semantic versioning and has already been reported in https://github.com/plan2net/webp/issues/98#issuecomment-2031375308

The solution is to create a real closure like this:

private function parseStripColorProfileCommand(): mixed
    {
        return $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_stripColorProfileCommand'] ??
            implode(
                ' ',
                array_map(
                    \Closure::fromCallable([CommandUtility::class, 'escapeShellArgument']),
                    $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor_stripColorProfileParameters'] ?? [],
                ),
            );
    }

I'll provide a PR

cschnell commented 5 months ago

Added PR https://github.com/plan2net/webp/pull/100