Hello, I'm seeing a fatal error trying to use Prophecy with PHPUnit in a Symfony 5 project running PHP 8 with the new static return type. Here is the error:
PHP Fatal error: '\static' is an invalid class name in /Users/alex/dev/project/vendor/bin/.phpunit/phpunit-9.5-0/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassCreator.php(49) : eval()'d code on line 11
And a simplified version of the Entity I'm trying to create a prophecy for:
class MyEntity {
/**
* @ORM\Column(name="id", type="integer", nullable=false, options={"unsigned"=true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private int $id;
/**
* @ORM\Column(name="name", type="string", length=50, nullable=false)
*/
private string $name;
public function getId(): int
{
return $this->id;
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): static // <--- if I replace this with 'self' it works
{
$this->name = $name;
return $this;
}
}
Is this a known issue with PHP 8? Apologies if so but I couldn't find any mention of it.
Or am I doing something wrong with this usage?
Thanks
Hello, I'm seeing a fatal error trying to use Prophecy with PHPUnit in a Symfony 5 project running PHP 8 with the new
staticreturn type. Here is the error:And a simplified version of the Entity I'm trying to create a prophecy for:
Is this a known issue with PHP 8? Apologies if so but I couldn't find any mention of it.
Or am I doing something wrong with this usage?
Thanks