Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge pull request zendframework/zendframework#4351 from noopable/pat…
Browse files Browse the repository at this point in the history
…ch-validator-notempty

fix the constructor's type-autodetection accepts wrong parameters
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/NotEmpty.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function __construct($options = null)
$detected = 0;
$found = false;
foreach ($options as $option) {
if (in_array($option, $this->constants)) {
if (in_array($option, $this->constants, true)) {
$found = true;
$detected += array_search($option, $this->constants);
}
Expand Down
6 changes: 6 additions & 0 deletions test/NotEmptyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,12 @@ public function testEqualsMessageTemplates()
$this->assertAttributeEquals($validator->getOption('messageTemplates'),
'messageTemplates', $validator);
}

public function testTypeAutoDetectionHasNoSideEffect()
{
$validator = new NotEmpty(array('translatorEnabled' => true));
$this->assertEquals(493, $validator->getType());
}
}

class ClassTest2
Expand Down

0 comments on commit 63a3d48

Please sign in to comment.