Bug #95528
closedPHP parse error in PackageArtifactBuilder
0%
Description
While updating to Version 11.5 an error is thrown
PHP Parse error: syntax error, unexpected 'Event' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in PackageArtifactBuilder.php on line 49
This error also appears with a new installation
Updated by Georg Ringer over 3 years ago
- Status changed from New to Needs Feedback
are you really using PHP 7.4?
Updated by Benni Mack over 3 years ago
This usually happens if the server (CI build server) runs a different PHP version or composer version than the production system, is that possible?
Updated by Oliver Hader over 3 years ago
- Subject changed from Update to TYPO3 v11.5 to PHP parse error in PackageArtifactBuilder
Line 49 of PackageArtifactBuilder.php
has the following
private Event $event;
Thus, Benni's assumption seems to be correct - the application is used with a PHP version lower than PHP 7.4.
Updated by Benni Mack over 3 years ago
- Status changed from Needs Feedback to Closed
Updated by Sebastian Schmal over 3 years ago
same Error here after "composer update"
Error:
PHP Parse error: syntax error, unexpected 'Event' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /public/typo3/sysext/core/Classes/Composer/PackageArtifactBuilder.php on line 49 Parse error: syntax error, unexpected 'Event' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /public/typo3/sysext/core/Classes/Composer/PackageArtifactBuilder.php on line 49
PHP: PHP Version 7.4.23
Updated by Roley McGallagher over 3 years ago
I get this error if I use PHP8.0
PHP Parse error: syntax error, unexpected 'Event' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in \app\public\typo3\sysext\core\Classes\Composer\PackageArtifactBuilder.php on line 49 Parse error: syntax error, unexpected 'Event' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in \app\public\typo3\sysext\core\Classes\Composer\PackageArtifactBuilder.php on line 49
On PHP7.4 everything is fine.
Updated by Sebastian Schmal about 3 years ago
same error here after "composer update":
PHP Parse error: syntax error, unexpected 'Event' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /public/typo3/sysext/core/Classes/Composer/PackageArtifactBuilder.php on line 49 Parse error: syntax error, unexpected 'Event' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /public/typo3/sysext/core/Classes/Composer/PackageArtifactBuilder.php on line 49
$php74 --version
PHP 7.4.26 (cli) (built: Nov 19 2021 11:52:45) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with the ionCube PHP Loader + ionCube24 v10.4.0, Copyright (c) 2002-2020, by ionCube Ltd.
Updated by Sebastian Schmal about 3 years ago
Damit geht nun alles:
http://www.typo3-probleme.de/2021/11/17/all-inkl-typo3-composer-installation-2516/
php74 composer.phar update
Updated by Jörg Velletti about 3 years ago
Same error on a shared hoster: (df.eu)
php --version -> 7.4.1..
composer --version -> 2.1.14 ..
but still composer is loading from "somewhere" php 7.3
Final solution from this gist https://gist.github.com/peterkraume/95b6ea3620cad311865e69a686564fc7
ln -s /usr/bin/php74 ~/php
and add to:
.bashrc
export PATH=$HOME:$PATH
Updated by Christian Kuhn about 3 years ago
- Related to Task #96017: Relax PackageArtifactBuilder to support PHP 7.1 added
Updated by Christian Kuhn about 3 years ago
Hey.
All reports probably come from instances where the php version in web context is 7.4 or higher, but on cli it's still < 7.4. It is unfortunate some hosters don't get this right, and there are probably various workaround for specific ones.
In this case, we relaxed this file a bit to also deal with older PHP versions, this is class executed early and "hooked" into composer does not fail when the PHP version is too old. See #96017 for details.