Thanks to visit codestin.com
Credit goes to github.com

Skip to content

The context parameter should be nullable but isn't #2521

@kalifg

Description

@kalifg

Expected behaviour

$r = new Redis();
$r->connect('redis', context: null);
# connected, return value true

Actual behaviour

$r = new Redis();
$r->connect('redis', context: null);
#  TypeError  Redis::connect(): Argument #7 ($context) must be of type array, null given.

I'm seeing this behaviour on

  • OS: Linux
  • Redis: 6.0.8
  • PHP: 8.3.9
  • phpredis: 6.0.2

Steps to reproduce, backtrace or example script

In this example I have a redis docker image running, accessible via the hostname redis

$r = new Redis();
$r->connect('redis', context: null);

The stubs say that context should be nullable:

phpredis/redis.stub.php

Lines 853 to 854 in 7de29d5

public function connect(string $host, int $port = 6379, float $timeout = 0, ?string $persistent_id = null,
int $retry_interval = 0, float $read_timeout = 0, ?array $context = null): bool;

I've checked

  • There is no similar issue from other users
  • Issue isn't fixed in develop branch

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions