[ERROR] Argument 2 passed to Symplify\CodingStandard\SniffTokenWrapper\ClassWrapper::createFromFileAndPosition() must
be of the type integer, boolean given, called in
<project path>/vendor/symplify/coding-standard/src/Sniffs/Property/DynamicPropertySniff.php on line 81
I dumped $this->file in the getClassWrapper method and it turns out that it is a file with trait. So it can't find a T_CLASS token there obviously.
By the way a T_CLASS token could actually be there somewhere if I used an anonymous class inside of that file. That might cause more problems.
Also I'm still on the 2.5 branch because I can't use SF 4.0 for now.
Thanks for the report. Could you please provide minimal PHP code causing this error?
Like this:
trait SomeTrait
{
public function someMetho()
{
$this->missingProperty;
}
}
I can fix that in current master, then you can backport it to 2.5 branch.
Will try tomorrow.
This seems to be the minimal code:
<?php declare(strict_types = 1);
trait Payload
{
protected $payload = [];
protected function setPayload(array $payload): void
{
$this->payload = $payload;
}
}
Great job!
Could you send that as failing test to the master here as correct4.php.inc file? I'll pull and fix it then much easily
I've added test case and it is working on master.
Just look to ClassWrapper and try to apply same code to 2.5: https://github.com/Symplify/Symplify/blob/a4540e1178b5c8ad9419c4e48b105c43b97109e9/packages/TokenRunner/src/Wrapper/SnifferWrapper/ClassWrapper.php#L47
I fixed it and tagged a new version. Thanks.
Happy to help!