briannesbitt/Carbon · error · InvalidArgumentException
Could not create reflection from the spec given
Error message
Could not create reflection from the spec given
What it means
Error "Could not create reflection from the spec given" thrown in briannesbitt/Carbon.
Source
Thrown at src/Carbon/PHPStan/MacroExtension.php:122
$deprecated = $reflection->isDeprecated();
$docComment = $reflection->getDocComment() ?: null;
} elseif ($macro instanceof Closure) {
$closure = $macro;
try {
$boundClosure = Closure::bind($closure, new stdClass());
$static = (!$boundClosure || (new ReflectionFunction($boundClosure))->getClosureThis() === null);
} catch (Throwable) {
$static = true;
}
$reflection = new ReflectionFunction($macro);
$deprecated = $reflection->isDeprecated();
$docComment = $reflection->getDocComment() ?: null;
}
if (!isset($closure)) {
throw new InvalidArgumentException('Could not create reflection from the spec given'); // @codeCoverageIgnore
}
$closureType = $this->closureTypeFactory->fromClosureObject($closure);
return new MacroMethodReflection(
$classReflection,
$methodName,
$closureType,
$static,
$final,
$deprecated,
$docComment,
);
}
}
View on GitHub (pinned to b13f05955d)
When it happens
Trigger: Thrown at src/Carbon/PHPStan/MacroExtension.php:122 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of briannesbitt/Carbon@b13f05955d (2026-08-17).
Data as JSON: /api/errors/5614fb1dc836a26a.
Report an issue: GitHub.