PHP8 named arguments are not supported
Author: jorgsowaCreated Nov 26, 2021Updated Sep 29, 2022
LabelsPHP8.0
I found out that it's not possible to mock methods which are using named parameters. Example:
$this->repository = $this->prophesize(Repository::class);
$this->repository
->get([self::ID], orderBy: 'sort, id')
->willReturn($objects)
->shouldBeCalledOnce();The same parameters are used in the referenced method, but still, I can't mock this function and receive the error:
Return value must be of type Objects, null returned.
When I provide defaults values for all the preceding parameters it works fine.
Source: phpspec/prophecy