From 5862c9c0a86a521be1617d4c7593be570b2eea39 Mon Sep 17 00:00:00 2001 From: Danielle McLean Date: Mon, 9 Apr 2018 08:37:16 +1000 Subject: [PATCH] Add an unphp script for deserialising PHP objects and converting them to nice friendly JSON --- local/bin/unphp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 local/bin/unphp diff --git a/local/bin/unphp b/local/bin/unphp new file mode 100755 index 0000000..21963eb --- /dev/null +++ b/local/bin/unphp @@ -0,0 +1,22 @@ +#!/usr/bin/env php + $cls->name]; + foreach ($cls->getProperties() as $prop) { + $prop->setAccessible(true); + $fields[$prop->getName()] = to_array($prop->getValue($obj)); + } + return $fields; +} + +$args = array_slice($argv, 1); +if (empty($args)) $args[] = '-'; +foreach ($args as $arg) { + if ($arg === '-') $arg = 'php://stdin'; + echo json_encode(to_array(unserialize(file_get_contents($arg)))) . PHP_EOL; +}