public function testObjectTypes()
 {
     $class = new \Scrutinizer\PhpAnalyzer\Model\Clazz('Foo');
     $class->setNormalized(true);
     $this->registry->registerClass($class);
     $this->assertUnion('object<Foo>', new NamedType($this->registry, 'Foo'), $class);
     $named = new NamedType($this->registry, 'Foo');
     $named->setReferencedType($class);
     $this->assertUnion('object<Foo>', $named, $class);
 }
 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;
 }
 public function testNamedTypeResolved()
 {
     $this->assertDatabaseValue(NamedType::createResolved($this->registry, new Clazz('Foo')), 'object<Foo>');
 }
 public function testIsSubtypeWithNamedTypes()
 {
     $bar = new \Scrutinizer\PhpAnalyzer\Model\InterfaceC('Bar');
     $bar->setNormalized(true);
     $foo = new Clazz('Foo');
     $foo->setNormalized(true);
     $this->assertFalse($foo->isSubtypeOf($bar));
     $foo->addImplementedInterface('Bar');
     $namedBar = NamedType::createResolved($this->registry, $bar);
     $this->assertTrue($foo->isSubTypeOf($namedBar));
     $this->assertTrue($foo->isSubTypeOf($bar));
     $namedFoo = NamedType::createResolved($this->registry, $foo);
     $this->assertTrue($namedFoo->isSubtypeOf($namedBar));
     $this->assertTrue($namedFoo->isSubtypeOf($bar));
     $unresolvedNamedBar = new NamedType($this->registry, 'Bar');
     $this->assertTrue($foo->isSubtypeOf($unresolvedNamedBar));
     $this->assertTrue($namedFoo->isSubtypeOf($unresolvedNamedBar));
     $baz = new InterfaceC('Baz');
     $baz->setNormalized(true);
     $this->assertFalse($baz->isSubtypeOf($bar));
     $this->assertFalse($baz->isSubtypeOf($namedBar));
     $this->assertFalse($baz->isSubtypeOf($unresolvedNamedBar));
     $baz->addExtendedInterface('Bar');
     $this->assertTrue($baz->isSubtypeOf($bar));
     $this->assertTrue($baz->isSubtypeOf($namedBar));
     $this->assertTrue($baz->isSubtypeOf($unresolvedNamedBar));
 }