| Conditions | 10 | 
| Paths | 16 | 
| Total Lines | 31 | 
| Code Lines | 18 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php | ||
| 74 | public static function getPropertyLine(\ReflectionProperty $property) | ||
| 75 | 	{ | ||
| 76 | $class = $property->getDeclaringClass(); | ||
| 77 | |||
| 78 | $context = 'file'; | ||
| 79 | $contextBrackets = 0; | ||
| 80 | 		foreach (token_get_all(file_get_contents($class->getFileName())) as $token) { | ||
| 81 | 			if ($token === '{') { | ||
| 82 | $contextBrackets += 1; | ||
| 83 | |||
| 84 | 			} elseif ($token === '}') { | ||
| 85 | $contextBrackets -= 1; | ||
| 86 | } | ||
| 87 | |||
| 88 | 			if (!is_array($token)) { | ||
| 89 | continue; | ||
| 90 | } | ||
| 91 | |||
| 92 | 			if ($token[0] === T_CLASS) { | ||
| 93 | $context = 'class'; | ||
| 94 | $contextBrackets = 0; | ||
| 95 | |||
| 96 | 			} elseif ($context === 'class' && $contextBrackets === 1 && $token[0] === T_VARIABLE) { | ||
| 97 | 				if ($token[1] === '$' . $property->getName()) { | ||
| 98 | return $token[2]; | ||
| 99 | } | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | return NULL; | ||
| 104 | } | ||
| 105 | |||
| 126 | 
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.