Skip to content

Commit 1f1914e

Browse files
committed
Use PHP 7 type check
1 parent 6c0303e commit 1f1914e

File tree

5 files changed

+19
-11
lines changed

5 files changed

+19
-11
lines changed

src/Annotations/IAnnotationParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ interface IAnnotationParser
3434
*
3535
* @return array An array of Annotation properties.
3636
*/
37-
public static function parseAnnotation($value);
37+
public static function parseAnnotation(string $value): array;
3838
}

src/Annotations/standard/ParamAnnotation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ParamAnnotation extends Annotation implements IAnnotationParser, IAnnotati
5959
*
6060
* @return array ['type', 'name']
6161
*/
62-
public static function parseAnnotation($value)
62+
public static function parseAnnotation(string $value): array
6363
{
6464
$parts = \explode(' ', \trim($value), 3);
6565

@@ -85,11 +85,11 @@ public function initAnnotation(array $properties)
8585
parent::initAnnotation($properties);
8686

8787
if (!isset($this->type)) {
88-
throw new AnnotationException('ParamAnnotation requires a type property');
88+
throw new AnnotationException(self::class . ' requires a type property');
8989
}
9090

9191
if (!isset($this->name)) {
92-
throw new AnnotationException('ParamAnnotation requires a name property');
92+
throw new AnnotationException(self::class . ' requires a name property');
9393
}
9494

9595
$this->type = $this->file->resolveType($this->type);

src/Annotations/standard/PropertyAnnotation.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class PropertyAnnotation extends Annotation implements IAnnotationParser, IAnnot
7171
*
7272
* @return array ['type', 'name'] or ['type', 'name', 'description'] if description is set.
7373
*/
74-
public static function parseAnnotation($value)
74+
public static function parseAnnotation(string $value): array
7575
{
7676
$parts = \explode(' ', \trim($value), 3);
7777

@@ -103,11 +103,11 @@ public function initAnnotation(array $properties)
103103
parent::initAnnotation($properties);
104104

105105
if (!isset($this->type)) {
106-
throw new AnnotationException(self::class.' requires a type property');
106+
throw new AnnotationException(self::class . ' requires a type property');
107107
}
108108

109109
if (!isset($this->name)) {
110-
throw new AnnotationException(self::class.' requires a name property');
110+
throw new AnnotationException(self::class . ' requires a name property');
111111
}
112112

113113
$this->type = $this->file->resolveType($this->type);

src/Annotations/standard/ReturnAnnotation.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ReturnAnnotation extends Annotation implements IAnnotationParser, IAnnotat
5252
* @param string $value
5353
* @return array
5454
*/
55-
public static function parseAnnotation($value)
55+
public static function parseAnnotation(string $value): array
5656
{
5757
$parts = \explode(' ', \trim($value), 2);
5858

@@ -61,6 +61,10 @@ public static function parseAnnotation($value)
6161

6262
/**
6363
* Initialize the annotation.
64+
*
65+
* @param array $properties The array of annotation properties.
66+
*
67+
* @throws AnnotationException
6468
*/
6569
public function initAnnotation(array $properties)
6670
{
@@ -69,7 +73,7 @@ public function initAnnotation(array $properties)
6973
parent::initAnnotation($properties);
7074

7175
if (!isset($this->type)) {
72-
throw new AnnotationException('ReturnAnnotation requires a type property');
76+
throw new AnnotationException(self::class . ' requires a type property');
7377
}
7478

7579
$this->type = $this->file->resolveType($this->type);

src/Annotations/standard/VarAnnotation.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class VarAnnotation extends Annotation implements IAnnotationParser, IAnnotation
7373
* @param string $value
7474
* @return array
7575
*/
76-
public static function parseAnnotation($value)
76+
public static function parseAnnotation(string $value): array
7777
{
7878
$parts = \explode(' ', \trim($value), 2);
7979

@@ -82,6 +82,10 @@ public static function parseAnnotation($value)
8282

8383
/**
8484
* Initialize the annotation.
85+
*
86+
* @param array $properties The array of annotation properties.
87+
*
88+
* @throws AnnotationException
8589
*/
8690
public function initAnnotation(array $properties)
8791
{
@@ -90,7 +94,7 @@ public function initAnnotation(array $properties)
9094
parent::initAnnotation($properties);
9195

9296
if (!isset($this->type)) {
93-
throw new AnnotationException(basename(__CLASS__).' requires a type property');
97+
throw new AnnotationException(self::class . ' requires a type property');
9498
}
9599

96100
$this->type = $this->file->resolveType($this->type);

0 commit comments

Comments
 (0)