Skip to content

Commit 1d2e115

Browse files
committed
fix phpstan
1 parent e3f3293 commit 1d2e115

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

rules/Php73/Rector/FuncCall/JsonThrowOnErrorRector.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ final class JsonThrowOnErrorRector extends AbstractRector implements MinPhpVersi
2929
{
3030
private const array FLAGS = ['JSON_THROW_ON_ERROR'];
3131

32-
private bool $hasChanged = false;
33-
3432
public function __construct(
3533
private readonly ValueResolver $valueResolver,
3634
private readonly BetterNodeFinder $betterNodeFinder
@@ -77,9 +75,9 @@ public function refactor(Node $node): ?Node
7775
return null;
7876
}
7977

80-
$this->hasChanged = false;
78+
$hasChanged = false;
8179

82-
$this->traverseNodesWithCallable($node, function (Node $currentNode): ?FuncCall {
80+
$this->traverseNodesWithCallable($node, function (Node $currentNode) use (&$hasChanged): ?FuncCall {
8381
if (! $currentNode instanceof FuncCall) {
8482
return null;
8583
}
@@ -89,17 +87,17 @@ public function refactor(Node $node): ?Node
8987
}
9088

9189
if ($this->isName($currentNode, 'json_encode')) {
92-
return $this->processJsonEncode($currentNode);
90+
return $this->processJsonEncode($currentNode, $hasChanged);
9391
}
9492

9593
if ($this->isName($currentNode, 'json_decode')) {
96-
return $this->processJsonDecode($currentNode);
94+
return $this->processJsonDecode($currentNode, $hasChanged);
9795
}
9896

9997
return null;
10098
});
10199

102-
if ($this->hasChanged) {
100+
if ($hasChanged) {
103101
return $node;
104102
}
105103

@@ -134,7 +132,7 @@ private function shouldSkipFuncCall(FuncCall $funcCall): bool
134132
return $this->isFirstValueStringOrArray($funcCall);
135133
}
136134

137-
private function processJsonEncode(FuncCall $funcCall): FuncCall
135+
private function processJsonEncode(FuncCall $funcCall, bool &$hasChanged): FuncCall
138136
{
139137
$flags = [];
140138
if (isset($funcCall->args[1])) {
@@ -145,14 +143,14 @@ private function processJsonEncode(FuncCall $funcCall): FuncCall
145143

146144
$newArg = $this->getArgWithFlags($flags);
147145
if ($newArg instanceof Arg) {
148-
$this->hasChanged = true;
146+
$hasChanged = true;
149147
$funcCall->args[1] = $newArg;
150148
}
151149

152150
return $funcCall;
153151
}
154152

155-
private function processJsonDecode(FuncCall $funcCall): FuncCall
153+
private function processJsonDecode(FuncCall $funcCall, bool &$hasChanged): FuncCall
156154
{
157155
$flags = [];
158156
if (isset($funcCall->args[3])) {
@@ -172,7 +170,7 @@ private function processJsonDecode(FuncCall $funcCall): FuncCall
172170

173171
$newArg = $this->getArgWithFlags($flags);
174172
if ($newArg instanceof Arg) {
175-
$this->hasChanged = true;
173+
$hasChanged = true;
176174
$funcCall->args[3] = $newArg;
177175
}
178176

src/ChangesReporting/Output/GitlabOutputFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
private const string ERROR_SEVERITY_MINOR = 'minor';
3131

3232
public function __construct(
33-
private Filehasher $filehasher,
33+
private FileHasher $filehasher,
3434
) {
3535
}
3636

0 commit comments

Comments
 (0)