| @@ 48-59 (lines=12) @@ | ||
| 45 | $exceptions = $this->getExceptionsList(); |
|
| 46 | $nodes = $node->findChildrenOfType('MemberPrimaryPrefix'); |
|
| 47 | ||
| 48 | foreach ($nodes as $methodCall) { |
|
| 49 | if (!$this->isStaticMethodCall($methodCall)) { |
|
| 50 | continue; |
|
| 51 | } |
|
| 52 | ||
| 53 | $className = $methodCall->getChild(0)->getNode()->getImage(); |
|
| 54 | if (in_array(trim($className, " \t\n\r\0\x0B\\"), $exceptions)) { |
|
| 55 | continue; |
|
| 56 | } |
|
| 57 | ||
| 58 | $this->addViolation($methodCall, array($className, $node->getName())); |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| 62 | private function isStaticMethodCall(AbstractNode $methodCall) |
|
| @@ 59-75 (lines=17) @@ | ||
| 56 | */ |
|
| 57 | public function apply(AbstractNode $node) |
|
| 58 | { |
|
| 59 | foreach ($node->findChildrenOfType('Variable') as $variable) { |
|
| 60 | $image = $variable->getImage(); |
|
| 61 | ||
| 62 | if (in_array($image, $this->exceptions)) { |
|
| 63 | continue; |
|
| 64 | } |
|
| 65 | ||
| 66 | if (preg_match('/^\$[_a-z][a-z_0-9]*$/', $image)) { |
|
| 67 | continue; |
|
| 68 | } |
|
| 69 | ||
| 70 | if ($variable->getParent()->isInstanceOf('PropertyPostfix')) { |
|
| 71 | continue; |
|
| 72 | } |
|
| 73 | ||
| 74 | $this->addViolation($node, array($image)); |
|
| 75 | } |
|
| 76 | } |
|
| 77 | } |
|
| 78 | ||