Update InArray.php #4047

Closed
wants to merge 4 commits into
from

3 participants

@fchastanet

in InArray validator
if haystack is an empty array, an exception 'haystack option is mandatory' is thrown
should be exact equality ===

<?php
$t = array();
if ($t == null) echo "null\n"; else echo "not null\n";

this code echoes null

<?php
$t = array();
if ($t === null) echo "null\n"; else echo "not null\n";

this code echoes not null

@fchastanet fchastanet Update InArray.php
in InArray validator
if haystack is an empty array, an exception 'haystack option is mandatory' is thrown
should be exact equality ===




<?php
$t = array();
if ($t == null) echo "null\n"; else echo "not null\n";




this code echoes null




<?php
$t = array();
if ($t === null) echo "null\n"; else echo "not null\n";




this code echoes not null
b8af129
@mwillbanks

Thanks for the patch; please provide a unit test to test against existing behavior to prevent any regressions.

@fchastanet fchastanet Update InArrayTest.php
array() is a valid empty haystack, null no
188f46c
@mwillbanks

Looks like this behavior breaks since InArray validator does not accept null; see the build details.

fchastanet added some commits Mar 18, 2013
@fchastanet fchastanet Update InArrayTest.php 53243e5
@fchastanet fchastanet Update InArrayTest.php
the test testSetEmptyHaystack is not anymore needed as null can't be set 
on the setHaystack function because of the array type needed and empty array 
is possible.
4bf7b87
@fchastanet

Sorry about that, I'm new to github, Travis Test is OK now.
Finally, I removed the test that is no more needed
as null can't be set on the setHaystack function because of the array type needed
but empty array must be possible.

@mwillbanks mwillbanks commented on the diff Mar 18, 2013
tests/ZendTest/Validator/InArrayTest.php
@@ -52,16 +52,6 @@ public function testGetHaystack()
$this->assertEquals(array(1, 2, 3), $this->validator->getHaystack());
}
- public function testSetEmptyHaystack()
@mwillbanks
mwillbanks added a line comment Mar 18, 2013

Instead of removing this; the parameter value should be changed to "null".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@weierophinney weierophinney added a commit that referenced this pull request Mar 27, 2013
@weierophinney weierophinney [#4047] Re-instated test
- Modified to work on a clean instance of InArray, to demonstrate what happens
  if the haystack is null and you attempt to retrieve it.
0716e75
@weierophinney weierophinney added a commit that referenced this pull request Mar 27, 2013
@weierophinney weierophinney Merge branch 'hotfix/4047' into develop
Forward port #4047
0500c84
@weierophinney weierophinney added a commit that closed this pull request Mar 27, 2013
@weierophinney weierophinney Merge branch 'hotfix/4047'
Close #4047
4532128
@weierophinney
Zend Framework member

Re-instated the test on merge.

@ghost Unknown pushed a commit that referenced this pull request Jul 14, 2013
@weierophinney weierophinney [#4047] Re-instated test
- Modified to work on a clean instance of InArray, to demonstrate what happens
  if the haystack is null and you attempt to retrieve it.
f4f8a7c
@ghost Unknown pushed a commit that referenced this pull request Jul 14, 2013
@weierophinney weierophinney Merge branch 'hotfix/4047'
Close #4047
04420a5
@ghost Unknown pushed a commit that referenced this pull request Jul 14, 2013
@weierophinney weierophinney Merge branch 'hotfix/4047' into develop
Forward port #4047
d90d660
@weierophinney weierophinney added a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge pull request zendframework/zendframework#4047 from fchastanet/p…
…atch-1

Update InArray.php
c0f26f8
@weierophinney weierophinney added a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
@weierophinney weierophinney [zendframework/zendframework#4047] Re-instated test
- Modified to work on a clean instance of InArray, to demonstrate what happens
  if the haystack is null and you attempt to retrieve it.
15c8551
@weierophinney weierophinney added a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge branch 'hotfix/4047' a7c0820
@weierophinney weierophinney added a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
@weierophinney weierophinney Merge branch 'hotfix/4047' into develop 4ad378a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment