1 | <?php |
||||
2 | namespace Lepton\Helpers; |
||||
3 | |||||
4 | class Functions{ |
||||
5 | static function getDeclarationLine(\ReflectionProperty $prop){ |
||||
0 ignored issues
–
show
|
|||||
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) |
||||
0 ignored issues
–
show
It seems like
$content can also be of type array ; however, parameter $subject of preg_match() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
17 | ) { |
||||
18 | return $line + 1; |
||||
19 | } |
||||
20 | } |
||||
21 | return 1; |
||||
22 | } |
||||
23 | } |
||||
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.