I am writing a Flow application using PHP 7.1.0. In one of my domain models (postalAddress) I have a property named “postbox” for entering the postbox number of a users postal address.
The corresponding setter method looks like this:
/**
* @return string
*/
public function getPostBox(): string
{
return $this->postBox;
}
With the return type string
this method MUST return a valid string (empty strings are allowed), even if the user has no postbox. With PHP 7.1 nullable return types may be defined by preceding the return type with a question mark: http://php.net/manual/en/migration71.new-features.php
/**
* @return string
*/
public function getPostBox(): ?string
{
return $this->postBox;
}
When I create an instance of this entity type in a commandcontroller command, I get this syntax error:
syntax error, unexpected ‘?’
For testing purposes I created a simple test.php file in my localhost directory. In this file I wrote a single function for testing the return type definition. Both variants (with and without “?”) for string return types worked perfectly fine in browser and on command line as well.
==> Seems to be, this is a flow problem, isn’t it?
I’ll attach you guys the complete error log below:
Exception #1355480641 in line 321 of /Applications/MAMP/htdocs/volleymanager.local/Packages/Framework/Neos.Flow/Classes/Core/Booting/Scripts.php: syntax error, unexpected ‘?’
Type: ParseError
File: Packages/Application/SportManager.Core/Classes/Domain/Model/PostalAddress.p
hp
Line: 90
13 Neos\Flow\Core\Booting\Scripts::executeCommand(“neos.flow:core:compile”, array|16|)
12 Neos\Flow\Core\Booting\Scripts::initializeProxyClasses(Neos\Flow\Core\Bootstrap)
11 call_user_func(array|2|, Neos\Flow\Core\Bootstrap)
10 Neos\Flow\Core\Booting\Step::__invoke(Neos\Flow\Core\Bootstrap)
9 Neos\Flow\Core\Booting\Sequence::invokeStep(Neos\Flow\Core\Booting\Step, Neos\Flow\Core\Bootstrap)
8 Neos\Flow\Core\Booting\Sequence::invokeStep(Neos\Flow\Core\Booting\Step, Neos\Flow\Core\Bootstrap)
7 Neos\Flow\Core\Booting\Sequence::invokeStep(Neos\Flow\Core\Booting\Step, Neos\Flow\Core\Bootstrap)
6 Neos\Flow\Core\Booting\Sequence::invokeStep(Neos\Flow\Core\Booting\Step, Neos\Flow\Core\Bootstrap)
5 Neos\Flow\Core\Booting\Sequence::invoke(Neos\Flow\Core\Bootstrap)
4 Neos\Flow\Cli\CommandRequestHandler::boot(“Runtime”)
3 Neos\Flow\Cli\CommandRequestHandler::handleRequest()
2 Neos\Flow\Core\Bootstrap::run()
1 require("/Applications/MAMP/htdocs/volleymanager.local/Packages/Framework/Neos.Flow/Scripts/flow.php")