diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 09cf856d8..dba10ab56 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -19,6 +19,8 @@
src/Psalm/Issue/
src/Psalm/Internal/Stubs/
src/Psalm/Internal/LanguageServer/
+ src/Psalm/Internal/ExecutionEnvironment/
+ src/Psalm/SourceControl/
src/command_functions.php
src/psalm.php
src/psalm-language-server.php
@@ -26,6 +28,7 @@
src/psalm_plugin.php
src/Psalm/Internal/CallMap.php
src/Psalm/Internal/Fork/Pool.php
+ src/Psalm/Internal/Fork/Restarter.php
src/Psalm/Internal/PropertyMap.php
src/Psalm/Internal/Provider/ClassLikeStorageCacheProvider.php
src/Psalm/Internal/Provider/FileReferenceCacheProvider.php
diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php
index d214d508c..c36c72b4d 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/AssertionFinder.php
@@ -180,8 +180,6 @@ class AssertionFinder
if ($count_equality_position) {
if ($count_equality_position === self::ASSIGNMENT_TO_RIGHT) {
$counted_expr = $conditional->left;
- } elseif ($count_equality_position === self::ASSIGNMENT_TO_LEFT) {
- $counted_expr = $conditional->right;
} else {
throw new \UnexpectedValueException('$count_equality_position value');
}
@@ -238,9 +236,7 @@ class AssertionFinder
$typed_value_position = self::hasTypedValueComparison($conditional);
if ($count_equality_position) {
- if ($count_equality_position === self::ASSIGNMENT_TO_RIGHT) {
- $count_expr = $conditional->left;
- } elseif ($count_equality_position === self::ASSIGNMENT_TO_LEFT) {
+ if ($count_equality_position === self::ASSIGNMENT_TO_LEFT) {
$count_expr = $conditional->right;
} else {
throw new \UnexpectedValueException('$count_equality_position value');
@@ -306,23 +302,6 @@ class AssertionFinder
if ($var_name) {
$if_types[$var_name] = [['empty']];
- } else {
- // look for any variables we *can* use for an isset assertion
- $array_root = $conditional->expr;
-
- while ($array_root instanceof PhpParser\Node\Expr\ArrayDimFetch && !$var_name) {
- $array_root = $array_root->var;
-
- $var_name = ExpressionAnalyzer::getArrayVarId(
- $array_root,
- $this_class_name,
- $source
- );
- }
-
- if ($var_name) {
- $if_types[$var_name] = [['=empty']];
- }
}
$conditional->assertions = $if_types;
@@ -718,7 +697,7 @@ class AssertionFinder
}
} else {
if (IssueBuffer::accepts(
- new TypeDoesNotContainNull(
+ new TypeDoesNotContainType(
$var_type . ' does not contain empty array',
new CodeLocation($source, $conditional)
),
diff --git a/tests/AssignmentTest.php b/tests/AssignmentTest.php
index 673be223e..74c230331 100644
--- a/tests/AssignmentTest.php
+++ b/tests/AssignmentTest.php
@@ -45,6 +45,12 @@ class AssignmentTest extends TestCase
echo $x;
}',
],
+ 'ifAssignment' => [
+ ' [
+ ' [
+ ' 'RedundantCondition',
],
+ 'redundantInstanceof' => [
+ ' 'RedundantConditionGivenDocblockType',
+ ],
+ 'preventDocblockTypesBeingIdenticalToTrue' => [
+ ' 'DocblockTypeContradiction',
+ ],
+ 'preventDocblockTypesBeingIdenticalToTrueReversed' => [
+ ' 'DocblockTypeContradiction',
+ ],
+ 'preventDocblockTypesBeingIdenticalToFalse' => [
+ ' 'DocblockTypeContradiction',
+ ],
+ 'preventDocblockTypesBeingIdenticalToFalseReversed' => [
+ ' 'DocblockTypeContradiction',
+ ],
+ 'preventDocblockTypesBeingSameAsEmptyArrayReversed' => [
+ ' 'DocblockTypeContradiction',
+ ],
+ 'preventDocblockTypesBeingIdenticalToEmptyArrayReversed' => [
+ ' 'DocblockTypeContradiction',
+ ],
+ 'preventTypesBeingIdenticalToEmptyArrayReversed' => [
+ ' 'TypeDoesNotContainType',
+ ],
];
}
}