From 1fce3430c96c33584bdd60f475de63931b9a02a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Wed, 8 Mar 2017 16:17:28 +0100 Subject: [PATCH] Forward compatibility with Stream v0.5 and upcoming v0.6 --- README.md | 12 ++++++++++-- composer.json | 2 +- src/ConnectionInterface.php | 12 ++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b4c8dc2..efd58a3 100644 --- a/README.md +++ b/README.md @@ -116,10 +116,18 @@ you can use any of its events and methods as usual: ```php $connection->on('data', function ($chunk) { - echo $data; + echo $chunk; }); -$conenction->on('close', function () { +$connection->on('end', function () { + echo 'ended'; +}); + +$connection->on('error', function (Exception $e) { + echo 'error: ' . $e->getMessage(); +}); + +$connection->on('close', function () { echo 'closed'; }); diff --git a/composer.json b/composer.json index b90f717..3671b72 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "php": ">=5.3.0", "react/dns": "0.4.*|0.3.*", "react/event-loop": "0.4.*|0.3.*", - "react/stream": "^0.4.5", + "react/stream": "^0.6 || ^0.5 || ^0.4.5", "react/promise": "^2.1 || ^1.2", "react/promise-timer": "~1.0" }, diff --git a/src/ConnectionInterface.php b/src/ConnectionInterface.php index 0687e75..ad33b2b 100644 --- a/src/ConnectionInterface.php +++ b/src/ConnectionInterface.php @@ -29,10 +29,18 @@ * * ```php * $connection->on('data', function ($chunk) { - * echo $data; + * echo $chunk; * }); * - * $conenction->on('close', function () { + * $connection->on('end', function () { + * echo 'ended'; + * }); + * + * $connection->on('error', function (Exception $e) { + * echo 'error: ' . $e->getMessage(); + * }); + * + * $connection->on('close', function () { * echo 'closed'; * }); *