1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Ignore more redundant issues

This commit is contained in:
bugreportuser 2019-02-18 20:31:08 -06:00 committed by Matthew Brown
parent f49be31aeb
commit 61e086ac7b
2 changed files with 39 additions and 0 deletions

View File

@ -553,8 +553,11 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer implements Statements
if ($context->collect_initializations) {
$statements_analyzer->addSuppressedIssues([
'DocblockTypeContradiction',
'InvalidReturnStatement',
'RedundantCondition',
'RedundantConditionGivenDocblockType',
'TypeDoesNotContainNull',
'TypeDoesNotContainType',
]);
}

View File

@ -1376,6 +1376,42 @@ class PropertyTypeTest extends TestCase
return 2;
}
public function __construct () {
$this->x = false;
if ($this->func1()) {
$this->y = $this->func2();
}
$this->func2();
}
}'
],
'noRedundantConditionWhenCheckingInitializationsEdgeCases' => [
'<?php
final class Clazz {
/**
* @var bool
*/
public $x;
/**
* @var int
*/
public $y = 0;
public function func1 (): bool {
if ($this->y !== 0) {
return true;
}
return false;
}
public function func2 (): int {
if ($this->y !== 0) {
return $this->y;
}
return 2;
}
public function __construct () {
$this->x = false;
if ($this->func1()) {