Compare commits

..

4 Commits

2 changed files with 12 additions and 1 deletions

View File

@@ -12,3 +12,8 @@ spl_autoload_register(function ($className) {
require_once $file;
}
});
set_exception_handler(function ($exception) {
echo "Uncaught exception: " , $exception->getMessage(), "\n";
echo $exception->getTraceAsString();
});

View File

@@ -140,6 +140,10 @@ class Synapsis
{
$values = [];
foreach ($parameters as $parameter) {
if ($parameter->isVariadic()) { // Skip variatic parameters
continue;
}
if ($parameter->isOptional()) { // Always use the default value first
$values[] = $parameter->getDefaultValue();
continue;
@@ -148,7 +152,9 @@ class Synapsis
$paramType = $parameter->getType();
if ($paramType === null) {
// If no type is declared, and it's not optional, we cannot resolve it.
throw new Exception('Untyped parameters expect at least a default value or must be optional.');
throw new Exception(
"Untyped parameter '{$parameter}' expect at least a default value or must be optional."
);
}
if ($paramType->isBuiltin()) {