From 3c8a811ca345ce1f04fbed8fed1591a7cf213946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Till=20Kru=CC=88ss?= Date: Tue, 17 Jan 2023 14:43:40 -0800 Subject: [PATCH] update examples --- examples/dispatcher_loop.php | 2 +- examples/executing_redis_commands.php | 9 ++++++--- examples/pubsub_consumer.php | 2 +- examples/replication_complex.php | 2 +- examples/session_handler.php | 2 +- examples/shared.php | 2 +- 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/dispatcher_loop.php b/examples/dispatcher_loop.php index 16a8c4b7..92f3796c 100644 --- a/examples/dispatcher_loop.php +++ b/examples/dispatcher_loop.php @@ -59,7 +59,7 @@ class EventsListener implements Countable } // Attach our callable class to the dispatcher. -$dispatcher->attachCallback('events', ($events = new EventsListener())); +$dispatcher->attachCallback('events', $events = new EventsListener()); // Attach a function to control the dispatcher loop termination with a message. $dispatcher->attachCallback('control', function ($payload, $dispatcher) { diff --git a/examples/executing_redis_commands.php b/examples/executing_redis_commands.php index 9f09be37..8acd5241 100644 --- a/examples/executing_redis_commands.php +++ b/examples/executing_redis_commands.php @@ -18,7 +18,8 @@ $client = new Predis\Client($single_server); $client->set('library', 'predis'); $response = $client->get('library'); -var_export($response); echo PHP_EOL; +var_export($response); +echo PHP_EOL; /* OUTPUT: 'predis' */ // Redis has the MSET and MGET commands to set or get multiple keys in one go, @@ -33,7 +34,8 @@ $mkv = [ $client->mset($mkv); $response = $client->mget(array_keys($mkv)); -var_export($response); echo PHP_EOL; +var_export($response); +echo PHP_EOL; /* OUTPUT: array ( 0 => '1st user', @@ -49,7 +51,8 @@ $response = $client->executeRaw([ 'MGET', 'uid:0001', 'uid:0002', 'uid:0003', ]); -var_export($response); echo PHP_EOL; +var_export($response); +echo PHP_EOL; /* OUTPUT: array ( 0 => '1st user', diff --git a/examples/pubsub_consumer.php b/examples/pubsub_consumer.php index 1660cbbe..c593067e 100644 --- a/examples/pubsub_consumer.php +++ b/examples/pubsub_consumer.php @@ -44,7 +44,7 @@ foreach ($pubsub as $message) { } } else { echo "Received the following message from {$message->channel}:", - PHP_EOL, " {$message->payload}", PHP_EOL, PHP_EOL; + PHP_EOL, " {$message->payload}", PHP_EOL, PHP_EOL; } break; } diff --git a/examples/replication_complex.php b/examples/replication_complex.php index 24aa6728..25f90edd 100644 --- a/examples/replication_complex.php +++ b/examples/replication_complex.php @@ -30,7 +30,7 @@ use Predis\Replication\ReplicationStrategy; class HashMultipleGetAll extends ScriptCommand { - const BODY = <<= 5.4.0 ' . + exit('ATTENTION: the session handler implemented by Predis requires PHP >= 5.4.0 ' . "or a polyfill for SessionHandlerInterface provided by an external package.\n"); } diff --git a/examples/shared.php b/examples/shared.php index 119d1f76..c805a50c 100644 --- a/examples/shared.php +++ b/examples/shared.php @@ -11,7 +11,7 @@ */ if (PHP_SAPI !== 'cli') { - die('Example scripts are meant to be executed locally via CLI.'); + exit('Example scripts are meant to be executed locally via CLI.'); } require __DIR__ . '/../autoload.php';