Skip to content

Commit

Permalink
TASK: Pass arguments to EelInvocationTracerInterface and also trace…
Browse files Browse the repository at this point in the history
… function calls
  • Loading branch information
mhsdesign committed Aug 19, 2024
1 parent ee1266d commit 13ccf72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Neos.Eel/Classes/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public function call($method, array $arguments = [])
if ($this->value === null) {
return null;
} elseif (is_object($this->value)) {
$this->tracer?->recordMethodCall($this->value, $method);
$callback = [$this->value, $method];
} elseif (is_array($this->value)) {
if (!array_key_exists($method, $this->value)) {
Expand All @@ -113,6 +112,14 @@ public function call($method, array $arguments = [])
$arguments[$i] = $arguments[$i]->unwrap();
}
}
if ($this->tracer !== null) {
// optional experimental tracing
if (is_object($this->value)) {
$this->tracer->recordMethodCall($this->value, $method, $arguments);
} else {
$this->tracer->recordFunctionCall($callback, $method, $arguments);
}
}
return call_user_func_array($callback, $arguments);
}

Expand Down
10 changes: 9 additions & 1 deletion Neos.Eel/Classes/EelInvocationTracerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,13 @@ interface EelInvocationTracerInterface
{
public function recordPropertyAccess(object $object, string $propertyName): void;

public function recordMethodCall(object $object, string $methodName): void;
/**
* @param array<int, mixed> $arguments
*/
public function recordMethodCall(object $object, string $methodName, array $arguments): void;

/**
* @param array<int, mixed> $arguments
*/
public function recordFunctionCall(callable $function, string $functionName, array $arguments): void;
}

0 comments on commit 13ccf72

Please sign in to comment.