diff --git a/src/Php/Parser/AssignOpTrait.php b/src/Php/Parser/AssignOpTrait.php index ac1e8690..3594bf74 100644 --- a/src/Php/Parser/AssignOpTrait.php +++ b/src/Php/Parser/AssignOpTrait.php @@ -236,7 +236,8 @@ trait AssignOpTrait $finalVarType = $this->isNativeType($type) ? $this->getNativeType($type) : $type; $this->addLocalVar($var, $finalVarType); } else { - $this->checkVarAssignExpr($left, $this->getVarType($var), $type); + $finalVarType = $this->getVarType($var); + $this->checkVarAssignExpr($left, $finalVarType, $type); } } } elseif ($this->isPropertyFetch($left) and !$left->getAttribute('nativeProperty')) { @@ -252,17 +253,6 @@ trait AssignOpTrait return $this->parseAssignArrayDim($left, $right); } - // When the RHS is untyped (TYPE_VAR) but the LHS variable already has a known - // native type, use the LHS type for the conversion so that e.g. - // php::Int i; ... i = n; (n is php::Var) - // becomes i = php::toInt(n); - if ($finalVarType === self::TYPE_VAR && $this->hasVar($var)) { - $varType = $this->getVarType($var); - if ($varType !== self::TYPE_VAR) { - $finalVarType = $varType; - } - } - $rightExpr = $this->parseAssignRightExpr($right); $leftExprType = $this->detectTypeOfExpr($left); $rightExprType = $this->detectTypeOfExpr($right);