-
-
Notifications
You must be signed in to change notification settings - Fork 942
Description
Based on a discussion under a commit that converts $this->assert*() to self::assert*() in Doctrine: doctrine/dbal@62eb475#commitcomment-24420550
PHP still allows calling static method non-statically, although such behavior could be considered unsafe and not a good practice. Hopefully PHP will come to a point where this behavior will be deprecated.
Example:
class Test
{
public function foo() : void
{
$this->bar();
}
public static function bar() : void
{
}
}This currently works, PHP has no problems with mixing static and non-static calls (sadly). Also PHPStan is happy.
I'd like to propose a new rule that would ban this abomination altogether. 🥇 I'd love to see it in core in L5/L6 for example, but if it's too agressive (some people may think so), at least to be included in the upcoming phpstan-extra-strict-rules repo.
Thoughts?
cc-ing @PowerKiKi & @Ocramius from the abovementioned discussion.