Verified on latest main
PHPantom version / commit
phpantom_lsp 33718a6
Installation method
Built from source
Operating system
Linux x86_64
Editor
Zed
Bug description
phpantom_lsp only take into account the last @phpstan-assert-if-true
Steps to reproduce
- create a file with:
declare(strict_types=1);
class Example {
public function compute(?\DateTimeInterface $start, ?\DateTimeInterface $end): int|false {
if ($this->areBothDatesDefined($this->startDate, $this->endDate)) {
return $this->getMinutesDifference($this->startDate, $this->endDate);
}
return false;
}
/**
* @phpstan-assert-if-true \DateTimeInterface $start
* @phpstan-assert-if-true \DateTimeInterface $end
*/
private function areBothDatesDefined(?\DateTimeInterface $start, ?\DateTimeInterface $end): bool
{
return $start instanceof \DateTimeInterface && $end instanceof \DateTimeInterface;
}
/**
* Get the difference in minutes between end date and start date.
*/
private function getMinutesDifference(\DateTimeInterface $startDate, \DateTimeInterface $endDate): int
{
return (int) round(($endDate->getTimestamp() - $startDate->getTimestamp()) / 60);
}
}
Error output or panic trace
Argument 1 ($startDate) expects DateTimeInterface, got null|DateTimeImmutable (null does not satisfy DateTimeInterface)
🪪 type_mismatch_argument
.phpantom.toml
[diagnostics]
unresolved-member-access = true
extra-arguments = true
workspace = true
[indexing]
strategy = "full"
[phpstan]
command="tools/phpstan/vendor/bin/phpstan"
[phpcs]
command="tools/phpcs/vendor/bin/phpcs"
[formatting]
php-cs-fixer="tools/php-cs-fixer/vendor/bin/php-cs-fixer"
phpcbf="tools/phpcs/vendor/bin/phpcbf"
Additional context
No response
Verified on latest main
mainbranch.PHPantom version / commit
phpantom_lsp 33718a6
Installation method
Built from source
Operating system
Linux x86_64
Editor
Zed
Bug description
phpantom_lsp only take into account the last
@phpstan-assert-if-trueSteps to reproduce
Error output or panic trace
.phpantom.toml
Additional context
No response