diff --git a/src/exceptions.php b/src/exceptions.php index 71863ebb76296e23217a71fe7bcb73ae27979f86..dcfe4f9dc827b5b989018a018b6059d85d8761e8 100644 --- a/src/exceptions.php +++ b/src/exceptions.php @@ -1,11 +1,7 @@ <?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 {}; diff --git a/src/functions.php b/src/functions.php index fda6ddb18835d1eaa2c36e7f5f5ce89e6163449d..7eaf202f4f5e687bb599334eb61c483d13d80e14 100644 --- a/src/functions.php +++ b/src/functions.php @@ -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()) {