Created
April 13, 2012 16:59
-
-
Save manuelpichler/2378355 to your computer and use it in GitHub Desktop.
PHPMD Symfony base class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class My_Custom_Symfony2BarRule extends My_Custom_Symfony2BaseRule | |
{ | |
protected function doApply($class) {} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class My_Custom_Symfony2BaseRule extends PHP_PMD_Rule implements PHP_PMD_Rule_IClassAware | |
{ | |
public final function apply($class) | |
{ | |
if ($this->isController($class)) { | |
$this->doApply($class); | |
} | |
} | |
protected abstract function doApply($class); | |
protected function isController($class) | |
{ | |
foreach ($class->getInterfaces() as $interface) | |
{ | |
if ($interface->getName() === 'ControllerInterface) { | |
return true; | |
} | |
} | |
return false; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class My_Custom_Symfony2FooRule extends My_Custom_Symfony2BaseRule | |
{ | |
protected function doApply($class) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment