FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Incorrect PHP reflection type for Memcached::cas $cas_token · Issue #523 · php-memcached-dev/php-memcached · GitHub

Incorrect PHP reflection type for Memcached::cas $cas_token #523

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL