Closed
Description
The first argument ($cas_token
) to Memcached::cas
is a float
according to the documentation.
However when using Reflection to list the parameters it determines that the $cas_token
is of type string
.
PHP script:
<?php
declare(strict_types=1);
$class = Memcached::class;
$method_to_inspect = "cas";
$method = new ReflectionMethod($class, $method_to_inspect);
echo "PHP version: " . PHP_VERSION . PHP_EOL;
echo "memcached version: " . phpversion("memcached") . PHP_EOL;
echo "Reflecting $class::$method_to_inspect" . PHP_EOL;
foreach ($method->getParameters() as $parameter) {
echo "- " . $parameter->getDeclaringClass()->getName() . "::" . $parameter->getName() . PHP_EOL;
echo " " . "type: " . $parameter->getType()->getName() . PHP_EOL;
}
results in
PHP version: 8.1.12
memcached version: 3.2.0
Reflecting Memcached::cas
- Memcached::cas_token
type: string
- Memcached::key
type: string
- Memcached::value
type: mixed
- Memcached::expiration
type: int
Dockerfile:
FROM php:8.1-cli-alpine
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions && install-php-extensions memcached
Where does this inconsistency come from and can it be resolved?
A possible explanation is https://github.com/php-memcached-dev/php-memcached/blob/master/php_memcached.stub.php#L34
This stub file type hints the $cas_token
parameter as being a string
.
public function cas(string $cas_token, string $key, mixed $value, int $expiration=0): bool {}
Metadata
Metadata
Assignees
Labels
No labels