PHPStan\Analyser\Scope::enterForeach PHP Method

enterForeach() public method

public enterForeach ( PhpParser\Node $iteratee, string $valueName, string $keyName = null ) : self
$iteratee PhpParser\Node
$valueName string
$keyName string
return self
    public function enterForeach(Node $iteratee, string $valueName, string $keyName = null) : self
    {
        $iterateeType = $this->getType($iteratee);
        $variableTypes = $this->getVariableTypes();
        if ($iterateeType instanceof ArrayType) {
            $variableTypes[$valueName] = $iterateeType->getItemType();
        } else {
            $variableTypes[$valueName] = new MixedType(true);
        }
        if ($keyName !== null) {
            $variableTypes[$keyName] = new MixedType(false);
        }
        return new self($this->broker, $this->printer, $this->getFile(), $this->isDeclareStrictTypes(), $this->getClass(), $this->getFunction(), $this->getNamespace(), $variableTypes, $this->inClosureBindScopeClass, $this->getAnonymousFunctionReturnType(), $this->isInAnonymousClass() ? $this->getAnonymousClass() : null, null, $this->isNegated(), $this->moreSpecificTypes);
    }