php-memcachedのmock作れない問題

どうした

php-memcachedMemcachedクラスを作ろうとするとエラーが出るので調べた。
get()とgetMulti()がダメっぽい。これらを避けてstubは作れる。
昔からissue立ってて、3.x系から出来るっぽい。

github.com

その他

テストコードとか。

php -v

PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

apt-cache policy php-memcached

php-memcached:
  Installed: 2.2.0-51-ge573a6e+2.2.0-2build2
  Candidate: 2.2.0-51-ge573a6e+2.2.0-2build2
  Version table:
 *** 2.2.0-51-ge573a6e+2.2.0-2build2 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
        100 /var/lib/dpkg/status

Test.php

<?php
require_once "vendor/autoload.php";

class TestTest extends PHPUnit\Framework\TestCase {
  public function testMo() {
    $m = $this->getMockBuilder(Memcached::class)
      ->setMethods(['get'])
      ->getMock();
  }
}

./vendor/bin/phpunit Test.php

PHPUnit 6.5.5 by Sebastian Bergmann and contributors.

E                                                                   1 / 1 (100%)

Time: 33 ms, Memory: 4.00MB

There was 1 error:

1) TestTest::testMo
Declaration of Mock_Memcached_60ba7bf9::get($key, $cache_cb = NULL, &$cas_token = NULL, &$udf_flags = NULL) should be compatible with Memcached::get($key, $cache_cb = NULL, &$cas_token = NULL, &$udf_flags = NULL)

/home/no6/php/mock/Test.php:8

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

2018年にやる話か…?