Skip to content

Commit

Permalink
Revert "Revert "Refactor""
Browse files Browse the repository at this point in the history
This reverts commit ca220b5.
  • Loading branch information
sebastianbergmann committed Jun 19, 2023
1 parent 73f4bfc commit eb2d761
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Framework/MockObject/Invocation.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ final class Invocation implements SelfDescribing
* @psalm-var non-empty-string
*/
private readonly string $methodName;
private array $parameters;
private readonly array $parameters;
private readonly string $returnType;
private bool $isReturnTypeNullable = false;
private readonly bool $isReturnTypeNullable;
private readonly bool $proxiedCall;
private readonly object $object;

Expand All @@ -48,7 +48,6 @@ public function __construct(string $className, string $methodName, array $parame
{
$this->className = $className;
$this->methodName = $methodName;
$this->parameters = $parameters;
$this->object = $object;
$this->proxiedCall = $proxiedCall;

Expand All @@ -59,19 +58,25 @@ public function __construct(string $className, string $methodName, array $parame
if (str_starts_with($returnType, '?')) {
$returnType = substr($returnType, 1);
$this->isReturnTypeNullable = true;
} else {
$this->isReturnTypeNullable = false;
}

$this->returnType = $returnType;

if (!$cloneObjects) {
$this->parameters = $parameters;

return;
}

foreach ($this->parameters as $key => $value) {
foreach ($parameters as $key => $value) {
if (is_object($value)) {
$this->parameters[$key] = Cloner::clone($value);
$parameters[$key] = Cloner::clone($value);
}
}

$this->parameters = $parameters;
}

public function className(): string
Expand Down

0 comments on commit eb2d761

Please sign in to comment.