예제 #1
0
 public function hash_table_of_string_Generic_is_assignable_top_hash_of_int_any()
 {
     $this->assertFalse(WildcardType::forName('util.collections.HashTable<int, ?>')->isAssignableFrom(Type::forName('util.collections.HashTable<string, lang.Generic>')));
 }
예제 #2
0
function is($type, $object)
{
    if (null === $type) {
        return $object instanceof __null;
    } else {
        if ('int' === $type) {
            return is_int($object);
        } else {
            if ('double' === $type) {
                return is_double($object);
            } else {
                if ('string' === $type) {
                    return is_string($object);
                } else {
                    if ('bool' === $type) {
                        return is_bool($object);
                    } else {
                        if ('var' === $type) {
                            return true;
                        } else {
                            if (0 === strncmp($type, 'function(', 9)) {
                                return \lang\FunctionType::forName($type)->isInstance($object);
                            } else {
                                if (0 === substr_compare($type, '[]', -2)) {
                                    return (new \lang\ArrayType(substr($type, 0, -2)))->isInstance($object);
                                } else {
                                    if (0 === substr_compare($type, '[:', 0, 2)) {
                                        return (new \lang\MapType(substr($type, 2, -1)))->isInstance($object);
                                    } else {
                                        if (0 === strncmp($type, '(function(', 10)) {
                                            return \lang\FunctionType::forName(substr($type, 1, -1))->isInstance($object);
                                        } else {
                                            if (strstr($type, '|')) {
                                                return \lang\TypeUnion::forName($type)->isInstance($object);
                                            } else {
                                                if (strstr($type, '?')) {
                                                    return \lang\WildcardType::forName($type)->isInstance($object);
                                                } else {
                                                    $literal = literal($type);
                                                    return $object instanceof $literal;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}