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; } } } } } } } } } } } } }
public function is_not_assignable_from($type) { $union = new TypeUnion([Primitive::$STRING, Primitive::$INT, $this->getClass()]); $this->assertFalse($union->isAssignableFrom($type)); }