Skip to content

Commit c7e465d

Browse files
committed
recognize where nullable types are used, and where they are not;
1 parent 404ae12 commit c7e465d

File tree

11 files changed

+31
-32
lines changed

11 files changed

+31
-32
lines changed

src/phpDocumentor/Reflection/NodeVisitor/ElementNameResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private function resetState(?string $namespace = null): void
121121
/**
122122
* Builds the name of the current node using the parts that are pushed to the parts list.
123123
*/
124-
private function buildName(): ?string
124+
private function buildName(): string
125125
{
126126
$name = null;
127127
foreach ($this->parts as $part) {

src/phpDocumentor/Reflection/Php/Class_.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ final class Class_ implements Element
4343
private $final = false;
4444

4545
/**
46-
* @var Class_ The class this class is extending.
46+
* @var null|Fqsen The class this class is extending.
4747
*/
4848
private $parent = null;
4949

@@ -75,11 +75,11 @@ final class Class_ implements Element
7575
*/
7676
public function __construct(
7777
Fqsen $fqsen,
78-
DocBlock $docBlock = null,
79-
Fqsen $parent = null,
78+
?DocBlock $docBlock = null,
79+
?Fqsen $parent = null,
8080
bool $abstract = false,
8181
bool $final = false,
82-
Location $location = null
82+
?Location $location = null
8383
) {
8484
if ($location === null) {
8585
$location = new Location(-1);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ protected function createMember($stmt, StrategyContainer $strategies, ?Context $
4545
/**
4646
* @return null|DocBlockInstance
4747
*/
48-
protected function createDocBlock(StrategyContainer $strategies, ?Doc $docBlock = null, ?Context $context = null)
48+
protected function createDocBlock(?StrategyContainer $strategies = null, ?Doc $docBlock = null, ?Context $context = null)
4949
{
50-
if ($docBlock === null) {
50+
if ($docBlock === null || $strategies === null) {
5151
return null;
5252
}
5353

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function getFqsen(): Fqsen
7272
*
7373
* The doc comment has to be the last comment associated with the node.
7474
*
75-
* @return null|string|Doc Doc comment object or null
75+
* @return null|Doc Doc comment object or null
7676
*/
7777
public function getDocComment()
7878
{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function matches($object): bool
6767
*/
6868
public function create($object, StrategyContainer $strategies, ?Context $context = null)
6969
{
70-
if ($object === null) {
70+
if ($object == null) {
7171
return null;
7272
}
7373

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function getLine(): int
8989
*
9090
* The doc comment has to be the last comment associated with the node.
9191
*
92-
* @return null|string|Doc Doc comment object or null
92+
* @return null|Doc Doc comment object or null
9393
*/
9494
public function getDocComment()
9595
{

src/phpDocumentor/Reflection/Php/File.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class File
3636
/** @var string $path */
3737
private $path = null;
3838

39-
/** @var string|null $source */
39+
/** @var string $source */
4040
private $source = null;
4141

4242
/** @var Fqsen[] $namespaces */
@@ -65,9 +65,8 @@ final class File
6565
*
6666
*
6767
* @param string $hash An MD5 hash of the contents if this file.
68-
* @param string|null $source
6968
*/
70-
public function __construct(string $hash, string $path, ?string $source = null, ?DocBlock $docBlock = null)
69+
public function __construct(string $hash, string $path, string $source = '', ?DocBlock $docBlock = null)
7170
{
7271
$this->hash = $hash;
7372
$this->path = $path;
@@ -87,7 +86,7 @@ public function getHash(): string
8786
/**
8887
* Retrieves the contents of this file.
8988
*/
90-
public function getSource(): ?string
89+
public function getSource(): string
9190
{
9291
return $this->source;
9392
}

src/phpDocumentor/Reflection/Php/Interface_.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ final class Interface_ implements Element
5858
public function __construct(
5959
Fqsen $fqsen,
6060
array $parents = [],
61-
DocBlock $docBlock = null,
62-
Location $location = null
61+
?DocBlock $docBlock = null,
62+
?Location $location = null
6363
) {
6464
if ($location === null) {
6565
$location = new Location(-1);

src/phpDocumentor/Reflection/Php/Method.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ final class Method implements Element
4545
/** @var bool $static */
4646
private $static = false;
4747

48-
/** @var Visibility visibility of this method */
48+
/** @var null|Visibility visibility of this method */
4949
private $visibility = null;
5050

5151
/** @var Argument[] */
@@ -71,13 +71,13 @@ final class Method implements Element
7171
*/
7272
public function __construct(
7373
Fqsen $fqsen,
74-
Visibility $visibility = null,
75-
DocBlock $docBlock = null,
74+
?Visibility $visibility = null,
75+
?DocBlock $docBlock = null,
7676
bool $abstract = false,
7777
bool $static = false,
7878
bool $final = false,
79-
Location $location = null,
80-
Type $returnType = null
79+
?Location $location = null,
80+
?Type $returnType = null
8181
) {
8282
$this->fqsen = $fqsen;
8383
$this->visibility = $visibility;
@@ -129,7 +129,7 @@ public function isStatic(): bool
129129
/**
130130
* Returns the Visibility of this method.
131131
*/
132-
public function getVisibility(): Visibility
132+
public function getVisibility(): ?Visibility
133133
{
134134
return $this->visibility;
135135
}

src/phpDocumentor/Reflection/Php/Project.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class Project implements ProjectInterface
2525
/** @var string $name */
2626
private $name = '';
2727

28-
/** @var Namespace_ $rootNamespace */
28+
/** @var Namespace_|null */
2929
private $rootNamespace;
3030

3131
/**
@@ -100,7 +100,7 @@ public function addNamespace(Namespace_ $namespace): void
100100
/**
101101
* Returns the root (global) namespace.
102102
*/
103-
public function getRootNamespace(): Namespace_
103+
public function getRootNamespace(): ?Namespace_
104104
{
105105
return $this->rootNamespace;
106106
}

0 commit comments

Comments
 (0)