[#3055] Remove array to string conversion notice #3484

Merged
merged 1 commit into from Jan 21, 2013

Projects

None yet

3 participants

@weierophinney
Member
  • Removes an array to string conversion notice when nested arrays are
    provided as values

Addresses #3055

@weierophinney weierophinney [#3055] Remove array to string conversion notice
- Removes an array to string conversion notice when nested arrays are
  provided as values
138f73b
@ThomasCantonnet ThomasCantonnet commented on the diff Jan 19, 2013
library/Zend/Validator/AbstractValidator.php
@@ -303,7 +303,7 @@ protected function createMessage($messageKey, $value)
) {
$value = get_class($value) . ' object';
} elseif (is_array($value)) {
- $value = '[' . implode(', ', $value) . ']';
+ $value = var_export($value, 1);
} else {
@ThomasCantonnet
ThomasCantonnet Jan 19, 2013 Contributor

I reckon var_export expects a boolean as a second parameter.

@weierophinney
weierophinney Jan 19, 2013 Member

Any truthy value works; I regularly use exactly this syntax.

On Saturday, January 19, 2013, Thomas Cantonnet wrote:

In library/Zend/Validator/AbstractValidator.php:

@@ -303,7 +303,7 @@ protected function createMessage($messageKey, $value)
) {
$value = get_class($value) . ' object';
} elseif (is_array($value)) {

  •        $value = '[' . implode(', ', $value) . ']';
    
  •        $value = var_export($value, 1);
     } else {
    

I reckon var_export expects a boolean as a second parameter.


Reply to this email directly or view it on GitHubhttps://github.com/zendframework/zf2/pull/3484/files#r2705210.

Matthew Weier O'Phinney
matthew@weierophinney.net
http://mwop.net/

@weierophinney
weierophinney Jan 19, 2013 Member

Additionally, when testing, I had a $this->fail($message) present so that I could introspect the output of various different solutions I tried. Finally, if array to string conversion were happening, we would not see the various values I test for in the unit test, which further demonstrates that it works as written.

@Maks3w Maks3w merged commit 138f73b into zendframework:master Jan 21, 2013

1 check passed

default The Travis build passed
Details
@Maks3w Maks3w was assigned Jan 21, 2013
@weierophinney weierophinney deleted the weierophinney:hotfix/3055 branch Jan 21, 2013
@gianarb gianarb pushed a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
@Maks3w Maks3w Merge pull request zendframework/zendframework#3484 branch 'hotfix/ar…
…ray-to-string-conversion'
be31ff1
@gianarb gianarb pushed a commit to zendframework/zend-validator that referenced this pull request May 15, 2015
@Maks3w Maks3w Forward port zendframework/zendframework#3484 7c0ec68
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment