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 40368aa commit aaeedce
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 @@ -80,33 +80,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 === IStruct::TYPE_STRUCT
|| $type === ITable::TYPE_TABLE
) {
$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 aaeedce

Please sign in to comment.