| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | static function getDeclarationLine(\ReflectionProperty $prop){ |
||
|
|
|||
| 6 | $declaringClass = $prop->getDeclaringClass(); |
||
| 7 | $propname = $prop->getName(); |
||
| 8 | $classFile = new \SplFileObject($declaringClass->getFileName()); |
||
| 9 | foreach ($classFile as $line => $content) { |
||
| 10 | if (preg_match( |
||
| 11 | '/ |
||
| 12 | (private|protected|public|var|static) # match visibility or var |
||
| 13 | \s # followed 1 whitespace |
||
| 14 | \$'.$propname.' # followed by the var name $bar |
||
| 15 | /x', |
||
| 16 | $content) |
||
| 17 | ) { |
||
| 18 | return $line + 1; |
||
| 19 | } |
||
| 20 | } |
||
| 21 | return 1; |
||
| 22 | } |
||
| 24 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.