Skip to content

Commit fd00676

Browse files
committed
Fix PHPStan issues level 5 - Close #38
1 parent e953d90 commit fd00676

6 files changed

+12
-15
lines changed

phpstan.neon.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
parameters:
2-
level: 3
2+
level: 5
33
paths:
44
- src/

src/Code/ClassConstGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class ClassConstGenerator extends AbstractMemberGenerator
2121

2222
/**
2323
* @param string $name
24-
* @param ValueGenerator|string|array $value
24+
* @param ValueGenerator|mixed $value
2525
* @param int $flags
2626
*/
2727
public function __construct(string $name, $value, $flags = self::FLAG_PUBLIC)

src/Code/ClassGenerator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final class ClassGenerator implements StatementGenerator
3737

3838
/**
3939
* @param string|null $name
40-
* @param array|string $flags
40+
* @param array|int $flags
4141
*/
4242
public function __construct(
4343
?string $name,

src/Code/ParameterGenerator.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final class ParameterGenerator
3333
private $type;
3434

3535
/**
36-
* @var ValueGenerator
36+
* @var ValueGenerator|null
3737
*/
3838
private $defaultValue;
3939

@@ -117,7 +117,7 @@ public function getName(): string
117117
*
118118
* Certain variables are difficult to express
119119
*
120-
* @param null|bool|string|int|float|array|ValueGenerator $defaultValue
120+
* @param ValueGenerator|mixed $defaultValue
121121
* @return ParameterGenerator
122122
*/
123123
public function setDefaultValue($defaultValue): self
@@ -130,10 +130,7 @@ public function setDefaultValue($defaultValue): self
130130
return $this;
131131
}
132132

133-
/**
134-
* @return ValueGenerator
135-
*/
136-
public function getDefaultValue(): ValueGenerator
133+
public function getDefaultValue(): ?ValueGenerator
137134
{
138135
return $this->defaultValue;
139136
}
@@ -195,6 +192,7 @@ public function setTypeDocBlockHint(?string $typeDocBlockHint): void
195192

196193
public function generate(): Node\Param
197194
{
195+
// @phpstan-ignore-next-line
198196
return new Node\Param(
199197
new Node\Expr\Variable($this->name),
200198
$this->defaultValue ? $this->defaultValue->generate() : null,

src/Code/PropertyGenerator.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class PropertyGenerator extends AbstractMemberGenerator
3232
private $type;
3333

3434
/**
35-
* @var ValueGenerator
35+
* @var ValueGenerator|null
3636
*/
3737
private $defaultValue;
3838

@@ -133,10 +133,7 @@ public function setDefaultValue(
133133
return $this;
134134
}
135135

136-
/**
137-
* @return ValueGenerator
138-
*/
139-
public function getDefaultValue(): ValueGenerator
136+
public function getDefaultValue(): ?ValueGenerator
140137
{
141138
return $this->defaultValue;
142139
}
@@ -156,6 +153,7 @@ public function setTypeDocBlockHint(?string $typeDocBlockHint): void
156153

157154
public function generate(): Property
158155
{
156+
// @phpstan-ignore-next-line
159157
return new Property(
160158
$this->flags,
161159
[

src/NodeVisitor/ClassNamespace.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespace OpenCodeModeling\CodeAst\NodeVisitor;
1212

1313
use PhpParser\BuilderFactory;
14+
use PhpParser\Node;
1415
use PhpParser\Node\Stmt;
1516
use PhpParser\NodeVisitorAbstract;
1617

@@ -57,7 +58,7 @@ public function afterTraverse(array $nodes): ?array
5758
return $newNodes;
5859
}
5960

60-
private function isNodeStrictType(Stmt $node): bool
61+
private function isNodeStrictType(Node $node): bool
6162
{
6263
return $node instanceof Stmt\Declare_
6364
&& \strtolower($node->declares[0]->key->name) === 'strict_types';

0 commit comments

Comments
 (0)