From e4ee3b3131074e6f27cea6dc158f8ab036992a29 Mon Sep 17 00:00:00 2001 From: Masatoshi Ogiwara Date: Tue, 5 Aug 2025 17:08:47 +0900 Subject: [PATCH 1/2] feat: add-rector-rule --- rector.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rector.php b/rector.php index 23afcb2ea..3776c15d7 100644 --- a/rector.php +++ b/rector.php @@ -6,6 +6,7 @@ use Rector\Php80\Rector\FunctionLike\MixedTypeRector; use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector; use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector; +use Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector; return RectorConfig::configure() ->withPaths([ @@ -16,6 +17,9 @@ ]) ->withPhpSets() ->withTypeCoverageLevel(0) + ->withRules([ + ExplicitNullableParamTypeRector::class, + ]) ->withSkip([ RemoveExtraParametersRector::class, ClosureToArrowFunctionRector::class, From 05418172338b88f933cedac76be92e9b41059d52 Mon Sep 17 00:00:00 2001 From: Masatoshi Ogiwara Date: Tue, 5 Aug 2025 17:10:50 +0900 Subject: [PATCH 2/2] chore: apply-rector-changes-for-code-style-and-type-safety --- docs/includes/fundamentals/as-avs/AtlasSearchTest.php | 4 ++-- src/CommandSubscriber.php | 2 +- src/Scout/ScoutEngine.php | 4 ++-- tests/AtlasSearchTest.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/includes/fundamentals/as-avs/AtlasSearchTest.php b/docs/includes/fundamentals/as-avs/AtlasSearchTest.php index 79dfe46df..bec0d6638 100644 --- a/docs/includes/fundamentals/as-avs/AtlasSearchTest.php +++ b/docs/includes/fundamentals/as-avs/AtlasSearchTest.php @@ -149,9 +149,9 @@ public function testVectorSearch(): void /** Generates random vectors using fixed seed to make tests deterministic */ private function addVector(array $items): array { - srand(1); + mt_srand(1); foreach ($items as &$item) { - $this->vectors[] = $item['vector4'] = array_map(fn () => rand() / mt_getrandmax(), range(0, 3)); + $this->vectors[] = $item['vector4'] = array_map(fn () => random_int(0, mt_getrandmax()) / mt_getrandmax(), range(0, 3)); } return $items; diff --git a/src/CommandSubscriber.php b/src/CommandSubscriber.php index 1cad23280..1a3f41b0b 100644 --- a/src/CommandSubscriber.php +++ b/src/CommandSubscriber.php @@ -18,7 +18,7 @@ final class CommandSubscriber implements CommandSubscriberInterface /** @var array */ private array $commands = []; - public function __construct(private Connection $connection) + public function __construct(private readonly Connection $connection) { } diff --git a/src/Scout/ScoutEngine.php b/src/Scout/ScoutEngine.php index 9455608bb..e026aa03d 100644 --- a/src/Scout/ScoutEngine.php +++ b/src/Scout/ScoutEngine.php @@ -69,8 +69,8 @@ final class ScoutEngine extends Engine /** @param array $indexDefinitions */ public function __construct( - private Database $database, - private bool $softDelete, + private readonly Database $database, + private readonly bool $softDelete, private array $indexDefinitions = [], ) { } diff --git a/tests/AtlasSearchTest.php b/tests/AtlasSearchTest.php index 43848c09a..4f953644b 100644 --- a/tests/AtlasSearchTest.php +++ b/tests/AtlasSearchTest.php @@ -256,9 +256,9 @@ public function testEloquentBuilderVectorSearch() /** Generate random vectors using fixed seed to make tests deterministic */ private function addVector(array $items): array { - srand(1); + mt_srand(1); foreach ($items as &$item) { - $this->vectors[] = $item['vector4'] = array_map(fn () => rand() / mt_getrandmax(), range(0, 3)); + $this->vectors[] = $item['vector4'] = array_map(fn () => random_int(0, mt_getrandmax()) / mt_getrandmax(), range(0, 3)); } return $items;