Jelajahi Sumber

Merge branch 'v0.9/hhvm-compatibility'

Daniele Alessandri 11 tahun lalu
induk
melakukan
913bcb3b20

+ 4 - 0
.travis.yml

@@ -3,6 +3,10 @@ php:
   - 5.3
   - 5.4
   - 5.5
+  - hhvm
+matrix:
+  allow_failures:
+    - php: hhvm
 branches:
   except:
     - v0.5

+ 4 - 0
README.md

@@ -10,6 +10,10 @@ Predis does not require any additional extension loaded in PHP but can be option
 and parsing the Redis protocol. An asynchronous implementation of the client, albeit experimental,
 is also available through [Predis\Async](https://github.com/nrk/predis-async).
 
+The library can also be used with [HHVM](http://www.hhvm.com) >= 2.3.0 although we cannot guarantee
+that you will not run into unexpected issues especially in some obscure corner cases, mostly due to
+the fact that HHVM is still being actively developed and not 100% compatible with PHP.
+
 You can refer to our [FAQ](FAQ.md) for a list of frequently asked questions about Predis, or find
 more details on the [wiki pages](https://github.com/nrk/predis/wiki) of the project.
 

+ 6 - 1
lib/Predis/Configuration/ProfileOption.php

@@ -33,7 +33,12 @@ class ProfileOption implements OptionInterface
     protected function setProcessors(OptionsInterface $options, ProfileInterface $profile)
     {
         if (isset($options->prefix) && $profile instanceof RedisProfile) {
-            $profile->setProcessor($options->prefix);
+            // NOTE: directly using __get('prefix') is actually a workaround for
+            // HHVM 2.3.0. It's correct and respects the options interface, it's
+            // just ugly. We will remove this hack when HHVM will fix re-entrant
+            // calls to __get() once and for all.
+
+            $profile->setProcessor($options->__get('prefix'));
         }
     }
 

+ 1 - 1
lib/Predis/Connection/StreamConnection.php

@@ -92,7 +92,7 @@ class StreamConnection extends AbstractConnection
             stream_set_timeout($resource, $timeoutSeconds, $timeoutUSeconds);
         }
 
-        if (isset($parameters->tcp_nodelay) && version_compare(PHP_VERSION, '5.4.0') >= 0) {
+        if (isset($parameters->tcp_nodelay) && function_exists('socket_import_stream')) {
             $socket = socket_import_stream($resource);
             socket_set_option($socket, SOL_TCP, TCP_NODELAY, (int) $parameters->tcp_nodelay);
         }

+ 4 - 1
tests/Predis/Command/RawCommandTest.php

@@ -69,9 +69,12 @@ class RawCommandTest extends PredisTestCase
     }
 
     /**
+     * The signature of RawCommand::create() requires one argument which is the
+     * ID of the command (other arguments are fetched dinamically). If the first
+     * argument is missing, PHP emits an E_WARNING.
+     *
      * @group disconnected
      * @expectedException PHPUnit_Framework_Error_Warning
-     * @expectedExceptionMessage Missing argument 1 for Predis\Command\RawCommand::create()
      */
     public function testPHPWarningOnMissingCommandIDWithStaticCreate()
     {