diff options
author | Urban Müller | 2019-04-10 14:47:01 +0200 |
---|---|---|
committer | Urban Müller | 2019-04-10 14:47:01 +0200 |
commit | a55604b32903e2b46d869b25128df976b7ab82f8 (patch) | |
tree | 5a7eaf787eaa9272cfcc3b0e22684aaad4050299 | |
parent | da49744afaa628059b84336f11fc694ceccb3a6c (diff) | |
download | itools-a55604b32903e2b46d869b25128df976b7ab82f8.tar.gz itools-a55604b32903e2b46d869b25128df976b7ab82f8.tar.bz2 itools-a55604b32903e2b46d869b25128df976b7ab82f8.zip |
correctly handle "data" => []
-rw-r--r-- | it_pipe.class | 6 |
1 files 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) |