Skip to content

Commit e25e515

Browse files
committed
misc
1 parent 15f94e7 commit e25e515

54 files changed

Lines changed: 150 additions & 75 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

rules-tests/TypeDeclarationDocblocks/Rector/FuncCall/AddArrayAnyAllClosureParamTypeFromDocblockRector/AddArrayAnyAllClosureParamTypeFromDocblockRectorTest.php renamed to rules-tests/TypeDeclaration/Rector/FuncCall/AddArrayAnyAllClosureParamTypeRector/AddArrayAnyAllClosureParamTypeRectorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace Rector\Tests\TypeDeclarationDocblocks\Rector\FuncCall\AddArrayAnyAllClosureParamTypeFromDocblockRector;
5+
namespace Rector\Tests\TypeDeclaration\Rector\FuncCall\AddArrayAnyAllClosureParamTypeRector;
66

77
use Iterator;
88
use PHPUnit\Framework\Attributes\DataProvider;
99
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
1010

11-
final class AddArrayAnyAllClosureParamTypeFromDocblockRectorTest extends AbstractRectorTestCase
11+
final class AddArrayAnyAllClosureParamTypeRectorTest extends AbstractRectorTestCase
1212
{
1313
#[DataProvider('provideData')]
1414
public function test(string $filePath): void

rules-tests/TypeDeclarationDocblocks/Rector/FuncCall/AddArrayAnyAllClosureParamTypeFromDocblockRector/Fixture/array_all_closure.php.inc renamed to rules-tests/TypeDeclaration/Rector/FuncCall/AddArrayAnyAllClosureParamTypeRector/Fixture/array_all_closure.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Rector\Tests\TypeDeclarationDocblocks\Rector\FuncCall\AddArrayAnyAllClosureParamTypeFromDocblockRector\Fixture;
3+
namespace Rector\Tests\TypeDeclaration\Rector\FuncCall\AddArrayAnyAllClosureParamTypeRector\Fixture;
44

55
function arrayAllClosure()
66
{
@@ -16,7 +16,7 @@ function arrayAllClosure()
1616
-----
1717
<?php
1818

19-
namespace Rector\Tests\TypeDeclarationDocblocks\Rector\FuncCall\AddArrayAnyAllClosureParamTypeFromDocblockRector\Fixture;
19+
namespace Rector\Tests\TypeDeclaration\Rector\FuncCall\AddArrayAnyAllClosureParamTypeRector\Fixture;
2020

2121
function arrayAllClosure()
2222
{

rules-tests/TypeDeclarationDocblocks/Rector/FuncCall/AddArrayAnyAllClosureParamTypeFromDocblockRector/Fixture/array_any_arrow_function.php.inc renamed to rules-tests/TypeDeclaration/Rector/FuncCall/AddArrayAnyAllClosureParamTypeRector/Fixture/array_any_arrow_function.php.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Rector\Tests\TypeDeclarationDocblocks\Rector\FuncCall\AddArrayAnyAllClosureParamTypeFromDocblockRector\Fixture;
3+
namespace Rector\Tests\TypeDeclaration\Rector\FuncCall\AddArrayAnyAllClosureParamTypeRector\Fixture;
44

55
function arrayAnyArrowFunction()
66
{
@@ -14,7 +14,7 @@ function arrayAnyArrowFunction()
1414
-----
1515
<?php
1616

17-
namespace Rector\Tests\TypeDeclarationDocblocks\Rector\FuncCall\AddArrayAnyAllClosureParamTypeFromDocblockRector\Fixture;
17+
namespace Rector\Tests\TypeDeclaration\Rector\FuncCall\AddArrayAnyAllClosureParamTypeRector\Fixture;
1818

1919
function arrayAnyArrowFunction()
2020
{

rules-tests/TypeDeclarationDocblocks/Rector/FuncCall/AddArrayAnyAllClosureParamTypeFromDocblockRector/Fixture/skip_already_typed.php.inc renamed to rules-tests/TypeDeclaration/Rector/FuncCall/AddArrayAnyAllClosureParamTypeRector/Fixture/skip_already_typed.php.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Rector\Tests\TypeDeclarationDocblocks\Rector\FuncCall\AddArrayAnyAllClosureParamTypeFromDocblockRector\Fixture;
3+
namespace Rector\Tests\TypeDeclaration\Rector\FuncCall\AddArrayAnyAllClosureParamTypeRector\Fixture;
44

55
function skipAlreadyTyped()
66
{
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\FuncCall\AddArrayAnyAllClosureParamTypeRector\Fixture;
4+
5+
function skipMixedArray($items)
6+
{
7+
return array_any($items, fn ($item): bool => $item !== '');
8+
}

rules-tests/TypeDeclarationDocblocks/Rector/FuncCall/AddArrayAnyAllClosureParamTypeFromDocblockRector/config/configured_rule.php renamed to rules-tests/TypeDeclaration/Rector/FuncCall/AddArrayAnyAllClosureParamTypeRector/config/configured_rule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\TypeDeclarationDocblocks\Rector\FuncCall\AddArrayAnyAllClosureParamTypeFromDocblockRector;
6+
use Rector\TypeDeclaration\Rector\FuncCall\AddArrayAnyAllClosureParamTypeRector;
77
use Rector\ValueObject\PhpVersion;
88

99
return static function (RectorConfig $rectorConfig): void {
10-
$rectorConfig->rule(AddArrayAnyAllClosureParamTypeFromDocblockRector::class);
10+
$rectorConfig->rule(AddArrayAnyAllClosureParamTypeRector::class);
1111

1212
$rectorConfig->phpVersion(PhpVersion::PHP_84);
1313
};
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Rector\Tests\TypeDeclaration\Rector\FuncCall\NarrowArrayAnyAllClosureParamTypeRector\Fixture;
4+
5+
function arrayFind(): ?string
6+
{
7+
/** @var string[] $items */
8+
$items = ['a', 'b'];
9+
10+
return array_find($items, fn (?string $item): bool => $item !== '');
11+
}
12+
13+
?>
14+
-----
15+
<?php
16+
17+
namespace Rector\Tests\TypeDeclaration\Rector\FuncCall\NarrowArrayAnyAllClosureParamTypeRector\Fixture;
18+
19+
function arrayFind(): ?string
20+
{
21+
/** @var string[] $items */
22+
$items = ['a', 'b'];
23+
24+
return array_find($items, fn (string $item): bool => $item !== '');
25+
}
26+
27+
?>

‎rules-tests/TypeDeclarationDocblocks/Rector/FuncCall/AddArrayAnyAllClosureParamTypeFromDocblockRector/Fixture/skip_mixed_array.php.inc‎

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PhpParser\Node\Name;
1515
use PhpParser\Node\Stmt\Catch_;
1616
use PhpParser\NodeVisitor;
17+
use PHPStan\Reflection\ExtendedParameterReflection;
1718
use PHPStan\Reflection\ParametersAcceptorSelector;
1819
use PHPStan\Reflection\ReflectionProvider;
1920
use PHPStan\Type\ObjectType;
@@ -235,15 +236,15 @@ private function hasParameter(New_ $new, string $parameterName): bool
235236
);
236237
return array_any(
237238
$extendedParametersAcceptor->getParameters(),
238-
fn ($extendedParameterReflection): bool => $extendedParameterReflection->getName() === $parameterName
239+
fn (ExtendedParameterReflection $extendedParameterReflection): bool => $extendedParameterReflection->getName() === $parameterName
239240
);
240241
}
241242

242243
private function hasArgument(New_ $new, string $argumentName): bool
243244
{
244245
return array_any(
245246
$new->getArgs(),
246-
fn ($arg): bool => $arg->name instanceof Identifier && $arg->name->toString() === $argumentName
247+
fn (Arg $arg): bool => $arg->name instanceof Identifier && $arg->name->toString() === $argumentName
247248
);
248249
}
249250

‎rules/CodeQuality/Rector/FuncCall/ChangeArrayPushToArrayAssignRector.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Rector\CodeQuality\Rector\FuncCall;
66

77
use PhpParser\Node;
8+
use PhpParser\Node\Arg;
89
use PhpParser\Node\Expr\ArrayDimFetch;
910
use PhpParser\Node\Expr\Assign;
1011
use PhpParser\Node\Expr\FuncCall;
@@ -100,6 +101,6 @@ public function refactor(Node $node): ?array
100101

101102
private function hasArraySpread(FuncCall $funcCall): bool
102103
{
103-
return array_any($funcCall->getArgs(), fn ($arg) => $arg->unpack);
104+
return array_any($funcCall->getArgs(), fn (Arg $arg): bool => $arg->unpack);
104105
}
105106
}

0 commit comments

Comments
 (0)