From 2f14d695cbb27333df217553abfdbc23cff20a37 Mon Sep 17 00:00:00 2001 From: "(Andy) James Andrew Vaughn" Date: Tue, 22 Jan 2019 01:49:29 -0800 Subject: [PATCH 1/2] Add unstable badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 61c6231..f08483f 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ A utility for traversing PHP arrays with an XPath-like syntax. [![travis-ci.org](https://travis-ci.org/MindTouch/XArray.php.svg?branch=master)](https://travis-ci.org/MindTouch/XArray.php) [![codecov.io](https://codecov.io/github/MindTouch/XArray.php/coverage.svg?branch=master)](https://codecov.io/github/MindTouch/XArray.php?branch=master) [![Latest Stable Version](https://poser.pugx.org/mindtouch/xarray/version.svg)](https://packagist.org/packages/mindtouch/xarray) +[![Latest Unstable Version](https://poser.pugx.org/mindtouch/xarray/v/unstable)](https://packagist.org/packages/mindtouch/xarray) ## Requirements * PHP 5.4, 5.5, 5.6 (0.1.x) From d130128a8cab3721fb6960406d1838733553eb47 Mon Sep 17 00:00:00 2001 From: "(Andy) James Andrew Vaughn" Date: Tue, 22 Jan 2019 13:11:18 -0800 Subject: [PATCH 2/2] Clarify how getString() works --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f08483f..57e8e88 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,8 @@ $x1->setVal('foo/bar', 'baz'); $x1->setVal('qux', ['fred', 'quxx']); // get some values -$result = $x1->getVal('foo/bar'); // baz -$result = $x1->getVal('qux'); // fred +$result = $x1->getVal('foo/bar'); // 'baz' +$result = $x1->getVal('qux'); // 'fred' $results = $x1->getAll('qux'); // ['fred', 'quxx'] // get the array @@ -57,20 +57,26 @@ $x2->setVal('foo/bar', ['qux', 'baz']); $x2->setVal('bar', 'foo'); // get some values -$result = $x2->getVal('foo/bar'); // qux +$result = $x2->getVal('foo/bar'); // 'qux' $result = $x2->getAll('bar'); // ['foo'] $results = $x2->getAll('qux'); // ['fred', 'quxx'] -// get a value strictly as a string +// we can get a value strictly as a string, if we are in strict typing mode! +// first we set some non-string values... $x2->setVal('qwerty', true); $x2->setVal('asdf', new class { public function __toString() { return 'zxcv'; } }); + +// ...and cast them to string! $result = $x2->getString('qwerty'); // 'true' $result = $x2->getString('asdf'); // 'zxcv' +// of course, string values themselves can be fetched as strict string types +$result = $x2->getString('foo/bar'); // 'qux' + // get the new array $array2 = $x2->toArray();