diff --git a/src/Serializer/AbstractSerializer.php b/src/Serializer/AbstractSerializer.php index ec1389ac8..b5b33b49f 100644 --- a/src/Serializer/AbstractSerializer.php +++ b/src/Serializer/AbstractSerializer.php @@ -288,6 +288,12 @@ protected function serializeCallable($callable): string throw new \InvalidArgumentException(sprintf('Expecting callable, got %s', \is_object($callable) ? \get_class($callable) : \gettype($callable))); } + // Prefer a string representation for simple strings that might just + // happen to be callable, such as "file". + if (\is_string($callable) && strpos($callable, '::') === false && strpos($callable, '_') === false) { + return $this->serializeString($callable); + } + try { if (\is_array($callable)) { $reflection = new \ReflectionMethod($callable[0], $callable[1]);