public function testSignature()
 {
     $ts = new PHP_Token_Stream(TEST_FILES_PATH . 'source5.php');
     $f = $ts->getFunctions();
     $c = $ts->getClasses();
     $i = $ts->getInterfaces();
     $this->assertEquals('foo($a, array $b, array $c = array())', $f['foo']['signature']);
     $this->assertEquals('m($a, array $b, array $c = array())', $c['c']['methods']['m']['signature']);
     $this->assertEquals('m($a, array $b, array $c = array())', $c['a']['methods']['m']['signature']);
     $this->assertEquals('m($a, array $b, array $c = array())', $i['i']['methods']['m']['signature']);
 }
Ejemplo n.º 2
0
 /**
  * Processes whitelisted files that are not covered.
  */
 protected function processUncoveredFilesFromWhitelist()
 {
     $data = array();
     $uncoveredFiles = array_diff($this->filter->getWhitelist(), array_keys($this->data));
     foreach ($uncoveredFiles as $uncoveredFile) {
         if (!file_exists($uncoveredFile)) {
             continue;
         }
         if ($this->cacheTokens) {
             $tokens = PHP_Token_Stream_CachingFactory::get($uncoveredFile);
         } else {
             $tokens = new PHP_Token_Stream($uncoveredFile);
         }
         $classes = $tokens->getClasses();
         $interfaces = $tokens->getInterfaces();
         $functions = $tokens->getFunctions();
         unset($tokens);
         foreach (array_keys($classes) as $class) {
             if (class_exists($class, FALSE)) {
                 continue 2;
             }
         }
         unset($classes);
         foreach (array_keys($interfaces) as $interface) {
             if (interface_exists($interface, FALSE)) {
                 continue 2;
             }
         }
         unset($interfaces);
         foreach (array_keys($functions) as $function) {
             if (function_exists($function)) {
                 continue 2;
             }
         }
         unset($functions);
         $this->driver->start();
         include_once $uncoveredFile;
         $coverage = $this->driver->stop();
         foreach ($coverage as $file => $fileCoverage) {
             if (!isset($data[$file]) && in_array($file, $uncoveredFiles)) {
                 foreach (array_keys($fileCoverage) as $key) {
                     if ($fileCoverage[$key] == 1) {
                         $fileCoverage[$key] = -1;
                     }
                 }
                 $data[$file] = $fileCoverage;
             }
         }
     }
     $this->append($data, 'UNCOVERED_FILES_FROM_WHITELIST');
 }