tea icon indicating copy to clipboard operation
tea copied to clipboard

Bug: lintPhp fails for php 8.1 and php 8.2

Open linxpinx opened this issue 7 months ago • 2 comments

Short problem description

lintPhp throws error:

Parse error: Tests/Functional/Command/CreateTestDataCommandTest.php:21
    19|      * @var non-empty-string
    20|      */
  > 21|     private const string COMMAND_NAME = 'tea:create-test-data';
    22| 
    23|     protected array $testExtensionsToLoad = ['ttn/tea'];
Unexpected identifier "COMMAND_NAME", expecting "="

Steps to reproduce the problem

Run job

actual behavior

command fails

expected behavior

command runs green

Additional Information

Parse error: Tests/Functional/Command/CreateTestDataCommandTest.php:21
    19|      * @var non-empty-string
    20|      */
  > 21|     private const string COMMAND_NAME = 'tea:create-test-data';
    22| 
    23|     protected array $testExtensionsToLoad = ['ttn/tea'];
Unexpected identifier "COMMAND_NAME", expecting "="

linxpinx avatar May 24 '25 16:05 linxpinx

That is not a bug. TYPED class constants have been introduced with PHP 8.3 and can only be used when the minimal used/supported PHP version is PHP8.3 or newer.

And this means, that the lintPhp checks executed PHP 8.1 and 8.2 do their jobs and ensures that used PHP codes is parsable with all supported PHP versions.

Either PHP version must be raised to at least 8.3+ (and with it the litings) or code needs to be written in 8.1 compatible way.

Instead of

private const string COMMAND_NAME = 'tea:create-test-data';

use

private const COMMAND_NAME = 'tea:create-test-data';

My personal opionion (not official for this repository as I'm not part of the team) is, that a extension must support the full supported PHP version range related to supported TYPO3 Core Versions (at least public extensions). I know that that other have other opionens.

sbuerk avatar May 26 '25 08:05 sbuerk

This will be solved by #1332.

oliverklee avatar May 27 '25 08:05 oliverklee