Skip to content

Chore: apply ExplicitNullableParamTypeRector rule #3438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/includes/fundamentals/as-avs/AtlasSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -16,6 +17,9 @@
])
->withPhpSets()
->withTypeCoverageLevel(0)
->withRules([
ExplicitNullableParamTypeRector::class,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule did not fix anything in the codebase. The explicit nullable params are already fixed by phpcs.

])
->withSkip([
RemoveExtraParametersRector::class,
ClosureToArrowFunctionRector::class,
Expand Down
2 changes: 1 addition & 1 deletion src/CommandSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final class CommandSubscriber implements CommandSubscriberInterface
/** @var array<string, CommandStartedEvent> */
private array $commands = [];

public function __construct(private Connection $connection)
public function __construct(private readonly Connection $connection)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/Scout/ScoutEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ final class ScoutEngine extends Engine

/** @param array<string, array> $indexDefinitions */
public function __construct(
private Database $database,
private bool $softDelete,
private readonly Database $database,
private readonly bool $softDelete,
Comment on lines +72 to +73
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to protect private properties with readonly, their usage is internal to this class.

private array $indexDefinitions = [],
) {
}
Expand Down
4 changes: 2 additions & 2 deletions tests/AtlasSearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down