diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php
index <HASH>..<HASH> 100644
--- a/src/Analyser/NodeScopeResolver.php
+++ b/src/Analyser/NodeScopeResolver.php
@@ -627,6 +627,8 @@ class NodeScopeResolver
 			}
 		} elseif ($node instanceof Print_) {
 			$scope = $this->lookForAssigns($scope, $node->expr);
+		} elseif ($node instanceof Foreach_) {
+			$scope = $this->lookForAssigns($scope, $node->expr);
 		}
 
 		$scope = $this->updateScopeForVariableAssign($scope, $node);
diff --git a/tests/PHPStan/Rules/Variables/data/defined-variables.php b/tests/PHPStan/Rules/Variables/data/defined-variables.php
index <HASH>..<HASH> 100644
--- a/tests/PHPStan/Rules/Variables/data/defined-variables.php
+++ b/tests/PHPStan/Rules/Variables/data/defined-variables.php
@@ -120,3 +120,8 @@ echo $echoedVariable;
 
 print $printedVariable = 2;
 print $printedVariable;
+
+foreach ($variableAssignedInForeach = [] as $v) {
+
+}
+echo $variableAssignedInForeach;
Foreach iteratee expression can assign a new variable