public function testCachedCallSitesAreRemoved()
 {
     $cachedFooFunc = new GlobalFunction('foo');
     $cachedBarFunc = new GlobalFunction('bar');
     $cachedBarClass = new Clazz('Bar');
     $cachedBarClass->addMethod($cachedBarMethod = new Method('bar'));
     $cachedFooClass = new Clazz('Foo');
     $cachedFooClass->addMethod($cachedFooMethod = new Method('foo'));
     CallSite::create($cachedFooFunc, $cachedBarFunc);
     CallSite::create($cachedFooMethod, $cachedBarFunc);
     CallSite::create($cachedFooMethod, $cachedBarMethod);
     CallSite::create($cachedBarFunc, $cachedFooFunc);
     CallSite::create($cachedBarMethod, $cachedFooFunc);
     $this->provider->addFunction($cachedFooFunc);
     $this->provider->addFunction($cachedBarFunc);
     $this->provider->addClass($cachedBarClass);
     $this->provider->addClass($cachedFooClass);
     $this->analyzeAst('CallGraph/cache.php');
     $fooFunc = $this->registry->getFunction('foo');
     $fooMethod = $this->registry->getClass('Foo')->getMethod('foo')->getMethod();
     $this->assertInCallSites($fooFunc, array($cachedBarMethod), array($cachedBarFunc));
     $this->assertOutCallSites($fooFunc, array(), array());
     $this->assertInCallSites($fooMethod, array(), array());
     $this->assertOutCallSites($fooMethod, array($cachedBarMethod), array($cachedBarFunc));
     $this->assertInCallSites($cachedBarMethod, array($fooMethod), array());
     $this->assertOutCallSites($cachedBarMethod, array(), array($fooFunc));
     $this->assertInCallSites($cachedBarFunc, array($fooMethod), array());
     $this->assertOutCallSites($cachedBarFunc, array(), array($fooFunc));
     $this->assertInCallSites($cachedFooFunc, array($cachedBarMethod), array($cachedBarFunc));
     $this->assertOutCallSites($cachedFooFunc, array(), array($cachedBarFunc));
     $this->assertInCallSites($cachedFooMethod, array(), array());
     $this->assertOutCallSites($cachedFooMethod, array($cachedBarMethod), array($cachedBarFunc));
 }
 public function testDocTypesOfMethods()
 {
     $this->packageVersion->addContainer($foo = new Clazz('Foo'));
     $foo->addMethod($method = new Method('foo'));
     $method->setReturnDocType('self');
     $method->setParamDocType(0, 'string');
     $this->persister->persist($this->packageVersion);
     $reloadedFoo = $this->em->createQuery('SELECT c FROM Scrutinizer\\PhpAnalyzer\\Model\\Clazz c WHERE c.name = :name')->setParameter('name', 'Foo')->getSingleResult();
     $reloadedMethod = $reloadedFoo->getMethod('foo');
     $this->assertEquals(array('param_0' => 'string', 'return' => 'self'), $reloadedMethod->getDocTypes());
 }
 /**
  * @group foreach
  */
 public function testForeach3()
 {
     $this->registry->registerClass($foo = new Clazz('Foo'));
     $foo->setTypeRegistry($this->registry);
     $foo->addImplementedInterface('Iterator');
     $foo->addMethod($current = new Method('current'));
     $current->setReturnType($this->registry->getClassOrCreate('Bar'));
     $this->assuming('y', 'object<Foo>');
     $this->inMethod('$x = $i = null; foreach ($y as $i => $x);');
     $this->verify('x', $this->createNullableType('object<Bar>'));
     $this->verify('i', $this->createNullableType('integer|string'));
 }