Skip to content

Commit 7ea50ff

Browse files
committed
misc
1 parent 76c5038 commit 7ea50ff

File tree

5 files changed

+27
-11
lines changed

5 files changed

+27
-11
lines changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ includes:
55
parameters:
66
level: 8
77
errorFormat: symplify
8-
# reportUnmatchedIgnoredErrors: false
8+
reportUnmatchedIgnoredErrors: false
99

1010
# see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases
1111
typeAliases:
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Rector\Tests\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector\Fixture;
4+
5+
final class BracketMatches
6+
{
7+
public function run($delimiter)
8+
{
9+
$delimiter = match ($delimiter) {
10+
'(' => ')',
11+
'{' => '}',
12+
'[' => ']',
13+
'<' => '>',
14+
default => $delimiter
15+
};
16+
}
17+
}
18+
19+
?>

rules-tests/DowngradePhp80/Rector/MethodCall/DowngradeReflectionGetAttributesRector/Fixture/class_is_nullable.php

Whitespace-only changes.

rules/DowngradePhp73/Rector/ConstFetch/DowngradePhp73JsonConstRector.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ private function markConstantKnownInInnerStmts(If_ $if): void
118118
SimpleNodeTraverser::decorateWithAttributeValue($if, self::PHP73_JSON_CONSTANT_IS_KNOWN, true);
119119
}
120120

121-
private function resolveFuncCall(Expression $Expression): ?FuncCall
121+
private function resolveFuncCall(Expression $expression): ?FuncCall
122122
{
123-
$expr = $Expression->expr;
123+
$expr = $expression->expr;
124124
if ($expr instanceof Assign) {
125125
if ($expr->expr instanceof FuncCall) {
126126
return $expr->expr;
@@ -154,8 +154,6 @@ private function refactorExpression(Expression $expression): ?array
154154

155155
// retrieve a `FuncCall`, if any, from the statement
156156
$funcCall = $this->resolveFuncCall($expression);
157-
158-
// Nothing to do if no `FuncCall` found
159157
if (! $funcCall instanceof FuncCall) {
160158
return null;
161159
}
@@ -165,12 +163,12 @@ private function refactorExpression(Expression $expression): ?array
165163
return null;
166164
}
167165

168-
if ($funcCall->isFirstClassCallable()) {
166+
// Nothing to do if the flag `JSON_THROW_ON_ERROR` is not set in args
167+
if (! $this->hasConstFetchInArgs($funcCall->getArgs(), 'JSON_THROW_ON_ERROR')) {
169168
return null;
170169
}
171170

172-
// Nothing to do if the flag `JSON_THROW_ON_ERROR` is not set in args
173-
if (! $this->hasConstFetchInArgs($funcCall->getArgs(), 'JSON_THROW_ON_ERROR')) {
171+
if ($funcCall->isFirstClassCallable()) {
174172
return null;
175173
}
176174

@@ -203,8 +201,7 @@ private function hasConstFetchInArgs(array $args, string $constName): bool
203201
{
204202
foreach ($args as $arg) {
205203
$value = $arg->value;
206-
207-
if ($value instanceof ConstFetch && $this->getName($value) === $constName) {
204+
if ($value instanceof ConstFetch && $this->isName($value, $constName)) {
208205
return true;
209206
}
210207

tests/Issues/DowngradeNullJson/Fixture/fixture.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Fixture
2222
{
2323
public function run(?int $flags = null)
2424
{
25-
$flags = $flags ?? JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRESERVE_ZERO_FRACTION;
25+
$flags = $flags ?? JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_PRESERVE_ZERO_FRACTION | 0;
2626

2727
json_encode([], $flags);
2828
}

0 commit comments

Comments
 (0)