mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Check this properties for redundant conditions
This commit is contained in:
parent
ecf4ed65e3
commit
5bb5bb2476
@ -629,7 +629,6 @@ class ClassLikes
|
||||
}
|
||||
|
||||
if ($classlike_storage->location
|
||||
&& $this->config
|
||||
&& $this->config->isInProjectDirs($classlike_storage->location->file_path)
|
||||
&& !$classlike_storage->is_trait
|
||||
) {
|
||||
|
@ -692,7 +692,7 @@ class Context
|
||||
|
||||
$stripped_var = preg_replace('/(->|\[).*$/', '', $var_name);
|
||||
|
||||
if ($stripped_var[0] === '$' && $stripped_var !== '$this') {
|
||||
if ($stripped_var[0] === '$' && ($stripped_var !== '$this' || $var_name !== $stripped_var)) {
|
||||
$this->referenced_var_ids[$var_name] = true;
|
||||
|
||||
if ($this->collect_references && $statements_checker) {
|
||||
|
@ -1494,6 +1494,23 @@ class PropertyTypeTest extends TestCase
|
||||
if (is_string($a->foo)) {}',
|
||||
'error_message' => 'DocblockTypeContradiction',
|
||||
],
|
||||
'impossiblePropertyCheck' => [
|
||||
'<?php
|
||||
class Bar {}
|
||||
class Foo {
|
||||
/** @var Bar */
|
||||
private $bar;
|
||||
|
||||
public function __construct() {
|
||||
$this->bar = new Bar();
|
||||
}
|
||||
|
||||
public function getBar(): void {
|
||||
if (!$this->bar) {}
|
||||
}
|
||||
}',
|
||||
'error_message' => 'DocblockTypeContradiction',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user