From b31aeedccb8d72378e3febdf185808cc9345367e Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 20:10:59 +0100 Subject: [PATCH 01/22] Created test for BaseInputFilterTest to require that BaseInputFilter implements UnfilteredDataInterface. --- test/BaseInputFilterTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/BaseInputFilterTest.php b/test/BaseInputFilterTest.php index 829c82d6..f5e87d66 100644 --- a/test/BaseInputFilterTest.php +++ b/test/BaseInputFilterTest.php @@ -12,8 +12,8 @@ use ArrayIterator; use ArrayObject; use FilterIterator; -use PHPUnit_Framework_MockObject_MockObject as MockObject; use PHPUnit\Framework\TestCase; +use PHPUnit_Framework_MockObject_MockObject as MockObject; use stdClass; use Zend\InputFilter\BaseInputFilter; use Zend\InputFilter\Exception\InvalidArgumentException; @@ -21,6 +21,7 @@ use Zend\InputFilter\Input; use Zend\InputFilter\InputFilterInterface; use Zend\InputFilter\InputInterface; +use Zend\InputFilter\UnfilteredDataInterface; /** * @covers Zend\InputFilter\BaseInputFilter @@ -603,6 +604,17 @@ public function testNestedInputFilterShouldAllowNonArrayValueForData() self::assertNull($filter1->getValues()['nested']['nestedField1']); } + public function testInstanceOfUnfilteredDataInterface() + { + $baseInputFilter = new BaseInputFilter(); + + self::assertInstanceOf( + UnfilteredDataInterface::class, + $baseInputFilter, + sprintf('%s should implement %s', BaseInputFilter::class, UnfilteredDataInterface::class) + ); + } + public function addMethodArgumentsProvider() { $inputTypes = $this->inputProvider(); From 9704ea935e31dc3817050ca8bb646a4057dd0ae9 Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 20:11:34 +0100 Subject: [PATCH 02/22] Created UnfilteredDataInterface with getter and setter requirements and TODO for when PHP 7.2 is minimum requirement. --- src/UnfilteredDataInterface.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/UnfilteredDataInterface.php diff --git a/src/UnfilteredDataInterface.php b/src/UnfilteredDataInterface.php new file mode 100644 index 00000000..c8ddc50d --- /dev/null +++ b/src/UnfilteredDataInterface.php @@ -0,0 +1,32 @@ + PHP 7.2 as minimum requirement + // public function getUnfilteredData() : array; + // public function setUnfilteredData(array $data) : array; +} \ No newline at end of file From 10eac9610951d22b42a7e1ef1f5d4da8d36ffd6a Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 20:12:15 +0100 Subject: [PATCH 03/22] Implemented UnfilteredDataInterface on BaseInputFilter and created empty functions. --- src/BaseInputFilter.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/BaseInputFilter.php b/src/BaseInputFilter.php index 5b9b5223..6c656e65 100644 --- a/src/BaseInputFilter.php +++ b/src/BaseInputFilter.php @@ -18,7 +18,8 @@ class BaseInputFilter implements InputFilterInterface, UnknownInputsCapableInterface, InitializableInterface, - ReplaceableInputInterface + ReplaceableInputInterface, + UnfilteredDataInterface { /** * @var null|array @@ -602,4 +603,18 @@ public function merge(BaseInputFilter $inputFilter) return $this; } + + // TODO replace functions when upgrading to > PHP 7.2 as minimum requirement + // public function getUnfilteredData() : array; + public function getUnfilteredData() + { + // TODO: Implement getUnfilteredData() method. + } + + // TODO replace functions when upgrading to > PHP 7.2 as minimum requirement + // public function setUnfilteredData(array $data) : array; + public function setUnfilteredData($data) + { + // TODO: Implement setUnfilteredData() method. + } } From 31ee91907307865cee62417ed56018ef836e7cd6 Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 20:13:29 +0100 Subject: [PATCH 04/22] Added .idea folder to .gitignore - commonly created by PhpStorm workspace --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9e685001..6ee4c64e 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ clover.xml coveralls-upload.json phpunit.xml zf-mkdoc-theme.tgz +.idea/ \ No newline at end of file From 0f56c4575970cb1aa99796a713e7a316e790ce46 Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 20:26:49 +0100 Subject: [PATCH 05/22] Testing for return type of array on getter and BaseInputFilter on setter for applying UnfilteredDataInterface on BaseInputFilter. --- test/BaseInputFilterTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/BaseInputFilterTest.php b/test/BaseInputFilterTest.php index f5e87d66..961bbf8a 100644 --- a/test/BaseInputFilterTest.php +++ b/test/BaseInputFilterTest.php @@ -615,6 +615,20 @@ public function testInstanceOfUnfilteredDataInterface() ); } + public function testGetUnfilteredDataReturnsArray() + { + $baseInputFilter = new BaseInputFilter(); + + self::assertInternalType('array', $baseInputFilter->getUnfilteredData()); + } + + public function testSetUnfilteredDataReturnsBaseInputFilter() + { + $baseInputFilter = new BaseInputFilter(); + + self::assertInstanceOf(BaseInputFilter::class, $baseInputFilter->setUnfilteredData([])); + } + public function addMethodArgumentsProvider() { $inputTypes = $this->inputProvider(); From 02ac1f7088a3901d2ababb3e4a267c701ed0b474 Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 20:27:26 +0100 Subject: [PATCH 06/22] Returning empty array in getter and returning self for UnfilteredDataInterface in BaseInputFilter. --- src/BaseInputFilter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BaseInputFilter.php b/src/BaseInputFilter.php index 6c656e65..f23d7f0b 100644 --- a/src/BaseInputFilter.php +++ b/src/BaseInputFilter.php @@ -608,13 +608,13 @@ public function merge(BaseInputFilter $inputFilter) // public function getUnfilteredData() : array; public function getUnfilteredData() { - // TODO: Implement getUnfilteredData() method. + return []; } // TODO replace functions when upgrading to > PHP 7.2 as minimum requirement // public function setUnfilteredData(array $data) : array; public function setUnfilteredData($data) { - // TODO: Implement setUnfilteredData() method. + return $this; } } From d471d649d223676adc708f30fe0f61088d7456e5 Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 20:33:58 +0100 Subject: [PATCH 07/22] Created test with test data to compare result of getting and setting unfiltered data in BaseInputFilter --- test/BaseInputFilterTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/BaseInputFilterTest.php b/test/BaseInputFilterTest.php index 961bbf8a..79a2a3ab 100644 --- a/test/BaseInputFilterTest.php +++ b/test/BaseInputFilterTest.php @@ -629,6 +629,18 @@ public function testSetUnfilteredDataReturnsBaseInputFilter() self::assertInstanceOf(BaseInputFilter::class, $baseInputFilter->setUnfilteredData([])); } + public function testSettingAndReturningDataArrayUnfilteredDataInterface() + { + $testArray = [ + 'foo' => 'bar', + ]; + + $baseInputFilter = new BaseInputFilter(); + $baseInputFilter->setUnfilteredData($testArray); + + self::assertSame($testArray, $baseInputFilter->getUnfilteredData()); + } + public function addMethodArgumentsProvider() { $inputTypes = $this->inputProvider(); From 6c5bb4d126d99ac7a1ed55b1e7346eec1e40426a Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 20:40:51 +0100 Subject: [PATCH 08/22] Setting and getting of unfiltered data possible with getter and setter. Added property on BaseInputFilter - unfilteredData. Tests pass again. Changed setter return type for PHP 7.2 todo's from array to UnfilteredDataInterface. --- src/BaseInputFilter.php | 20 ++++++++++++++++++-- src/UnfilteredDataInterface.php | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/BaseInputFilter.php b/src/BaseInputFilter.php index f23d7f0b..372e1ede 100644 --- a/src/BaseInputFilter.php +++ b/src/BaseInputFilter.php @@ -11,6 +11,7 @@ use ArrayAccess; use Traversable; +use TypeError; use Zend\Stdlib\ArrayUtils; use Zend\Stdlib\InitializableInterface; @@ -26,6 +27,11 @@ class BaseInputFilter implements */ protected $data; + /** + * @var array + */ + protected $unfilteredData = []; + /** * @var InputInterface[]|InputFilterInterface[] */ @@ -604,17 +610,27 @@ public function merge(BaseInputFilter $inputFilter) return $this; } + /** + * @return array + */ // TODO replace functions when upgrading to > PHP 7.2 as minimum requirement // public function getUnfilteredData() : array; public function getUnfilteredData() { - return []; + return $this->unfilteredData; } + /** + * @param array $data + * + * @return $this + */ // TODO replace functions when upgrading to > PHP 7.2 as minimum requirement - // public function setUnfilteredData(array $data) : array; + // public function setUnfilteredData(array $data) : UnfilteredDataInterface; public function setUnfilteredData($data) { + $this->unfilteredData = $data; + return $this; } } diff --git a/src/UnfilteredDataInterface.php b/src/UnfilteredDataInterface.php index c8ddc50d..5e195a03 100644 --- a/src/UnfilteredDataInterface.php +++ b/src/UnfilteredDataInterface.php @@ -28,5 +28,5 @@ public function setUnfilteredData($data); // TODO replace functions when upgrading to > PHP 7.2 as minimum requirement // public function getUnfilteredData() : array; - // public function setUnfilteredData(array $data) : array; + // public function setUnfilteredData(array $data) : UnfilteredDataInterface; } \ No newline at end of file From b46d3fffa54b179e868e13c5e4bd586d1f1092d3 Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 20:51:34 +0100 Subject: [PATCH 09/22] Created test to test setting data with setData in BaseInputFilter and returning same via getUnfiteredData --- test/BaseInputFilterTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/BaseInputFilterTest.php b/test/BaseInputFilterTest.php index 79a2a3ab..de70cc7a 100644 --- a/test/BaseInputFilterTest.php +++ b/test/BaseInputFilterTest.php @@ -641,6 +641,18 @@ public function testSettingAndReturningDataArrayUnfilteredDataInterface() self::assertSame($testArray, $baseInputFilter->getUnfilteredData()); } + public function testSettingAndReturnDataArrayUsingSetDataForUnfilteredDataInterface() + { + $testArray = [ + 'foo' => 'bar', + ]; + + $baseInputFilter = new BaseInputFilter(); + $baseInputFilter->setData($testArray); + + self::assertSame($testArray, $baseInputFilter->getUnfilteredData()); + } + public function addMethodArgumentsProvider() { $inputTypes = $this->inputProvider(); From a2f3161fa774436bcd208662a0969e100421c053 Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 20:51:50 +0100 Subject: [PATCH 10/22] Updated year in copyright notic --- src/UnfilteredDataInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UnfilteredDataInterface.php b/src/UnfilteredDataInterface.php index 5e195a03..446a8003 100644 --- a/src/UnfilteredDataInterface.php +++ b/src/UnfilteredDataInterface.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2019 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ From 311b496872e148aba1565e1db86a0fbe93c4634c Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 20:52:11 +0100 Subject: [PATCH 11/22] Added setting of unfilteredData in setData of BaseInputFilter - test passes --- src/BaseInputFilter.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/BaseInputFilter.php b/src/BaseInputFilter.php index 372e1ede..ae9d0c75 100644 --- a/src/BaseInputFilter.php +++ b/src/BaseInputFilter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2019 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -11,7 +11,6 @@ use ArrayAccess; use Traversable; -use TypeError; use Zend\Stdlib\ArrayUtils; use Zend\Stdlib\InitializableInterface; @@ -201,8 +200,12 @@ public function setData($data) (is_object($data) ? get_class($data) : gettype($data)) )); } + + $this->setUnfilteredData($data); + $this->data = $data; $this->populate(); + return $this; } From f5bc16c3519af6bfe4a2922a06f021b457f9a097 Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 21:04:55 +0100 Subject: [PATCH 12/22] Created test to split array by filtering (getValues) and unfiltered (getUnfilteredData) - works out-of-the-box --- test/BaseInputFilterTest.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/BaseInputFilterTest.php b/test/BaseInputFilterTest.php index de70cc7a..63f74002 100644 --- a/test/BaseInputFilterTest.php +++ b/test/BaseInputFilterTest.php @@ -653,6 +653,28 @@ public function testSettingAndReturnDataArrayUsingSetDataForUnfilteredDataInterf self::assertSame($testArray, $baseInputFilter->getUnfilteredData()); } + public function testSetDataUsingSetDataAndApplyFiltersReturningSameAsOriginalForUnfilteredData() + { + $filteredArray = [ + 'bar' => 'foo', + ]; + + $unfilteredArray = array_merge( + $filteredArray, + [ + 'foo' => 'bar', + ] + ); + + /** @var BaseInputFilter $baseInputFilter */ + $baseInputFilter = (new BaseInputFilter()) + ->add(new Input(), 'bar') + ->setData($unfilteredArray); + + self::assertSame($unfilteredArray, $baseInputFilter->getUnfilteredData()); + self::assertSame($filteredArray, $baseInputFilter->getValues()); + } + public function addMethodArgumentsProvider() { $inputTypes = $this->inputProvider(); From e41a0c0cbbde85c43970fdc5a031e5d8a21a45b1 Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 21:43:15 +0100 Subject: [PATCH 13/22] Added additional assertion to test of BaseInputFilter to assure same result for getValues and getRawValues as opposed to getUnfilteredData. --- test/BaseInputFilterTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/test/BaseInputFilterTest.php b/test/BaseInputFilterTest.php index 63f74002..9ab18615 100644 --- a/test/BaseInputFilterTest.php +++ b/test/BaseInputFilterTest.php @@ -673,6 +673,7 @@ public function testSetDataUsingSetDataAndApplyFiltersReturningSameAsOriginalFor self::assertSame($unfilteredArray, $baseInputFilter->getUnfilteredData()); self::assertSame($filteredArray, $baseInputFilter->getValues()); + self::assertSame($filteredArray, $baseInputFilter->getRawValues()); } public function addMethodArgumentsProvider() From eb38848a44d9ac03febe382b22c08a65fb8afc14 Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 21:44:42 +0100 Subject: [PATCH 14/22] Created test for CollectionInputFilter to check the UnfilteredData is the same after running isValid method. --- test/CollectionInputFilterTest.php | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/CollectionInputFilterTest.php b/test/CollectionInputFilterTest.php index e09a6e12..5b7ad186 100644 --- a/test/CollectionInputFilterTest.php +++ b/test/CollectionInputFilterTest.php @@ -765,4 +765,35 @@ public function testUsesMessageFromComposedNotEmptyValidatorWhenRequiredButColle [NotEmpty::IS_EMPTY => $message], ], $this->inputFilter->getMessages()); } + + public function testSetDataUsingSetDataAndRunningIsValidReturningSameAsOriginalForUnfilteredData() + { + $filteredArray = [ + [ + 'bar' => 'foo', + 'foo' => 'bar', + ], + ]; + + $unfilteredArray = array_merge( + $filteredArray, + [ + [ + 'foo' => 'bar', + ], + ] + ); + + /** @var BaseInputFilter $baseInputFilter */ + $baseInputFilter = (new BaseInputFilter()) + ->add(new Input(), 'bar'); + + /** @var CollectionInputFilter $collectionInputFilter */ + $collectionInputFilter = (new CollectionInputFilter())->setInputFilter($baseInputFilter); + $collectionInputFilter->setData($unfilteredArray); + + $collectionInputFilter->isValid(); + + self::assertSame($unfilteredArray, $collectionInputFilter->getUnfilteredData()); + } } From 7a0ea8f67f6360d3cd424cdb4e0e7f1468899926 Mon Sep 17 00:00:00 2001 From: Robin Keet Date: Thu, 10 Jan 2019 21:45:41 +0100 Subject: [PATCH 15/22] Seting UnfilteredData on CollectionInputFilter. --- src/CollectionInputFilter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/CollectionInputFilter.php b/src/CollectionInputFilter.php index 005525fc..5c3e9188 100644 --- a/src/CollectionInputFilter.php +++ b/src/CollectionInputFilter.php @@ -153,6 +153,8 @@ public function setData($data) )); } + $this->setUnfilteredData($data); + foreach ($data as $item) { if (is_array($item) || $item instanceof Traversable) { continue; From a9396774c4584f46f50a1837c4c3a45a34be9906 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 30 Jan 2019 09:29:31 -0600 Subject: [PATCH 16/22] qa: remove .idea from .gitignore Should be in global gitignore, not project --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6ee4c64e..9e685001 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,3 @@ clover.xml coveralls-upload.json phpunit.xml zf-mkdoc-theme.tgz -.idea/ \ No newline at end of file From 96afb3598c743f345dbcc169443065206aebcc72 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 30 Jan 2019 09:30:51 -0600 Subject: [PATCH 17/22] qa: remove unnecessary annotations --- src/BaseInputFilter.php | 4 ---- src/UnfilteredDataInterface.php | 6 +----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/BaseInputFilter.php b/src/BaseInputFilter.php index ae9d0c75..c62c38af 100644 --- a/src/BaseInputFilter.php +++ b/src/BaseInputFilter.php @@ -616,8 +616,6 @@ public function merge(BaseInputFilter $inputFilter) /** * @return array */ - // TODO replace functions when upgrading to > PHP 7.2 as minimum requirement - // public function getUnfilteredData() : array; public function getUnfilteredData() { return $this->unfilteredData; @@ -628,8 +626,6 @@ public function getUnfilteredData() * * @return $this */ - // TODO replace functions when upgrading to > PHP 7.2 as minimum requirement - // public function setUnfilteredData(array $data) : UnfilteredDataInterface; public function setUnfilteredData($data) { $this->unfilteredData = $data; diff --git a/src/UnfilteredDataInterface.php b/src/UnfilteredDataInterface.php index 446a8003..bb8639ec 100644 --- a/src/UnfilteredDataInterface.php +++ b/src/UnfilteredDataInterface.php @@ -25,8 +25,4 @@ public function getUnfilteredData(); * @return array */ public function setUnfilteredData($data); - - // TODO replace functions when upgrading to > PHP 7.2 as minimum requirement - // public function getUnfilteredData() : array; - // public function setUnfilteredData(array $data) : UnfilteredDataInterface; -} \ No newline at end of file +} From e6c5479d889d1fea8672512eed07716e8093d51a Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 30 Jan 2019 09:48:41 -0600 Subject: [PATCH 18/22] docs: use short-form file annotation for UnfilteredDataInterface --- src/UnfilteredDataInterface.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/UnfilteredDataInterface.php b/src/UnfilteredDataInterface.php index bb8639ec..0c001511 100644 --- a/src/UnfilteredDataInterface.php +++ b/src/UnfilteredDataInterface.php @@ -1,10 +1,8 @@ Date: Wed, 30 Jan 2019 09:59:31 -0600 Subject: [PATCH 19/22] qa: use `array` typehint for `setUnfilteredData()` --- src/BaseInputFilter.php | 8 +++----- src/UnfilteredDataInterface.php | 7 +++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/BaseInputFilter.php b/src/BaseInputFilter.php index c62c38af..c6db8319 100644 --- a/src/BaseInputFilter.php +++ b/src/BaseInputFilter.php @@ -27,7 +27,7 @@ class BaseInputFilter implements protected $data; /** - * @var array + * @var array|object */ protected $unfilteredData = []; @@ -614,7 +614,7 @@ public function merge(BaseInputFilter $inputFilter) } /** - * @return array + * @return array|object */ public function getUnfilteredData() { @@ -622,14 +622,12 @@ public function getUnfilteredData() } /** - * @param array $data - * + * @param array|object $data * @return $this */ public function setUnfilteredData($data) { $this->unfilteredData = $data; - return $this; } } diff --git a/src/UnfilteredDataInterface.php b/src/UnfilteredDataInterface.php index 0c001511..18d7bc37 100644 --- a/src/UnfilteredDataInterface.php +++ b/src/UnfilteredDataInterface.php @@ -13,14 +13,13 @@ interface UnfilteredDataInterface { /** - * @return array + * @return array|object */ public function getUnfilteredData(); /** - * @param array $data - * - * @return array + * @param array|object $data + * @return $this */ public function setUnfilteredData($data); } From 2fc2d7996cac8fdcb691d24c4cb33a7bc0e4740e Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 30 Jan 2019 09:58:12 -0600 Subject: [PATCH 20/22] Adds CHANGELOG entry for #176 --- CHANGELOG.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8577c260..dd34598c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,18 @@ All notable changes to this project will be documented in this file, in reverse ### Added -- Nothing. +- [#176](https://github.com/zendframework/zend-inputfilter/pull/176) adds the interface `UnfilteredDataInterface`, with the following methods: + + ```php + public function getUnfilteredData() : array|object; + public function setUnfilteredData(array|object $data) : $this; + ``` + + By default, the `BaseInputFilter` now implements this interface. + + The primary purpose of the interface is to allow the ability to access ALL + original raw data, and not just the data the input filter knows about. This is + particularly useful with collections. ### Changed From 5dd31cc5898a7296757b72a6f5935a3c139d0e00 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 30 Jan 2019 10:49:15 -0600 Subject: [PATCH 21/22] docs: Adds docs for UnfilteredDataInterface Completes #176 --- docs/book/unfiltered-data.md | 49 ++++++++++++++++++++++++++++++++++++ mkdocs.yml | 7 +++--- 2 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 docs/book/unfiltered-data.md diff --git a/docs/book/unfiltered-data.md b/docs/book/unfiltered-data.md new file mode 100644 index 00000000..e9141a81 --- /dev/null +++ b/docs/book/unfiltered-data.md @@ -0,0 +1,49 @@ +# Unfiltered Data + +> Since 2.10.0 + +On input filters, there are several methods for retrieving the data: + +- `getValues()` will return all known values after filtering them. +- `getRawValues()` will return all known values with no filtering applied. +- `getUnknown()` returns the set of all unknown values (values with no + corresponding input or input filter). + +At times, particularly when working with collections, you may want access to the +complete set of original data provided to the input filter. This can be +accomplished by merging the sets returned by `getRawValues()` and +`getUnknown()` when working with normal input filters, but this approach breaks +down when working with collections. + +Version 2.10.0 introduces a new interface, `Zend\InputFilter\UnfilteredDataInterface`, +for dealing with this situation. `Zend\InputFilter\BaseInputFilter`, which +forms the parent class for all shipped input filter implementations, implements +the interface, which consists of the following methods: + +```php +interface UnfilteredDataInterface +{ + /** + * @return array|object + */ + public function getUnfilteredData() + { + return $this->unfilteredData; + } + + /** + * @param array|object $data + * @return $this + */ + public function setUnfilteredData($data) + { + $this->unfilteredData = $data; + return $this; + } +} +``` + +The `setUnfilteredData()` method is called by `setData()` with the full `$data` +provided to that method, ensuring that `getUnfilteredData()` will always provide +the original data with which the input filter was initialized, with no filtering +applied. diff --git a/mkdocs.yml b/mkdocs.yml index 2b9d4633..6e056c3c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,13 +1,14 @@ docs_dir: docs/book site_dir: docs/html pages: - - index.md - - Intro: intro.md + - Home: index.md + - Introduction: intro.md - Reference: - Specifications: specs.md - Files: file-input.md - "Optional Input Filters": optional-input-filters.md + - "Unfiltered Data": unfiltered-data.md site_name: zend-inputfilter site_description: zend-inputfilter repo_url: 'https://github.com/zendframework/zend-inputfilter' -copyright: 'Copyright (c) 2016-2017 Zend Technologies USA Inc.' +copyright: 'Copyright (c) 2016-2019 Zend Technologies USA Inc.' From d6b9c62dcdaca9234c782c51b174acc836f7c9db Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Wed, 30 Jan 2019 10:52:04 -0600 Subject: [PATCH 22/22] release: 2.10.0 readiness - Updates branch aliases: - dev-master => 2.10.x-dev - dev-develop => 2.11.x-dev - Updates CHANGELOG - removes empty stub for 2.9.2 - sets date for 2.10.0 --- CHANGELOG.md | 24 +----------------------- composer.json | 4 ++-- composer.lock | 2 +- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd34598c..4534b71a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file, in reverse chronological order by release. -## 2.10.0 - TBD +## 2.10.0 - 2019-01-30 ### Added @@ -35,28 +35,6 @@ All notable changes to this project will be documented in this file, in reverse - Nothing. -## 2.9.2 - TBD - -### Added - -- Nothing. - -### Changed - -- Nothing. - -### Deprecated - -- Nothing. - -### Removed - -- Nothing. - -### Fixed - -- Nothing. - ## 2.9.1 - 2019-01-07 ### Added diff --git a/composer.json b/composer.json index d895fafd..d4825e7d 100644 --- a/composer.json +++ b/composer.json @@ -12,8 +12,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.9.x-dev", - "dev-develop": "2.10.x-dev" + "dev-master": "2.10.x-dev", + "dev-develop": "2.11.x-dev" }, "zf": { "component": "Zend\\InputFilter", diff --git a/composer.lock b/composer.lock index 001e4d10..990d3352 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b7ceabdec2f140507b9c15f618abc0d9", + "content-hash": "e21de7a4adcf1b5fdb80477fd117b56b", "packages": [ { "name": "container-interop/container-interop",