Skip to content

Commit fca626c

Browse files
committed
PSR-2 love
1 parent 46a218c commit fca626c

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/PhpDocReader/PhpDocReader.php

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ class PhpDocReader
1818
*/
1919
private $phpParser;
2020

21-
22-
/**
23-
* Constructor
24-
*/
2521
public function __construct()
2622
{
2723
$this->phpParser = new PhpParser();
@@ -77,14 +73,21 @@ public function getPropertyType(ReflectionProperty $property)
7773
}
7874

7975
if (!$found) {
80-
throw new AnnotationException("The @var annotation on {$class->name}::" . $property->getName()
81-
. " contains a non existent class. Did you maybe forget to add a 'use' statement for this annotation?");
76+
throw new AnnotationException(sprintf(
77+
'The @var annotation on %s::%s contains a non existent class. '
78+
. 'Did you maybe forget to add a \'use\' statement for this annotation?',
79+
$class->name,
80+
$property->getName()
81+
));
8282
}
8383
}
8484

8585
if (!$this->classExists($type)) {
86-
throw new AnnotationException("The @var annotation on {$class->name}::" . $property->getName()
87-
. " contains a non existent class");
86+
throw new AnnotationException(sprintf(
87+
'The @var annotation on %s::%s contains a non existent class',
88+
$class->name,
89+
$property->getName()
90+
));
8891
}
8992

9093
// Remove the leading \ (FQN shouldn't contain it)
@@ -97,8 +100,8 @@ public function getPropertyType(ReflectionProperty $property)
97100
* Parse the docblock of the property to get the param annotation.
98101
*
99102
* @param ReflectionParameter $parameter
100-
* @throws AnnotationException
101103
*
104+
* @throws AnnotationException
102105
* @return string|null Type of the property (content of var annotation)
103106
*/
104107
public function getParameterType(ReflectionParameter $parameter)
@@ -151,14 +154,23 @@ public function getParameterType(ReflectionParameter $parameter)
151154
}
152155

153156
if (!$found) {
154-
throw new AnnotationException("The @param annotation for parameter $parameterName of {$class->name}::" . $method->name
155-
. " contains a non existent class. Did you maybe forget to add a 'use' statement for this annotation?");
157+
throw new AnnotationException(sprintf(
158+
'The @param annotation for parameter %s of %s::%s contains a non existent class. '
159+
. 'Did you maybe forget to add a \'use\' statement for this annotation?',
160+
$parameterName,
161+
$class->name,
162+
$method->name
163+
));
156164
}
157165
}
158166

159167
if (!$this->classExists($type)) {
160-
throw new AnnotationException("The @param annotation for parameter $parameterName of {$class->name}::" . $method->name
161-
. " contains a non existent class");
168+
throw new AnnotationException(sprintf(
169+
'The @param annotation for parameter %s of %s::%s contains a non existent class',
170+
$parameterName,
171+
$class->name,
172+
$method->name
173+
));
162174
}
163175

164176
// Remove the leading \ (FQN shouldn't contain it)

0 commit comments

Comments
 (0)