Skip to content

phpstan-ignore-line not ignoring line #6175

@jacekkarczmarczyk

Description

@jacekkarczmarczyk

Bug report

phpstan-ignore-line does not work in certain circumstances

Code snippet that reproduces the problem

https://phpstan.org/r/51956c1f-c771-478e-b8b7-3ce82321edc6

trait SomeTrait {
	private function sayHello(): ?string // @phpstan-ignore-line
	{
		return $this->value;
	}
}

class HelloWorld2
{
	use SomeTrait;
	private string $value = '';
	public function sayIt(): void
	{
		echo $this->sayHello();
	}
}

Code above raises Method HelloWorld2::sayHello() never returns null so it can be removed from the return type. error

Expected output

no error

Did PHPStan help you today? Did it make you happy in any way?

yup!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions