Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Kempf <[email protected]>
  • Loading branch information
R4c00n committed Feb 16, 2022
1 parent fa0d519 commit cd0442a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/ConstructorParametersHydratorDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,23 @@ private function getConstructorParameters(ProxyObject $object): array

/**
* @param mixed $value
* @param ReflectionParameter $constructorParameter
* @return mixed
*/
private function castScalarValue($value, ReflectionParameter $constructorParameter)
{
if ($value === null || !$constructorParameter->getType() instanceof ReflectionNamedType) {
if ($value === null || ! $constructorParameter->getType() instanceof ReflectionNamedType) {
return $value;
}

switch ($constructorParameter->getType()->getName()) {
case 'string':
return (string)$value;
return (string) $value;
case 'int':
return (int)$value;
return (int) $value;
case 'float':
return (float)$value;
return (float) $value;
case 'bool':
return (bool)$value;
return (bool) $value;
default:
return $value;
}
Expand Down
6 changes: 3 additions & 3 deletions test/TestAsset/ObjectWithConstructor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ final class ObjectWithConstructor

public function __construct(string $foo, bool $isMandatory, float $price, ?int $bar = 42)
{
$this->foo = $foo;
$this->foo = $foo;
$this->isMandatory = $isMandatory;
$this->bar = $bar;
$this->price = $price;
$this->bar = $bar;
$this->price = $price;
}

public function getFoo(): string
Expand Down

0 comments on commit cd0442a

Please sign in to comment.