Skip to content

Commit e0b7763

Browse files
committed
tighten up docblocks and types;
1 parent 89ab71e commit e0b7763

File tree

13 files changed

+24
-73
lines changed

13 files changed

+24
-73
lines changed

src/phpDocumentor/Reflection/Php/Argument.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getName(): string
6464
}
6565

6666
/**
67-
* {@inheritDoc}
67+
* @return mixed[]
6868
*/
6969
public function getTypes(): array
7070
{
@@ -80,25 +80,16 @@ public function addType($type): void
8080
$this->types[] = $type;
8181
}
8282

83-
/**
84-
* {@inheritDoc}
85-
*/
8683
public function getDefault(): ?string
8784
{
8885
return $this->default;
8986
}
9087

91-
/**
92-
* {@inheritDoc}
93-
*/
9488
public function isByReference(): bool
9589
{
9690
return $this->byReference;
9791
}
9892

99-
/**
100-
* Returns whether this argument represents a variadic argument.
101-
*/
10293
public function isVariadic(): bool
10394
{
10495
return $this->isVariadic;

src/phpDocumentor/Reflection/Php/Class_.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,12 @@ final class Class_ implements Element
7777
private $usedTraits = [];
7878

7979
/**
80-
* @var null|Location
80+
* @var Location
8181
*/
8282
private $location;
8383

8484
/**
8585
* Initializes a number of properties with the given values. Others are initialized by definition.
86-
*
87-
*
88-
* @param Location|null $location
8986
*/
9087
public function __construct(
9188
Fqsen $fqsen,
@@ -237,15 +234,12 @@ public function getName(): string
237234
return $this->fqsen->getName();
238235
}
239236

240-
/**
241-
* @returns null|DocBlock
242-
*/
243237
public function getDocBlock(): ?DocBlock
244238
{
245239
return $this->docBlock;
246240
}
247241

248-
public function getLocation(): ?Location
242+
public function getLocation(): Location
249243
{
250244
return $this->location;
251245
}

src/phpDocumentor/Reflection/Php/Factory/ClassConstantIterator.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ final class ClassConstantIterator implements Iterator
3030
*/
3131
private $classConstants;
3232

33-
/** @var int index of the current ClassConst to use */
33+
/**
34+
* @var int index of the current ClassConst to use
35+
*/
3436
private $index = 0;
3537

3638
/**
@@ -90,8 +92,6 @@ public function getValue()
9092
}
9193

9294
/**
93-
* (PHP 5 &gt;= 5.0.0)<br/>
94-
* Return the current element
9595
* @link http://php.net/manual/en/iterator.current.php
9696
*/
9797
public function current(): self
@@ -100,8 +100,6 @@ public function current(): self
100100
}
101101

102102
/**
103-
* (PHP 5 &gt;= 5.0.0)<br/>
104-
* Move forward to next element
105103
* @link http://php.net/manual/en/iterator.next.php
106104
*/
107105
public function next(): void
@@ -110,8 +108,6 @@ public function next(): void
110108
}
111109

112110
/**
113-
* (PHP 5 &gt;= 5.0.0)<br/>
114-
* Return the key of the current element
115111
* @link http://php.net/manual/en/iterator.key.php
116112
*/
117113
public function key(): ?int
@@ -120,20 +116,14 @@ public function key(): ?int
120116
}
121117

122118
/**
123-
* (PHP 5 &gt;= 5.0.0)<br/>
124-
* Checks if current position is valid
125119
* @link http://php.net/manual/en/iterator.valid.php
126-
* @return boolean The return value will be casted to boolean and then evaluated.
127-
* Returns true on success or false on failure.
128120
*/
129121
public function valid(): bool
130122
{
131123
return isset($this->classConstants->consts[$this->index]);
132124
}
133125

134126
/**
135-
* (PHP 5 &gt;= 5.0.0)<br/>
136-
* Rewind the Iterator to the first element
137127
* @link http://php.net/manual/en/iterator.rewind.php
138128
*/
139129
public function rewind(): void

src/phpDocumentor/Reflection/Php/Factory/File.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
namespace phpDocumentor\Reflection\Php\Factory;
1616

17+
use phpDocumentor\Reflection\DocBlock;
1718
use phpDocumentor\Reflection\File as FileSystemFile;
1819
use phpDocumentor\Reflection\Fqsen;
1920
use phpDocumentor\Reflection\Middleware\ChainFactory;
@@ -117,7 +118,7 @@ private function createFile(CreateCommand $command)
117118
/**
118119
* @param Node[] $nodes
119120
*/
120-
private function createElements(Fqsen $namespace, $nodes, FileElement $file, StrategyContainer $strategies)
121+
private function createElements(Fqsen $namespace, array $nodes, FileElement $file, StrategyContainer $strategies): void
121122
{
122123
$contextFactory = new ContextFactory();
123124
$context = $contextFactory->createForNamespace((string) $namespace, $file->getSource());
@@ -153,14 +154,13 @@ private function createElements(Fqsen $namespace, $nodes, FileElement $file, Str
153154

154155
/**
155156
* @param Node[] $nodes
156-
* @return null|\phpDocumentor\Reflection\DocBlock
157157
*/
158158
protected function createFileDocBlock(
159-
Doc $docBlock = null,
160-
StrategyContainer $strategies = null,
161-
Context $context = null,
162-
$nodes = []
163-
) {
159+
?Doc $docBlock = null,
160+
?StrategyContainer $strategies = null,
161+
?Context $context = null,
162+
array $nodes = []
163+
): ?DocBlock {
164164
$node = current($nodes);
165165
if (!$node instanceof Node) {
166166
return null;

src/phpDocumentor/Reflection/Php/Factory/Method.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ protected function doCreate($object, StrategyContainer $strategies, ?Context $co
7878

7979
/**
8080
* Converts the visibility of the method to a valid Visibility object.
81-
*
82-
* @return Visibility
8381
*/
84-
private function buildVisibility(ClassMethod $node)
82+
private function buildVisibility(ClassMethod $node): Visibility
8583
{
8684
if ($node->isPrivate()) {
8785
return new Visibility(Visibility::PRIVATE_);

src/phpDocumentor/Reflection/Php/Factory/Property.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,8 @@ protected function doCreate($object, StrategyContainer $strategies, ?Context $co
8080

8181
/**
8282
* Converts the visibility of the property to a valid Visibility object.
83-
*
84-
* @return Visibility
8583
*/
86-
private function buildVisibility(PropertyIterator $node)
84+
private function buildVisibility(PropertyIterator $node): Visibility
8785
{
8886
if ($node->isPrivate()) {
8987
return new Visibility(Visibility::PRIVATE_);

src/phpDocumentor/Reflection/Php/Factory/PropertyIterator.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ public function isStatic(): bool
7878

7979
/**
8080
* Gets line the node started in.
81-
*
82-
* @return int Line
8381
*/
8482
public function getLine(): int
8583
{
@@ -130,19 +128,14 @@ public function getFqsen(): Fqsen
130128
}
131129

132130
/**
133-
* (PHP 5 &gt;= 5.0.0)<br/>
134-
* Return the current element
135131
* @link http://php.net/manual/en/iterator.current.php
136-
* @return PropertyIterator Can return any type.
137132
*/
138133
public function current(): self
139134
{
140135
return $this;
141136
}
142137

143138
/**
144-
* (PHP 5 &gt;= 5.0.0)<br/>
145-
* Move forward to next element
146139
* @link http://php.net/manual/en/iterator.next.php
147140
*/
148141
public function next(): void
@@ -151,31 +144,22 @@ public function next(): void
151144
}
152145

153146
/**
154-
* (PHP 5 &gt;= 5.0.0)<br/>
155-
* Return the key of the current element
156147
* @link http://php.net/manual/en/iterator.key.php
157-
* @return integer scalar on success, or null on failure.
158148
*/
159149
public function key(): ?int
160150
{
161151
return $this->index;
162152
}
163153

164154
/**
165-
* (PHP 5 &gt;= 5.0.0)<br/>
166-
* Checks if current position is valid
167155
* @link http://php.net/manual/en/iterator.valid.php
168-
* @return boolean The return value will be casted to boolean and then evaluated.
169-
* Returns true on success or false on failure.
170156
*/
171157
public function valid(): bool
172158
{
173159
return isset($this->property->props[$this->index]);
174160
}
175161

176162
/**
177-
* (PHP 5 &gt;= 5.0.0)<br/>
178-
* Rewind the Iterator to the first element
179163
* @link http://php.net/manual/en/iterator.rewind.php
180164
*/
181165
public function rewind(): void

src/phpDocumentor/Reflection/Php/Function_.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ final class Function_ implements Element
3333
*/
3434
private $fqsen;
3535

36-
/** @var Argument[] $arguments */
36+
/**
37+
* @var Argument[]
38+
*/
3739
private $arguments = [];
3840

3941
/**
@@ -60,9 +62,9 @@ final class Function_ implements Element
6062
*/
6163
public function __construct(
6264
Fqsen $fqsen,
63-
DocBlock $docBlock = null,
64-
Location $location = null,
65-
Type $returnType = null
65+
?DocBlock $docBlock = null,
66+
?Location $location = null,
67+
?Type $returnType = null
6668
) {
6769
if ($location === null) {
6870
$location = new Location(-1);

src/phpDocumentor/Reflection/Php/Method.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ final class Method implements Element
7474
/**
7575
* Initializes the all properties.
7676
*
77-
*
7877
* @param Visibility|null $visibility when null is provided a default 'public' is set.
79-
* @param DocBlock|null $docBlock
80-
* @param Location|null $location
8178
*/
8279
public function __construct(
8380
Fqsen $fqsen,

src/phpDocumentor/Reflection/Php/NodesFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
namespace phpDocumentor\Reflection\Php;
1616

1717
use phpDocumentor\Reflection\NodeVisitor\ElementNameResolver;
18+
use PhpParser\Node;
1819
use PhpParser\NodeTraverser;
1920
use PhpParser\NodeVisitor\NameResolver;
2021
use PhpParser\Parser;
@@ -72,7 +73,7 @@ public static function createInstance($kind = ParserFactory::PREFER_PHP7): self
7273
* Will convert the provided code to nodes.
7374
*
7475
* @param string $code code to process.
75-
* @return \PhpParser\Node[]
76+
* @return Node[]
7677
*/
7778
public function create(string $code): array
7879
{

src/phpDocumentor/Reflection/Php/Project.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final class Project implements ProjectInterface
4646
* Initializes this descriptor.
4747
*
4848
* @param string $name Name of the current project.
49-
* @param Namespace_ $namespace Root namespace of the project.
49+
* @param null|Namespace_ $namespace Root namespace of the project.
5050
*/
5151
public function __construct(string $name, ?Namespace_ $namespace = null)
5252
{

src/phpDocumentor/Reflection/Php/Property.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ public function __construct(
8383

8484
/**
8585
* returns the default value of this property.
86-
*
87-
* @return string
8886
*/
8987
public function getDefault(): ?string
9088
{

src/phpDocumentor/Reflection/Php/Trait_.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ final class Trait_ implements Element
5252

5353
/**
5454
* Initializes the all properties
55-
*
56-
* @param DocBlock|null $docBlock
5755
*/
5856
public function __construct(Fqsen $fqsen, ?DocBlock $docBlock = null, ?Location $location = null)
5957
{

0 commit comments

Comments
 (0)