public function testAnalyze()
 {
     $service = new ServiceAnalyzer('JMS\\SecurityExtraBundle\\Tests\\Fixtures\\MainService');
     $service->analyze();
     $methods = $service->getMetadata()->getMethods();
     $this->assertTrue(isset($methods['differentMethodSignature']));
     $metadata = $methods['differentMethodSignature'];
     $this->assertEquals(array(array('EDIT')), $metadata->getParamPermissions());
     $this->assertEquals(array(), $metadata->getReturnPermissions());
     $this->assertEquals(array(), $metadata->getRoles());
     $this->assertFalse($metadata->isDeclaredOnInterface());
 }
 private function processDefinition(ContainerBuilder $container, $id, Definition $definition)
 {
     if ($this->needsReAssessment($id, $definition)) {
         $analyzer = new ServiceAnalyzer($definition->getClass(), $container->get('annotation_reader'));
         $analyzer->analyze();
         $files = array();
         foreach ($analyzer->getFiles() as $file) {
             $container->addResource($file = new FileResource($file));
             $files[] = $file;
         }
         $metadata = $analyzer->getMetadata();
         $proxyClass = $path = null;
         if (true === $metadata->isProxyRequired()) {
             list($newClassName, $content) = $this->generator->generate($definition, $metadata);
             file_put_contents($path = $this->cacheDir . 'SecurityProxies/' . $newClassName . '.php', $content);
             $definition->setFile($path);
             $definition->setClass($proxyClass = 'SecurityProxies\\' . $newClassName);
             $definition->addMethodCall('jmsSecurityExtraBundle__setMethodSecurityInterceptor', array(new Reference('security.access.method_interceptor')));
         } else {
             if (isset($this->cacheMetadata[$id]['proxy_class'])) {
                 @unlink($this->cacheDir . $this->cacheMetadata[$id]['proxy_class'] . '.php');
             }
         }
         $this->cacheMetadata[$id] = array('class' => $definition->getClass(), 'proxy_class' => $proxyClass, 'proxy_file' => $path, 'analyze_time' => time(), 'files' => $files);
     } else {
         foreach ($this->cacheMetadata[$id]['files'] as $file) {
             $container->addResource($file);
         }
         if (null !== ($proxyClass = $this->cacheMetadata[$id]['proxy_class'])) {
             $definition->setFile($this->cacheMetadata[$id]['proxy_file']);
             $definition->setClass($proxyClass);
             $definition->addMethodCall('jmsSecurityExtraBundle__setMethodSecurityInterceptor', array(new Reference('security.access.method_interceptor')));
         }
     }
 }