Skip to content

Commit 19289d8

Browse files
authored
Merge pull request #40 from open-code-modeling/0.8.x-merge-up-into-0.9.x_5fb7a50989a891.92911533
Merge release 0.8.5 into 0.9.x
2 parents 205a608 + 6d0dae6 commit 19289d8

8 files changed

+54
-35
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,27 @@ All notable changes to this project will be documented in this file, in reverse
2424

2525
- Nothing.
2626

27+
## 0.8.5 - 2020-11-20
28+
29+
30+
-----
31+
32+
### Release Notes for [0.8.5](https://github.com/open-code-modeling/php-code-ast/milestone/15)
33+
34+
0.8.x bugfix release (patch)
35+
36+
### 0.8.5
37+
38+
- Total issues resolved: **2**
39+
- Total pull requests resolved: **0**
40+
- Total contributors: **1**
41+
42+
#### bug
43+
44+
- [39: Fix missing fluent interface for setter](https://github.com/open-code-modeling/php-code-ast/issues/39) thanks to @sandrokeil
45+
- [38: Fix PHPStan issues level 5](https://github.com/open-code-modeling/php-code-ast/issues/38) thanks to @sandrokeil
46+
47+
2748
## 0.8.4 - 2020-11-20
2849

2950

phpstan.neon.dist

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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)
@@ -56,7 +56,7 @@ public function getValue(): ValueGenerator
5656
return $this->value;
5757
}
5858

59-
public function generate(): \PhpParser\Node\Stmt\ClassConst
59+
public function generate(): Node\Stmt\ClassConst
6060
{
6161
return new Node\Stmt\ClassConst(
6262
[

src/Code/ClassGenerator.php

Lines changed: 1 addition & 1 deletion
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/MethodGenerator.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,35 +172,35 @@ public function getDocBlockComment(): ?string
172172
return $this->docBlockComment;
173173
}
174174

175-
public function setDocBlockComment(?string $docBlockComment): void
175+
public function setDocBlockComment(?string $docBlockComment): self
176176
{
177177
$this->docBlockComment = $docBlockComment;
178+
179+
return $this;
178180
}
179181

180182
public function getReturnTypeDocBlockHint(): ?string
181183
{
182184
return $this->returnTypeDocBlockHint;
183185
}
184186

185-
public function setReturnTypeDocBlockHint(?string $typeDocBlockHint): void
187+
public function setReturnTypeDocBlockHint(?string $typeDocBlockHint): self
186188
{
187189
$this->returnTypeDocBlockHint = $typeDocBlockHint;
190+
191+
return $this;
188192
}
189193

190-
/**
191-
* @return bool
192-
*/
193194
public function getTyped(): bool
194195
{
195196
return $this->typed;
196197
}
197198

198-
/**
199-
* @param bool $typed
200-
*/
201-
public function setTyped(bool $typed): void
199+
public function setTyped(bool $typed): self
202200
{
203201
$this->typed = $typed;
202+
203+
return $this;
204204
}
205205

206206
/**

src/Code/ParameterGenerator.php

Lines changed: 9 additions & 14 deletions
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

@@ -77,11 +77,7 @@ public function __construct(
7777
}
7878
}
7979

80-
/**
81-
* @param string $type
82-
* @return ParameterGenerator
83-
*/
84-
public function setType($type): self
80+
public function setType(string $type): self
8581
{
8682
$this->type = TypeGenerator::fromTypeString($type);
8783

@@ -99,7 +95,7 @@ public function getType(): ?TypeGenerator
9995
*/
10096
public function setName(string $name): self
10197
{
102-
$this->name = (string) $name;
98+
$this->name = $name;
10399

104100
return $this;
105101
}
@@ -117,7 +113,7 @@ public function getName(): string
117113
*
118114
* Certain variables are difficult to express
119115
*
120-
* @param null|bool|string|int|float|array|ValueGenerator $defaultValue
116+
* @param ValueGenerator|mixed $defaultValue
121117
* @return ParameterGenerator
122118
*/
123119
public function setDefaultValue($defaultValue): self
@@ -130,10 +126,7 @@ public function setDefaultValue($defaultValue): self
130126
return $this;
131127
}
132128

133-
/**
134-
* @return ValueGenerator
135-
*/
136-
public function getDefaultValue(): ValueGenerator
129+
public function getDefaultValue(): ?ValueGenerator
137130
{
138131
return $this->defaultValue;
139132
}
@@ -188,17 +181,19 @@ public function getTypeDocBlockHint(): ?string
188181
/**
189182
* @param string|null $typeDocBlockHint
190183
*/
191-
public function setTypeDocBlockHint(?string $typeDocBlockHint): void
184+
public function setTypeDocBlockHint(?string $typeDocBlockHint): self
192185
{
193186
$this->typeDocBlockHint = $typeDocBlockHint;
187+
188+
return $this;
194189
}
195190

196191
public function generate(): Node\Param
197192
{
198193
return new Node\Param(
199194
new Node\Expr\Variable($this->name),
200195
$this->defaultValue ? $this->defaultValue->generate() : null,
201-
$this->type ? $this->type->generate() : null,
196+
$this->type ? $this->type->generate() : null, // @phpstan-ignore-line
202197
$this->passedByReference,
203198
$this->variadic
204199
);

src/Code/PropertyGenerator.php

Lines changed: 9 additions & 7 deletions
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

@@ -99,9 +99,11 @@ public function getDocBlockComment(): ?string
9999
return $this->docBlockComment;
100100
}
101101

102-
public function setDocBlockComment(?string $docBlockComment): void
102+
public function setDocBlockComment(?string $docBlockComment): self
103103
{
104104
$this->docBlockComment = $docBlockComment;
105+
106+
return $this;
105107
}
106108

107109
/**
@@ -133,10 +135,7 @@ public function setDefaultValue(
133135
return $this;
134136
}
135137

136-
/**
137-
* @return ValueGenerator
138-
*/
139-
public function getDefaultValue(): ValueGenerator
138+
public function getDefaultValue(): ?ValueGenerator
140139
{
141140
return $this->defaultValue;
142141
}
@@ -149,9 +148,11 @@ public function getTypeDocBlockHint(): ?string
149148
return $this->typeDocBlockHint;
150149
}
151150

152-
public function setTypeDocBlockHint(?string $typeDocBlockHint): void
151+
public function setTypeDocBlockHint(?string $typeDocBlockHint): self
153152
{
154153
$this->typeDocBlockHint = $typeDocBlockHint;
154+
155+
return $this;
155156
}
156157

157158
public function generate(): Property
@@ -165,6 +166,7 @@ public function generate(): Property
165166
),
166167
],
167168
$this->generateAttributes(),
169+
// @phpstan-ignore-next-line
168170
$this->typed && null !== $this->type ? $this->type->generate() : null
169171
);
170172
}

src/NodeVisitor/ClassNamespace.php

Lines changed: 2 additions & 1 deletion
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)