Skip to content

Commit

Permalink
Fix uses of trim as callback
Browse files Browse the repository at this point in the history
trim function cannot be used as callback argument of array_walk since the second argument of the callback (array index) conflicts with the second argument of trim (characters to trim) dealing in unexpected behaviors.
  • Loading branch information
Maks3w committed Jan 13, 2014
1 parent 723a50a commit 6bec874
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion library/Zend/Http/Header/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,13 @@ protected function assembleValue()
protected function splitMediaTypesFromString($criteria)
{
$mediaTypes = explode(',', $criteria);
array_walk($mediaTypes, 'trim');
array_walk(
$mediaTypes,
function (&$value) {
$value = trim($value);
}
);

return $mediaTypes;
}

Expand Down
7 changes: 6 additions & 1 deletion library/Zend/Mail/Header/AbstractAddressList.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ public static function fromString($headerLine)
// split value on ","
$fieldValue = str_replace(Headers::FOLDING, ' ', $fieldValue);
$values = explode(',', $fieldValue);
array_walk($values, 'trim');
array_walk(
$values,
function (&$value) {
$value = trim($value);
}
);

$addressList = $header->getAddressList();
foreach ($values as $address) {
Expand Down

0 comments on commit 6bec874

Please sign in to comment.