Skip to content

Extension causing "return statement is missing" false positives #113

Closed
@xificurk

Description

@xificurk

After update to PHPStan 0.12 and PHPStan exception rules 0.10 we started getting a lot of false positives of type Method *** should return *** but return statement is missing.

It looks like the root cause is in this extension. Here is a minimal code to reproduce the error:

<?php declare(strict_types = 1);

trait FooTrait
{
	abstract public function getString() : string;
}

class Foo
{
	use FooTrait;
	public function getString() : string
	{
		return 'Foo';
	}
}

With bare phpstan no errors are reported.
After enabling exception rules extension the following error is reported:

------ ------------------------------------------------------------------------------- 
  Line   Foo.php (in context of class Foo)                                              
 ------ ------------------------------------------------------------------------------- 
  5      Method Foo::getString() should return string but return statement is missing.  
 ------ ------------------------------------------------------------------------------- 

 [ERROR] Found 1 error

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions