Functions   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDeclarationLine() 0 17 3
1
<?php
2
namespace Lepton\Helpers;
3
4
class Functions{
5
static function getDeclarationLine(\ReflectionProperty $prop){
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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
Bug introduced by
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 ignore-type  annotation

16
          /** @scrutinizer ignore-type */ $content)
Loading history...
17
      ) {
18
          return $line + 1;
19
      }
20
  }
21
  return 1;
22
}
23
}
24