public function getIsSubtypeTests() { $tests = array(); try { $registry = new TypeRegistry(); $foo = new Clazz('Foo'); $foo->setSuperClass('Bar'); $foo->setSuperClasses(array('Bar')); $foo->setImplementedInterfaces(array('Baz', 'FooBar')); $foo->setNormalized(true); $tests[] = array($foo, new InterfaceC('FooBar'), true); $tests[] = array($foo, new InterfaceC('Foo'), false); $tests[] = array($foo, $foo, true); $tests[] = array($foo, new Clazz('Bar'), true); $tests[] = array($foo, new Clazz('FooBar'), false); $tests[] = array($foo, NamedType::createResolved($registry, new InterfaceC('Baz')), true); $tests[] = array($foo, NamedType::createResolved($registry, new InterfaceC('Moo')), false); $tests[] = array($foo, NamedType::createResolved($registry, new Clazz('Foo')), true); $tests[] = array($foo, NamedType::createResolved($registry, new Clazz('FoooFooo')), false); $tests[] = array($foo, new UnknownType($registry, false), true); $tests[] = array($foo, new NoObjectType($registry), true); $tests[] = array($foo, new BooleanType($registry), false); $tests[] = array($foo, new IntegerType($registry), false); $tests[] = array($foo, new DoubleType($registry), false); $tests[] = array($foo, new StringType($registry), false); $tests[] = array($foo, $registry->createUnionType(array('string', new InterfaceC('Baz'))), true); $tests[] = array($foo, $registry->createUnionType(array('string', 'boolean')), false); } catch (\Exception $ex) { echo sprintf("Could not get tests for isSubtypeTests(): %s\n", $ex->getMessage() . ' on line ' . $ex->getLine() . ' in file ' . $ex->getFile()); } return $tests; }
private function setUpClass($class, array $extends) { $class = new Clazz($class); if (isset($extends[$class->getName()])) { $parentClass = $this->setUpClass($extends[$class->getName()], $extends); $class->setSuperClasses(array_merge(array($parentClass->getName()), $parentClass->getSuperClasses())); $class->setSuperClass($parentClass->getName()); } $class->setNormalized(true); $this->registry->registerClass($class); return $class; }