null example

public function getClass(): string
    {
        return Collection::class;
    }

    public function isMethodSupported(MethodReflection $methodReflection, MethodCall $node, TypeSpecifierContext $context): bool
    {
        return (
            $methodReflection->getDeclaringClass()->getName() === Collection::class
            || $methodReflection->getDeclaringClass()->isSubclassOf(Collection::class)
        )
            && $methodReflection->getName() === 'has' && !$context->null();
    }

    public function specifyTypes(MethodReflection $methodReflection, MethodCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes
    {
        $getExpr = new MethodCall($node->var, 'get', $node->args);

        $getterTypes = $this->typeSpecifier->create(
            $getExpr,
            TypeCombinator::removeNull($scope->getType($getExpr)),
            $context
        );

        
Home | Imprint | This part of the site doesn't use cookies.