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

Merge branch 'rename-error' into 'master'

renamed exception to be more consistent with original PHP one

See merge request !1
parents ccb77f39 3f466774
Branches
Tags
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.
Please register or to comment