Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit ea574ae

Browse files
committed
Merge pull request #146 from allcode/bugfix/fix-wrong-docblock-return-types
Fixed docblock return types for 3.x releases
2 parents 2de9009 + 07a27fc commit ea574ae

17 files changed

+30
-25
lines changed

src/Generator/ClassGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ public function addUse($use, $useAlias = null)
743743

744744
/**
745745
* @param string $use
746-
* @return self
746+
* @return bool
747747
*/
748748
public function hasUse($use)
749749
{

src/Generator/DocBlock/Tag/AbstractTypeableTag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function __construct($types = [], $description = null)
5050

5151
/**
5252
* @param string $description
53-
* @return ReturnTag
53+
* @return AbstractTypeableTag
5454
*/
5555
public function setDescription($description)
5656
{
@@ -71,7 +71,7 @@ public function getDescription()
7171
* e.g. array('int', 'null') or "int|null"
7272
*
7373
* @param array|string $types
74-
* @return ReturnTag
74+
* @return AbstractTypeableTag
7575
*/
7676
public function setTypes($types)
7777
{

src/Generator/DocBlock/Tag/AuthorTag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct($authorName = null, $authorEmail = null)
4242

4343
/**
4444
* @param ReflectionTagInterface $reflectionTag
45-
* @return ReturnTag
45+
* @return AuthorTag
4646
* @deprecated Deprecated in 2.3. Use TagManager::createTagFromReflection() instead
4747
*/
4848
public static function fromReflection(ReflectionTagInterface $reflectionTag)

src/Generator/DocBlock/Tag/ParamTag.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct($variableName = null, $types = [], $description = nu
3737

3838
/**
3939
* @param ReflectionTagInterface $reflectionTag
40-
* @return ReturnTag
40+
* @return ParamTag
4141
* @deprecated Deprecated in 2.3. Use TagManager::createTagFromReflection() instead
4242
*/
4343
public static function fromReflection(ReflectionTagInterface $reflectionTag)
@@ -75,7 +75,7 @@ public function getVariableName()
7575

7676
/**
7777
* @param string $datatype
78-
* @return ReturnTag
78+
* @return ParamTag
7979
* @deprecated Deprecated in 2.3. Use setTypes() instead
8080
*/
8181
public function setDatatype($datatype)

src/Generator/DocBlockGenerator.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ class DocBlockGenerator extends AbstractGenerator
4949
*/
5050
protected $wordwrap = true;
5151

52+
/**
53+
* @var TagManager
54+
*/
5255
protected static $tagManager;
5356

5457
/**
@@ -107,6 +110,9 @@ public static function fromArray(array $array)
107110
return $docBlock;
108111
}
109112

113+
/**
114+
* @return TagManager
115+
*/
110116
protected static function getTagManager()
111117
{
112118
if (! isset(static::$tagManager)) {

src/Reflection/ClassReflection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function getDeclaringFile()
5050
/**
5151
* Return the classes DocBlock reflection object
5252
*
53-
* @return DocBlockReflection
53+
* @return DocBlockReflection|false
5454
* @throws Exception\ExceptionInterface for missing DocBock or invalid reflection class
5555
*/
5656
public function getDocBlock()
@@ -70,7 +70,7 @@ public function getDocBlock()
7070

7171
/**
7272
* @param AnnotationManager $annotationManager
73-
* @return AnnotationCollection
73+
* @return AnnotationCollection|false
7474
*/
7575
public function getAnnotations(AnnotationManager $annotationManager)
7676
{
@@ -188,7 +188,7 @@ public function getMethods($filter = -1)
188188
/**
189189
* Returns an array of reflection classes of traits used by this class.
190190
*
191-
* @return void|array
191+
* @return null|array
192192
*/
193193
public function getTraits()
194194
{

src/Reflection/DocBlock/Tag/MethodTag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function initialize($tagDocblockLine)
7878
/**
7979
* Get return value type
8080
*
81-
* @return void|string
81+
* @return null|string
8282
* @deprecated 2.0.4 use getTypes instead
8383
*/
8484
public function getReturnType()

src/Reflection/DocBlock/Tag/PropertyTag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function initialize($tagDocblockLine)
6464
}
6565

6666
/**
67-
* @return void|string
67+
* @return null|string
6868
* @deprecated 2.0.4 use getTypes instead
6969
*/
7070
public function getType()

src/Reflection/DocBlockReflection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public static function export()
9191
* @param Reflector|string $commentOrReflector
9292
* @param null|DocBlockTagManager $tagManager
9393
* @throws Exception\InvalidArgumentException
94-
* @return DocBlockReflection
9594
*/
9695
public function __construct($commentOrReflector, DocBlockTagManager $tagManager = null)
9796
{

src/Reflection/FileReflection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function getDocComment()
158158
}
159159

160160
/**
161-
* @return DocBlockReflection
161+
* @return DocBlockReflection|false
162162
*/
163163
public function getDocBlock()
164164
{
@@ -180,7 +180,7 @@ public function getNamespaces()
180180
}
181181

182182
/**
183-
* @return void|string
183+
* @return null|string
184184
*/
185185
public function getNamespace()
186186
{

src/Reflection/FunctionReflection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function getContents($includeDocBlock = true)
132132
* Get method prototype
133133
*
134134
* @param string $format
135-
* @return array
135+
* @return array|string
136136
*/
137137
public function getPrototype($format = FunctionReflection::PROTOTYPE_AS_ARRAY)
138138
{

src/Reflection/MethodReflection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getDocBlock()
6464

6565
/**
6666
* @param AnnotationManager $annotationManager
67-
* @return AnnotationScanner
67+
* @return AnnotationScanner|false
6868
*/
6969
public function getAnnotations(AnnotationManager $annotationManager)
7070
{
@@ -123,7 +123,7 @@ public function getDeclaringClass()
123123
* Get method prototype
124124
*
125125
* @param string $format
126-
* @return array
126+
* @return array|string
127127
*/
128128
public function getPrototype($format = MethodReflection::PROTOTYPE_AS_ARRAY)
129129
{

src/Reflection/ParameterReflection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ public function getDeclaringClass()
3737
/**
3838
* Get class reflection object
3939
*
40-
* @return void|ClassReflection
40+
* @return null|ClassReflection
4141
*/
4242
public function getClass()
4343
{
4444
$phpReflection = parent::getClass();
4545
if ($phpReflection === null) {
46-
return;
46+
return null;
4747
}
4848

4949
$zendReflection = new ClassReflection($phpReflection->getName());

src/Reflection/PropertyReflection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getDocBlock()
6464

6565
/**
6666
* @param AnnotationManager $annotationManager
67-
* @return AnnotationScanner
67+
* @return AnnotationScanner|false
6868
*/
6969
public function getAnnotations(AnnotationManager $annotationManager)
7070
{

src/Scanner/MethodScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function getDocComment()
189189

190190
/**
191191
* @param AnnotationManager $annotationManager
192-
* @return AnnotationScanner
192+
* @return AnnotationScanner|false
193193
*/
194194
public function getAnnotations(AnnotationManager $annotationManager)
195195
{

src/Scanner/PropertyScanner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public function getDocComment()
211211

212212
/**
213213
* @param Annotation\AnnotationManager $annotationManager
214-
* @return AnnotationScanner
214+
* @return AnnotationScanner|false
215215
*/
216216
public function getAnnotations(Annotation\AnnotationManager $annotationManager)
217217
{

src/Scanner/TokenArrayScanner.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function getAnnotationManager()
7676
* @todo Assignment of $this->docComment should probably be done in scan()
7777
* and then $this->getDocComment() just retrieves it.
7878
*
79-
* @return string
79+
* @return string|null
8080
*/
8181
public function getDocComment()
8282
{
@@ -176,7 +176,7 @@ public function getClasses()
176176
*
177177
* @param string|int $name
178178
* @throws Exception\InvalidArgumentException
179-
* @return ClassScanner
179+
* @return ClassScanner|false
180180
*/
181181
public function getClass($name)
182182
{
@@ -663,7 +663,7 @@ public function hasNamespace($namespace)
663663

664664
/**
665665
* @param string $namespace
666-
* @return void|array
666+
* @return null|array
667667
* @throws Exception\InvalidArgumentException
668668
*/
669669
protected function getUsesNoScan($namespace)

0 commit comments

Comments
 (0)