Gets the object type with the supplied class name.
public getObjectType ( string $classType ) : Pinq\Analysis\IObjectType | ||
$classType | string | |
return | Pinq\Analysis\IObjectType |
public function visitClosure(O\ClosureExpression $expression) { $originalContext = $this->analysisContext; $this->analysisContext = $originalContext->inNewScope(); foreach ($expression->getParameters() as $parameter) { $this->walk($parameter); $typeHintType = $this->typeSystem->getTypeFromTypeHint($parameter->getTypeHint()); if (!$parameter->hasDefaultValue() || $this->analysis[$parameter->getDefaultValue()]->isEqualTo($typeHintType)) { $this->analysisContext->setExpressionType($parameter->asVariable(), $typeHintType); } else { $this->analysisContext->setExpressionType($parameter->asVariable(), $this->typeSystem->getNativeType(INativeType::TYPE_MIXED)); } } foreach ($expression->getUsedVariables() as $usedVariable) { $variable = $usedVariable->asVariable(); //TODO: handle references with used variables. Probably impossible though. $this->analysisContext->setExpressionType($variable, $originalContext->getExpressionType($variable)); } $this->walkAll($expression->getBodyExpressions()); $this->analysis[$expression] = $this->typeSystem->getObjectType('Closure'); $this->analysisContext = $originalContext; }
protected function assertReturnsObjectType(callable $expression, $objectType, array $variableTypeMap = []) { $this->assertReturnsType($expression, $this->typeSystem->getObjectType($objectType), $variableTypeMap); }