Changeset 32005
- Timestamp:
- 02/07/11 16:18:09 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfProjectAnalyserPlugin/branches/1.4/lib/objects/paInterface.class.php
r31782 r32005 23 23 */ 24 24 protected $codeLength = 0; 25 26 /** 27 * @var Integer Comment lines if the code 28 */ 29 protected $commentsLength = 0; 30 31 32 /** 33 * @var String The doc comment block of the function is it exists 34 */ 35 public $docComment; 36 37 38 /** 39 * @var Array The list of PaMethods 40 */ 41 protected $paMethods; 42 25 43 26 44 /* GETTERS / SETTERS ********************************************************/ … … 51 69 } 52 70 71 public function getCommentsLength() 72 { 73 return $this->commentsLength; 74 } 75 76 public function getMethods() 77 { 78 return $this->paMethods; 79 } 80 81 public function setDocComment($docComment) 82 { 83 $this->docComment = $docComment; 84 $this->commentsLength = !empty($docComment) ? count(explode("\n", $docComment)) : 0; 85 } 86 53 87 /* END GETTERS / SETTERS ****************************************************/ 54 88 … … 86 120 } 87 121 122 public function getGlobalConfig() 123 { 124 $config = $this->getParent()->getConfig(); 125 return $config['global']; 126 } 127 128 129 88 130 /** 89 131 * Check specific alerts. … … 94 136 public function processAlerts() 95 137 { 138 $globalConfig = $this->getGlobalConfig(); 139 $config = array(); 140 $paMethods = array(); 141 142 $this->reflection=new ReflectionClass($this->getName()); 143 $this->processAlert4002($globalConfig,$config); 144 145 foreach ($this->reflection->getMethods() as $method){ 146 $paMethod=new paMethod($this,$method->getName()); 147 $paMethod->setDocComment($method->getDocComment()); 148 $paMethod->process(); 149 $paMethods[] = $paMethod; 150 } 151 152 $this->paMethods = $paMethods; 153 } 154 155 /** 156 * @internal See message & help. 157 * 158 * @since V0.9.0 - 30/06/10 159 */ 160 protected function processAlert4002($globalConfig, $config) 161 { 162 if ($globalConfig['check_class_docblock'] && $this->commentsLength == 0) 163 { 164 165 $alert = new paAlert( 166 paAlert::ALERT_ACTION_CHECK_DOC_BLOCK, 167 paAlert::WARNING, 168 sprintf('The class or interface "%s" does not have a docblock !', $this->getName()), 169 'Take some time to document the class or the interface' 170 ); 171 172 $this->addAlert($alert); 173 } 96 174 } 97 175 } plugins/sfProjectAnalyserPlugin/branches/1.4/lib/objects/paSfProject.class.php
r31973 r32005 270 270 { 271 271 $countAlerts += $interface->countAlerts($status); 272 foreach($interface->getMethods() as $method){ 273 $countAlerts += $method->countAlerts($status); 274 } 272 275 } 273 276 … … 275 278 { 276 279 $countAlerts += $class->countAlerts($status); 280 foreach($class->getMethods() as $method){ 281 $countAlerts += $method->countAlerts($status); 282 } 277 283 } 278 284 … … 335 341 $plugin->process(); 336 342 } 337 338 343 foreach ($this->classes as $class) 339 344 { … … 423 428 ->in($this->paths['sf_plugins_dir']) 424 429 ; 425 430 426 431 foreach ($results as $pluginDirectory) 427 432 { … … 435 440 } 436 441 442 if($parseAllPlugin){ 443 $this->processLib($this->paths['sf_plugins_dir'],false, 444 array_merge($pluginsToIgnore, 445 array('templates', 446 'actions' 447 )), 448 array('*Generator*')); 449 } 450 437 451 $this->plugins = $plugins; 438 452 } … … 443 457 * as symfony native classes. 444 458 */ 445 protected function processLib( )459 protected function processLib($path=null,$required=true,$prune=array(),$not_name=array()) 446 460 { 447 461 $classes = array(); 448 462 $interfaces = array(); 449 $libObjects = $this->extractClasses($this->paths['sf_lib_dir']); 463 if(is_null($path)){ 464 $path=$this->paths['sf_lib_dir']; 465 } 466 $libObjects = $this->extractClasses($path,$prune,$not_name); 450 467 $ignoredClasses = $this->getIgnoredObjects('classes'); 451 468 … … 459 476 460 477 $object = null; 461 478 462 479 if (class_exists($class)) 463 480 { 464 481 // Create the reflection object 465 482 $reflectionClass = new ReflectionClass($class); 466 $parent = $reflectionClass->getParentClass(); 483 try{ 484 $parent = $reflectionClass->getParentClass(); 485 }catch (Exception $e){ 486 487 } 467 488 468 489 while ($parent instanceof ReflectionClass) … … 511 532 // Unkown error for this class 512 533 else 513 { 534 { 514 535 // Error 515 throw new RuntimeException('Problem with class : '. $class. ', if seems like a bug of the plugin send me an email. :)'); 536 if($required){ 537 throw new RuntimeException('Problem with class : '. $class. ', if seems like a bug of the plugin send me an email. :)'); 538 } 516 539 } 517 540 … … 520 543 521 544 // Keep the file name in the object ?? 522 $object->setCodeLength(empty($fileContent) ? 0 : count(explode("\n", $fileContent))); 523 } 524 525 $this->interfaces = $interfaces; 526 $this->classes = $classes; 545 if($object) 546 $object->setCodeLength(empty($fileContent) ? 0 : count(explode("\n", $fileContent))); 547 } 548 549 $this->interfaces = array_merge($this->interfaces ,$interfaces); 550 $this->classes = array_merge($this->classes ,$classes); 527 551 } 528 552 … … 532 556 * @see sfAutoloadCore::make 533 557 */ 534 public function extractClasses($sfLibDir )558 public function extractClasses($sfLibDir,$prune=array(),$not_name=array()) 535 559 { 536 560 $files = sfFinder::type('file') 537 561 ->prune('plugins') 562 ->prune('fixtures') 538 563 ->prune('vendor') 539 564 ->prune('skeleton') 540 565 ->prune('default') 541 566 ->prune('helper') 542 ->name('*.php') 543 ->in($sfLibDir) 544 ; 545 567 ->prune('test'); 568 569 foreach ($prune as $pr) { 570 $files->prune($pr); 571 } 572 573 foreach ($not_name as $nn) { 574 $files->not_name($nn); 575 } 576 577 if(strtolower(sfConfig::get('sf_orm'))=='doctrine'){ 578 $files->not_name('*Propel*'); 579 }else{ 580 $files->not_name('*Doctrine*'); 581 } 582 583 $files=$files->name('*.php') 584 ->in($sfLibDir); 546 585 sort($files, SORT_STRING); 547 586 … … 549 588 foreach ($files as $file) 550 589 { 590 sfSimpleAutoload::getInstance()->addFile($file); 551 591 $file = str_replace(DIRECTORY_SEPARATOR, '/', $file); 552 592 $class = basename($file, false === strpos($file, '.class.php') ? '.php' : '.class.php');