Skip to content

Return of void method reported as used, when it is not #1656

@gmazzap

Description

@gmazzap

Summary of problem

The rule: "Result of method {xxx} (void) is used" should IMO check that the result of a void method is actually used, i.e. set to a variable or passed to a function/method...

However it does not seems to work like that.

Code snippet that reproduces the problem

class HelloWorld {

	public function test(): void {
		return;
	}
	
	public function testVoidResult(): void {
                // this does not use the return value of `test()`, still it is reported
		true or $this->test();
	}
}

https://phpstan.org/r/dea43fe8-b309-491b-bdde-b06bfcbaed88

Expected output

I would expect the rule to report an error only if the void return is actually used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions