PhpSandbox\ValidatorVisitor::isPrimitive PHP Метод

isPrimitive() защищенный Метод

Test the current PhpParser_Node node to see if it is a primitive, and return the name if it is and null if it is not
protected isPrimitive ( PhpParser\Node $node ) : string | null
$node PhpParser\Node The sandboxed $node to test
Результат string | null Return string name of node, or null if it is not a primitive
    protected function isPrimitive(Node $node)
    {
        switch ($node->getType()) {
            case 'Expr_Cast_Array':
            case 'Expr_Array':
                return 'array';
            case 'Expr_Cast_Bool':
                //booleans are treated as constants otherwise. . .
                return 'bool';
            case 'Expr_Cast_String':
            case 'Scalar_String':
            case 'Scalar_Encapsed':
                return 'string';
            case 'Expr_Cast_Double':
            case 'Scalar_DNumber':
                return 'float';
            case 'Expr_Cast_Int':
            case 'Scalar_LNumber':
                return 'int';
            case 'Expr_Cast_Object':
                return 'object';
        }
        return null;
    }