Skip to content
Snippets Groups Projects
Commit 3f466774 authored by Jan Kuchař's avatar Jan Kuchař
Browse files

renamed exception to be more consistent with original PHP one

parent ccb77f39
No related branches found
No related tags found
1 merge request!1renamed exception to be more consistent with original PHP one
Pipeline #
<?php declare(strict_types=1);
namespace Grifart\AssertFunction;
use Throwable;
final class AssertFunctionError extends \AssertionError {
final class FunctionAssertionError extends \AssertionError {
const PATH_DEPTH = 2;
......@@ -53,5 +49,3 @@ final class AssertFunctionError extends \AssertionError {
return implode('/', $pathParts); // normalized shortened readable path
}
};
abstract class RuntimeException extends \RuntimeException {};
......@@ -5,7 +5,7 @@
// todo: use only assert( ... ) instead of exceptions; to be compatible without configuration with PHP env
// todo: [performance] separate code itself into autoloaded class
// todo: better assertion messages + throw AssertFunctionError + catch in fn + pass it to assert -> compatible with PHP assert config
// todo: better assertion messages + throw FunctionAssertionError + catch in fn + pass it to assert -> compatible with PHP assert config
// todo: covariance and contra-variance
namespace Grifart\AssertFunction;
......@@ -29,7 +29,7 @@ function assertSignature(callable $function, array $parameters, ?string $expecte
$numberOfParameters = $reflection->getNumberOfParameters();
assert(
$numberOfParameters === count($parameters),
AssertFunctionError::wrongNumberOrArguments($reflection, count($parameters), $numberOfParameters)
FunctionAssertionError::wrongNumberOrArguments($reflection, count($parameters), $numberOfParameters)
);
if ($numberOfParameters !== count($parameters)) {
return;
......@@ -53,7 +53,7 @@ function assertSignature(callable $function, array $parameters, ?string $expecte
if($expectedReturnType !== NULL) {
assert(
$reflection->hasReturnType(),
AssertFunctionError::missingReturnType($reflection, $expectedReturnType)
FunctionAssertionError::missingReturnType($reflection, $expectedReturnType)
);
if ($reflection->hasReturnType()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment