Skip to content

Instantly share code, notes, and snippets.

@manuelpichler
Created April 13, 2012 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manuelpichler/2378294 to your computer and use it in GitHub Desktop.
Save manuelpichler/2378294 to your computer and use it in GitHub Desktop.
Custom PHPMD rule
<?php
class My_Custom_Symfony2Rule extends PHP_PMD_Rule implements PHP_PMD_Rule_IClassAware
{
public function apply($class)
{
// Skip here
if (false === $this->isController($class)) {
return;
}
// Do some controller specific analysis
}
protected function isController($class)
{
foreach ($class->getInterfaces() as $interface)
{
if ($interface->getName() === 'ControllerInterface) {
return true;
}
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment