Skip to content

Commit 52a4529

Browse files
committed
additional typing added;
1 parent 323b731 commit 52a4529

File tree

7 files changed

+53
-39
lines changed

7 files changed

+53
-39
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
/**
35
* This file is part of phpDocumentor.
46
*
@@ -44,7 +46,7 @@ public function __construct(ClassConst $classConst)
4446
*
4547
* @return int Line
4648
*/
47-
public function getLine()
49+
public function getLine(): int
4850
{
4951
return $this->classConstants->getLine();
5052
}
@@ -54,7 +56,7 @@ public function getLine()
5456
*
5557
* @return string
5658
*/
57-
public function getName()
59+
public function getName(): string
5860
{
5961
return $this->classConstants->consts[$this->index]->name;
6062
}
@@ -64,7 +66,7 @@ public function getName()
6466
*
6567
* @return Fqsen
6668
*/
67-
public function getFqsen()
69+
public function getFqsen(): Fqsen
6870
{
6971
return $this->classConstants->consts[$this->index]->fqsen;
7072
}
@@ -74,7 +76,7 @@ public function getFqsen()
7476
*
7577
* The doc comment has to be the last comment associated with the node.
7678
*
77-
* @return null|Doc Doc comment object or null
79+
* @return null|string|Doc Doc comment object or null
7880
*/
7981
public function getDocComment()
8082
{
@@ -97,7 +99,7 @@ public function getValue()
9799
* @link http://php.net/manual/en/iterator.current.php
98100
* @return mixed Can return any type.
99101
*/
100-
public function current()
102+
public function current(): self
101103
{
102104
return $this;
103105
}
@@ -107,7 +109,7 @@ public function current()
107109
* Move forward to next element
108110
* @link http://php.net/manual/en/iterator.next.php
109111
*/
110-
public function next()
112+
public function next(): void
111113
{
112114
++$this->index;
113115
}
@@ -118,7 +120,7 @@ public function next()
118120
* @link http://php.net/manual/en/iterator.key.php
119121
* @return mixed scalar on success, or null on failure.
120122
*/
121-
public function key()
123+
public function key(): ?int
122124
{
123125
return $this->index;
124126
}
@@ -130,7 +132,7 @@ public function key()
130132
* @return boolean The return value will be casted to boolean and then evaluated.
131133
* Returns true on success or false on failure.
132134
*/
133-
public function valid()
135+
public function valid(): bool
134136
{
135137
return isset($this->classConstants->consts[$this->index]);
136138
}
@@ -140,7 +142,7 @@ public function valid()
140142
* Rewind the Iterator to the first element
141143
* @link http://php.net/manual/en/iterator.rewind.php
142144
*/
143-
public function rewind()
145+
public function rewind(): void
144146
{
145147
$this->index = 0;
146148
}

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

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
/**
35
* This file is part of phpDocumentor.
46
*
@@ -14,8 +16,8 @@
1416

1517
use Iterator;
1618
use phpDocumentor\Reflection\Fqsen;
17-
use PhpParser\Comment;
18-
use PhpParser\Node;
19+
use PhpParser\Comment\Doc;
20+
use PhpParser\Node\Expr;
1921
use PhpParser\Node\Stmt\Property as PropertyNode;
2022

2123
/**
@@ -45,7 +47,7 @@ public function __construct(PropertyNode $property)
4547
*
4648
* @return bool
4749
*/
48-
public function isPublic()
50+
public function isPublic(): bool
4951
{
5052
return $this->property->isPublic();
5153
}
@@ -55,7 +57,7 @@ public function isPublic()
5557
*
5658
* @return bool
5759
*/
58-
public function isProtected()
60+
public function isProtected(): bool
5961
{
6062
return $this->property->isProtected();
6163
}
@@ -65,7 +67,7 @@ public function isProtected()
6567
*
6668
* @return bool
6769
*/
68-
public function isPrivate()
70+
public function isPrivate(): bool
6971
{
7072
return $this->property->isPrivate();
7173
}
@@ -75,7 +77,7 @@ public function isPrivate()
7577
*
7678
* @return bool
7779
*/
78-
public function isStatic()
80+
public function isStatic(): bool
7981
{
8082
return $this->property->isStatic();
8183
}
@@ -85,7 +87,7 @@ public function isStatic()
8587
*
8688
* @return int Line
8789
*/
88-
public function getLine()
90+
public function getLine(): int
8991
{
9092
return $this->property->getLine();
9193
}
@@ -95,7 +97,7 @@ public function getLine()
9597
*
9698
* The doc comment has to be the last comment associated with the node.
9799
*
98-
* @return null|Comment\Doc Doc comment object or null
100+
* @return null|string|Doc Doc comment object or null
99101
*/
100102
public function getDocComment()
101103
{
@@ -112,15 +114,15 @@ public function getDocComment()
112114
*
113115
* @return string
114116
*/
115-
public function getName()
117+
public function getName(): string
116118
{
117119
return $this->property->props[$this->index]->name;
118120
}
119121

120122
/**
121123
* returns the default value of the current property.
122124
*
123-
* @return null|Node\Expr
125+
* @return null|string|Expr
124126
*/
125127
public function getDefault()
126128
{
@@ -132,7 +134,7 @@ public function getDefault()
132134
*
133135
* @return Fqsen
134136
*/
135-
public function getFqsen()
137+
public function getFqsen(): Fqsen
136138
{
137139
return $this->property->props[$this->index]->fqsen;
138140
}
@@ -143,7 +145,7 @@ public function getFqsen()
143145
* @link http://php.net/manual/en/iterator.current.php
144146
* @return PropertyIterator Can return any type.
145147
*/
146-
public function current()
148+
public function current(): self
147149
{
148150
return $this;
149151
}
@@ -153,7 +155,7 @@ public function current()
153155
* Move forward to next element
154156
* @link http://php.net/manual/en/iterator.next.php
155157
*/
156-
public function next()
158+
public function next(): void
157159
{
158160
++$this->index;
159161
}
@@ -164,7 +166,7 @@ public function next()
164166
* @link http://php.net/manual/en/iterator.key.php
165167
* @return integer scalar on success, or null on failure.
166168
*/
167-
public function key()
169+
public function key(): ?int
168170
{
169171
return $this->index;
170172
}
@@ -176,7 +178,7 @@ public function key()
176178
* @return boolean The return value will be casted to boolean and then evaluated.
177179
* Returns true on success or false on failure.
178180
*/
179-
public function valid()
181+
public function valid(): bool
180182
{
181183
return isset($this->property->props[$this->index]);
182184
}
@@ -186,7 +188,7 @@ public function valid()
186188
* Rewind the Iterator to the first element
187189
* @link http://php.net/manual/en/iterator.rewind.php
188190
*/
189-
public function rewind()
191+
public function rewind(): void
190192
{
191193
$this->index = 0;
192194
}

src/phpDocumentor/Reflection/Php/Project.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
/**
35
* This file is part of phpDocumentor.
46
*
@@ -42,7 +44,7 @@ final class Project implements ProjectInterface
4244
* @param string $name Name of the current project.
4345
* @param Namespace_ $namespace Root namespace of the project.
4446
*/
45-
public function __construct($name, Namespace_ $namespace = null)
47+
public function __construct(string $name, Namespace_ $namespace = null)
4648
{
4749
$this->name = $name;
4850
$this->rootNamespace = $namespace;
@@ -66,15 +68,15 @@ public function getName(): string
6668
*
6769
* @return File[]
6870
*/
69-
public function getFiles()
71+
public function getFiles(): array
7072
{
7173
return $this->files;
7274
}
7375

7476
/**
7577
* Add a file to this project.
7678
*/
77-
public function addFile(File $file)
79+
public function addFile(File $file): void
7880
{
7981
$this->files[$file->getPath()] = $file;
8082
}
@@ -84,15 +86,15 @@ public function addFile(File $file)
8486
*
8587
* @return Namespace_[]
8688
*/
87-
public function getNamespaces()
89+
public function getNamespaces(): array
8890
{
8991
return $this->namespaces;
9092
}
9193

9294
/**
9395
* Add a namespace to the project.
9496
*/
95-
public function addNamespace(Namespace_ $namespace)
97+
public function addNamespace(Namespace_ $namespace): void
9698
{
9799
$this->namespaces[(string) $namespace->getFqsen()] = $namespace;
98100
}
@@ -102,7 +104,7 @@ public function addNamespace(Namespace_ $namespace)
102104
*
103105
* @return Namespace_
104106
*/
105-
public function getRootNamespace()
107+
public function getRootNamespace(): Namespace_
106108
{
107109
return $this->rootNamespace;
108110
}

src/phpDocumentor/Reflection/Php/ProjectFactory.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
/**
35
* This file is part of phpDocumentor.
46
*
@@ -34,15 +36,15 @@ final class ProjectFactory implements ProjectFactoryInterface
3436
*
3537
* @param ProjectFactoryStrategy[] $strategies
3638
*/
37-
public function __construct($strategies)
39+
public function __construct(array $strategies)
3840
{
3941
$this->strategies = new ProjectFactoryStrategies($strategies);
4042
}
4143

4244
/**
4345
* Creates a new instance of this factory. With all default strategies.
4446
*/
45-
public static function createInstance()
47+
public static function createInstance(): self
4648
{
4749
return new static(
4850
[
@@ -88,7 +90,7 @@ public function create($name, array $files): ProjectInterface
8890
/**
8991
* Builds the namespace tree with all elements in the project.
9092
*/
91-
private function buildNamespaces(Project $project)
93+
private function buildNamespaces(Project $project): void
9294
{
9395
foreach ($project->getFiles() as $file) {
9496
foreach ($file->getNamespaces() as $namespaceFqsen) {
@@ -103,7 +105,7 @@ private function buildNamespaces(Project $project)
103105
*
104106
* @return Namespace_
105107
*/
106-
private function getNamespaceByName(Project $project, $name)
108+
private function getNamespaceByName(Project $project, $name): Namespace_
107109
{
108110
$existingNamespaces = $project->getNamespaces();
109111

@@ -119,7 +121,7 @@ private function getNamespaceByName(Project $project, $name)
119121
/**
120122
* Adds all elements belonging to the namespace to the namespace.
121123
*/
122-
private function buildNamespace(File $file, Namespace_ $namespace)
124+
private function buildNamespace(File $file, Namespace_ $namespace): void
123125
{
124126
foreach ($file->getClasses() as $class) {
125127
if ($namespace->getFqsen() . '\\' . $class->getName() === (string) $class->getFqsen()) {

src/phpDocumentor/Reflection/Php/ProjectFactoryStrategies.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
/**
35
* This file is part of phpDocumentor.
46
*
@@ -61,7 +63,7 @@ public function findMatching($object)
6163
/**
6264
* Add a strategy to this container.
6365
*/
64-
public function addStrategy(ProjectFactoryStrategy $strategy)
66+
public function addStrategy(ProjectFactoryStrategy $strategy): void
6567
{
6668
$this->strategies[] = $strategy;
6769
}

src/phpDocumentor/Reflection/Php/ProjectFactoryStrategy.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
/**
35
* This file is part of phpDocumentor.
46
*
@@ -23,10 +25,10 @@ interface ProjectFactoryStrategy
2325
/**
2426
* Returns true when the strategy is able to handle the object.
2527
*
26-
* @param object $object object to check.
28+
* @param mixed $object object to check.
2729
* @return boolean
2830
*/
29-
public function matches($object);
31+
public function matches($object): bool;
3032

3133
/**
3234
* Creates an Element out of the given object.

src/phpDocumentor/Reflection/Php/StrategyContainer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
declare(strict_types=1);
3+
24
/**
35
* This file is part of phpDocumentor.
46
*

0 commit comments

Comments
 (0)