Addshore has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/333282 )

Change subject: PHAN: Add Memcached stub
......................................................................

PHAN: Add Memcached stub

Change-Id: I6b9056cd1c652ef8e81e5dbdd24e68b7d278ac14
---
M includes/libs/objectcache/MemcachedBagOStuff.php
M includes/libs/objectcache/MemcachedPeclBagOStuff.php
M includes/libs/objectcache/MemcachedPhpBagOStuff.php
M tests/phan/config.php
A tests/phan/stubs/memcached.php
M tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php
6 files changed, 155 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/82/333282/1

diff --git a/includes/libs/objectcache/MemcachedBagOStuff.php 
b/includes/libs/objectcache/MemcachedBagOStuff.php
index 5128d82..3fe5a18 100644
--- a/includes/libs/objectcache/MemcachedBagOStuff.php
+++ b/includes/libs/objectcache/MemcachedBagOStuff.php
@@ -26,7 +26,7 @@
  *
  * @ingroup Cache
  */
-class MemcachedBagOStuff extends BagOStuff {
+abstract class MemcachedBagOStuff extends BagOStuff {
        /** @var MemcachedClient|Memcached */
        protected $client;
 
diff --git a/includes/libs/objectcache/MemcachedPeclBagOStuff.php 
b/includes/libs/objectcache/MemcachedPeclBagOStuff.php
index 5983c1b..b949ad6 100644
--- a/includes/libs/objectcache/MemcachedPeclBagOStuff.php
+++ b/includes/libs/objectcache/MemcachedPeclBagOStuff.php
@@ -28,6 +28,9 @@
  */
 class MemcachedPeclBagOStuff extends MemcachedBagOStuff {
 
+       /** @var Memcached */
+       protected $client;
+
        /**
         * Constructor
         *
diff --git a/includes/libs/objectcache/MemcachedPhpBagOStuff.php 
b/includes/libs/objectcache/MemcachedPhpBagOStuff.php
index e2d9d93..654ba89 100644
--- a/includes/libs/objectcache/MemcachedPhpBagOStuff.php
+++ b/includes/libs/objectcache/MemcachedPhpBagOStuff.php
@@ -27,6 +27,10 @@
  * @ingroup Cache
  */
 class MemcachedPhpBagOStuff extends MemcachedBagOStuff {
+
+       /** @var MemcachedClient */
+       protected $client;
+
        /**
         * Available parameters are:
         *   - servers:             The list of IP:port combinations holding 
the memcached servers.
diff --git a/tests/phan/config.php b/tests/phan/config.php
index fe9bbd9..9aeaad1 100644
--- a/tests/phan/config.php
+++ b/tests/phan/config.php
@@ -40,6 +40,7 @@
                class_exists( PEAR::class ) ? [] : [ 
'tests/phan/stubs/mail.php' ],
                class_exists( Imagick::class ) ? [] : [ 
'tests/phan/stubs/imagick.php' ],
                class_exists( Redis::class ) ? [] : [ 
'tests/phan/stubs/redis.php' ],
+               class_exists( Memcached::class ) ? [] : [ 
'tests/phan/stubs/memcached.php' ],
                [
                        'maintenance/7zip.inc',
                        'maintenance/backupPrefetch.inc',
diff --git a/tests/phan/stubs/memcached.php b/tests/phan/stubs/memcached.php
new file mode 100644
index 0000000..bd9fceb
--- /dev/null
+++ b/tests/phan/stubs/memcached.php
@@ -0,0 +1,140 @@
+<?php
+
+/**
+ * Minimal set of classes necessary for Memcached classes to be happy.
+ * @codingStandardsIgnoreFile
+ */
+
+class Memcached{
+
+       const HAVE_IGBINARY = 0;
+
+       const SERIALIZER_PHP = 1;
+       const SERIALIZER_IGBINARY = 2;
+
+       const OPT_BINARY_PROTOCOL = 18;
+       const OPT_RETRY_TIMEOUT = 15;
+       const OPT_SERVER_FAILURE_LIMIT = 21;
+       const OPT_CONNECT_TIMEOUT = 14;
+       const OPT_SEND_TIMEOUT = 19;
+       const OPT_RECV_TIMEOUT = 20;
+       const OPT_POLL_TIMEOUT = 8;
+       const OPT_LIBKETAMA_COMPATIBLE = 16;
+       const OPT_SERIALIZER = -1003;
+
+       const RES_NOTFOUND = 16;
+       const RES_NOTSTORED = 14;
+
+       /**
+        * @param string $key <p>
+        * The key of the item to retrieve.
+        * </p>
+        * @param callable $cache_cb [optional] <p>
+        * Read-through caching callback or <b>NULL</b>.
+        * </p>
+        * @param float $cas_token [optional] <p>
+        * The variable to store the CAS token in.
+        * </p>
+        * @return mixed the value stored in the cache or <b>FALSE</b> 
otherwise.
+        * The <b>Memcached::getResultCode</b> will return
+        * <b>Memcached::RES_NOTFOUND</b> if the key does not exist.
+        */
+       public function get ($key, callable $cache_cb = null, &$cas_token = 
null) {}
+
+       /**
+        * @param string $key <p>
+        * The key under which to store the value.
+        * </p>
+        * @param mixed $value <p>
+        * The value to store.
+        * </p>
+        * @param int $expiration [optional] <p>
+        * The expiration time, defaults to 0. See Expiration Times for more 
info.
+        * </p>
+        * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure.
+        * Use <b>Memcached::getResultCode</b> if necessary.
+        */
+       public function set ($key, $value, $expiration = null) {}
+
+       /**
+        * @param float $cas_token <p>
+        * Unique value associated with the existing item. Generated by 
memcache.
+        * </p>
+        * @param string $key <p>
+        * The key under which to store the value.
+        * </p>
+        * @param mixed $value <p>
+        * The value to store.
+        * </p>
+        * @param int $expiration [optional] <p>
+        * The expiration time, defaults to 0. See Expiration Times for more 
info.
+        * </p>
+        * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure.
+        * The <b>Memcached::getResultCode</b> will return
+        * <b>Memcached::RES_DATA_EXISTS</b> if the item you are trying
+        * to store has been modified since you last fetched it.
+        */
+       public function cas ($cas_token, $key, $value, $expiration = null) {}
+
+       /**
+        * @param string $key <p>
+        * The key to be deleted.
+        * </p>
+        * @param int $time [optional] <p>
+        * The amount of time the server will wait to delete the item.
+        * </p>
+        * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure.
+        * The <b>Memcached::getResultCode</b> will return
+        * <b>Memcached::RES_NOTFOUND</b> if the key does not exist.
+        */
+       public function delete ($key, $time = 0) {}
+
+       /**
+        * @param string $key <p>
+        * The key under which to store the value.
+        * </p>
+        * @param mixed $value <p>
+        * The value to store.
+        * </p>
+        * @param int $expiration [optional] <p>
+        * The expiration time, defaults to 0. See Expiration Times for more 
info.
+        * </p>
+        * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure.
+        * The <b>Memcached::getResultCode</b> will return
+        * <b>Memcached::RES_NOTSTORED</b> if the key already exists.
+        */
+       public function add ($key, $value, $expiration = null) {}
+
+       /**
+        * @param string $key <p>
+        * The key under which to store the value.
+        * </p>
+        * @param int $expiration <p>
+        * The expiration time, defaults to 0. See Expiration Times for more 
info.
+        * </p>
+        * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure.
+        * Use <b>Memcached::getResultCode</b> if necessary.
+        */
+       public function touch ($key, $expiration) {}
+
+       /**
+        * @return array The list of all servers in the server pool.
+        */
+       public function getServerList () {}
+
+       /**
+        * @return string Message describing the result of the last Memcached 
operation.
+        */
+       public function getResultMessage () {}
+
+       /**
+        * @param string $server_key <p>
+        * The key identifying the server to store the value on or retrieve it 
from. Instead of hashing on the actual key for the item, we hash on the server 
key when deciding which memcached server to talk to. This allows related items 
to be grouped together on a single server for efficiency with multi operations.
+        * </p>
+        * @return array an array containing three keys of host,
+        * port, and weight on success or <b>FALSE</b>
+        * on failure.
+        */
+       public function getServerByKey ($server_key) {}
+
+}
\ No newline at end of file
diff --git a/tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php 
b/tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php
index 7814b83..9244b74 100644
--- a/tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php
+++ b/tests/phpunit/includes/objectcache/MemcachedBagOStuffTest.php
@@ -1,14 +1,18 @@
 <?php
+
+class InstantiableMemcachedBagOStuff extends MemcachedBagOStuff {}
+
 /**
  * @group BagOStuff
  */
 class MemcachedBagOStuffTest extends MediaWikiTestCase {
-       /** @var MemcachedBagOStuff */
+       /** @var InstantiableMemcachedBagOStuff */
        private $cache;
 
        protected function setUp() {
+
                parent::setUp();
-               $this->cache = new MemcachedBagOStuff( [ 'keyspace' => 'test' ] 
);
+               $this->cache = new InstantiableMemcachedBagOStuff( [ 'keyspace' 
=> 'test' ] );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/333282
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6b9056cd1c652ef8e81e5dbdd24e68b7d278ac14
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to