From a55604b32903e2b46d869b25128df976b7ab82f8 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Wed, 10 Apr 2019 14:47:01 +0200 Subject: correctly handle "data" => [] --- it_pipe.class | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/it_pipe.class b/it_pipe.class index 611c2ad..54f4a5b 100644 --- a/it_pipe.class +++ b/it_pipe.class @@ -15,9 +15,9 @@ class it_pipe implements Iterator */ function __construct($p = array()) { - if ($p['data']) - $this->lines = is_array($p['data']) ? $p['data'] : explode("\n", rtrim($p['data'], "\n")); - else if ($p['cmd']) + if (array_key_exists('data', $p)) + $this->lines = is_array($p['data']) || $p['data'] === null ? (array)$p['data'] : explode("\n", rtrim($p['data'], "\n")); + else if (array_key_exists('cmd', $p)) $this->lines = strlen($data = it::exec($p['cmd'], $p['args'])) ? explode("\n", rtrim($data, "\n")) : array(); else foreach ((array)($p['fn'] ? $p['fn'] : "php://stdin") as $fn) -- cgit v1.2.3