PHP Parse error in config helper

Hi,

I was working on some unittests and phpunit always failed with error code 255. So I looked for what I was doing wrong and looked into the php error logs, where I found this:

PHP Parse error:  syntax error, unexpected '|', expecting variable (T_VARIABLE) in kirby/config/helpers.php on line 38

Opening the file with my IDE (vscode) also throws that error on me. This is the function:

if (Helpers::hasOverride('attr') === false) { // @codeCoverageIgnore
	/**
	 * Generates a list of HTML attributes
	 *
	 * @param array|null $attr A list of attributes as key/value array
	 * @param string|null $before An optional string that will be prepended if the result is not empty
	 * @param string|null $after An optional string that will be appended if the result is not empty
	 * @return string|null
	 */
	function attr(array|null $attr = null, string|null $before = null, string|null $after = null): string|null
	{
		return Html::attr($attr, null, $before, $after);
	}
}

Did I just discover a bug or am I doing something strange in my tests suddenly causing this issue?

Kirby 3.8.2 (same problem with 3.8.0)
PHP 8.0.2 (MAMP)

Are you using the right PHP version in PHP unit configuration?

Thanks for the hint, something very fishy is going on on my system. I use mamp to set the php version and set it to 8.0.2 which is also the output of php -v.

After setting composer.json to require php >8, I get an error that says, I need php8 but use php 7.4.12, php -v still says I am using 8.0.2.

I then disabled the mamp linking of php, now php -v returns php 7.4.12 symlinked to Mamp… :face_with_raised_eyebrow:

So I guess, I somehow have a nasty version mix here … :thinking:

edit: it gets even better, after updating php via homebrew it also claims to have php symlinked, which isn’t the case.

Interesting, on my machine, Mamp’s PHP is completely independent of my CLI version. So php -v always gives me the version of which php which is the php version linked via Homebrew.

I un- and reinstalled everything related to php, cleaned up my dotfiles and zsh setup and finally got it working again. What a mess.