Compare commits
4 Commits
3770dd6d9b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b5d19ecd5 | |||
| 53e862d126 | |||
| b6baeef32f | |||
| 159da01d5c |
@@ -12,3 +12,8 @@ spl_autoload_register(function ($className) {
|
|||||||
require_once $file;
|
require_once $file;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
set_exception_handler(function ($exception) {
|
||||||
|
echo "Uncaught exception: " , $exception->getMessage(), "\n";
|
||||||
|
echo $exception->getTraceAsString();
|
||||||
|
});
|
||||||
|
|||||||
@@ -140,6 +140,10 @@ class Synapsis
|
|||||||
{
|
{
|
||||||
$values = [];
|
$values = [];
|
||||||
foreach ($parameters as $parameter) {
|
foreach ($parameters as $parameter) {
|
||||||
|
if ($parameter->isVariadic()) { // Skip variatic parameters
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($parameter->isOptional()) { // Always use the default value first
|
if ($parameter->isOptional()) { // Always use the default value first
|
||||||
$values[] = $parameter->getDefaultValue();
|
$values[] = $parameter->getDefaultValue();
|
||||||
continue;
|
continue;
|
||||||
@@ -148,7 +152,9 @@ class Synapsis
|
|||||||
$paramType = $parameter->getType();
|
$paramType = $parameter->getType();
|
||||||
if ($paramType === null) {
|
if ($paramType === null) {
|
||||||
// If no type is declared, and it's not optional, we cannot resolve it.
|
// 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()) {
|
if ($paramType->isBuiltin()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user