Skip to content

Commit

Permalink
remove string trimming after typecasting #7
Browse files Browse the repository at this point in the history
  • Loading branch information
gregor-j committed Dec 15, 2021
1 parent 3ee08b9 commit f3f6787
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/Traits/ParamTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,33 +74,8 @@ private function castOutputValues(array $outputs, array $result): array
foreach ($outputs as $output) {
$key = $output->getName();
$value = $output->cast($result[$key]);
$type = $output->getType();
if (
$type === IElement::TYPE_STRING
|| $type === IArray::TYPE_ARRAY
) {
$value = $this->rtrimStrings($value);
}
$return[$key] = $value;
}
return $return;
}

/**
* Trim all trailing spaces, newlines and null-bytes from strings.
* @param mixed $return
* @return mixed
*/
private function rtrimStrings($return)
{
if (is_string($return)) {
return rtrim($return);
}
if (is_array($return)) {
foreach ($return as $key => $value) {
$return[$key] = $this->rtrimStrings($value);
}
}
return $return;
}
}

0 comments on commit f3f6787

Please sign in to comment.