diff --git a/.github/lang/es-ES/README.md b/.github/lang/es-ES/README.md
index 32f1843..f59c1ac 100644
--- a/.github/lang/es-ES/README.md
+++ b/.github/lang/es-ES/README.md
@@ -61,9 +61,7 @@ git clone https://github.com/josantonius/php-exception-handler.git
### Clase ExceptionHandler
-```php
-use Josantonius\ExceptionHandler\ExceptionHandler;
-```
+`Josantonius\ExceptionHandler\ExceptionHandler`
Establece un manejador de excepciones:
@@ -71,19 +69,19 @@ Establece un manejador de excepciones:
/**
* Sets a exception handler.
*
- * @param callable $callback Función para manejo de excepciones.
- * @param array $runBeforeCallback Métodos a llamar en la excepción antes del callback.
- * @param array $runAfterCallback Métodos a llamar en la excepción después del callback.
+ * @param callable $callback Exception handler function.
+ * @param string[] $runBeforeCallback Method names to call in the exception before run callback.
+ * @param string[] $runAfterCallback Method names to call in the exception after run callback.
*
- * @throws NotCallableException si la llamada de retorno no es de tipo callable.
- * @throws WrongMethodNameException si el nombre del método no es string o está vacío.
+ * @throws NotCallableException if the callback is not callable.
+ * @throws WrongMethodNameException if the method names are not string or are empty.
*
* @see https://www.php.net/manual/en/functions.first_class_callable_syntax.php
*/
-new ExceptionHandler(
- callable $callback,
- string[] $runBeforeCallback = [],
- string[] $runAfterCallback = []
+public function __construct(
+ private callable $callback,
+ private array $runBeforeCallback = [],
+ private array $runAfterCallback = []
);
```
@@ -91,9 +89,6 @@ new ExceptionHandler(
```php
use Josantonius\ExceptionHandler\Exceptions\NotCallableException;
-```
-
-```php
use Josantonius\ExceptionHandler\Exceptions\WrongMethodNameException;
```
diff --git a/README.md b/README.md
index 3eaf9c0..a2bc23c 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ PHP library for handling exceptions.
- [TODO](#todo)
- [Changelog](#changelog)
- [Contribution](#contribution)
-- [Sponsor](#Sponsor)
+- [Sponsor](#sponsor)
- [License](#license)
---
@@ -61,9 +61,7 @@ git clone https://github.com/josantonius/php-exception-handler.git
### ExceptionHandler Class
-```php
-use Josantonius\ExceptionHandler\ExceptionHandler;
-```
+`Josantonius\ExceptionHandler\ExceptionHandler`
Sets a exception handler:
@@ -72,18 +70,18 @@ Sets a exception handler:
* Sets a exception handler.
*
* @param callable $callback Exception handler function.
- * @param array $runBeforeCallback Method names to call in the exception before run callback.
- * @param array $runAfterCallback Method names to call in the exception after run callback.
+ * @param string[] $runBeforeCallback Method names to call in the exception before run callback.
+ * @param string[] $runAfterCallback Method names to call in the exception after run callback.
*
* @throws NotCallableException if the callback is not callable.
* @throws WrongMethodNameException if the method names are not string or are empty.
*
* @see https://www.php.net/manual/en/functions.first_class_callable_syntax.php
*/
-new ExceptionHandler(
- callable $callback,
- string[] $runBeforeCallback = [],
- string[] $runAfterCallback = []
+public function __construct(
+ private callable $callback,
+ private array $runBeforeCallback = [],
+ private array $runAfterCallback = []
);
```
@@ -91,9 +89,6 @@ new ExceptionHandler(
```php
use Josantonius\ExceptionHandler\Exceptions\NotCallableException;
-```
-
-```php
use Josantonius\ExceptionHandler\Exceptions\WrongMethodNameException;
```
diff --git a/phpmd.xml b/phpmd.xml
index e3aa244..2202c32 100644
--- a/phpmd.xml
+++ b/phpmd.xml
@@ -32,7 +32,7 @@
-
+
diff --git a/src/ExceptionHandler.php b/src/ExceptionHandler.php
index 977d43b..334ecaf 100644
--- a/src/ExceptionHandler.php
+++ b/src/ExceptionHandler.php
@@ -3,13 +3,13 @@
declare(strict_types=1);
/*
-* This file is part of https://github.com/josantonius/php-exception-handler repository.
-*
-* (c) Josantonius
-*
-* For the full copyright and license information, please view the LICENSE
-* file that was distributed with this source code.
-*/
+ * This file is part of https://github.com/josantonius/php-exception-handler repository.
+ *
+ * (c) Josantonius
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
namespace Josantonius\ExceptionHandler;
diff --git a/src/Exceptions/NotCallableException.php b/src/Exceptions/NotCallableException.php
index 834c76a..f4d970d 100644
--- a/src/Exceptions/NotCallableException.php
+++ b/src/Exceptions/NotCallableException.php
@@ -1,13 +1,13 @@
-*
-* For the full copyright and license information, please view the LICENSE
-* file that was distributed with this source code.
-*/
+ * This file is part of https://github.com/josantonius/php-exception-handler repository.
+ *
+ * (c) Josantonius
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
namespace Josantonius\ExceptionHandler\Exceptions;
diff --git a/src/Exceptions/WrongMethodNameException.php b/src/Exceptions/WrongMethodNameException.php
index ae15059..c70475c 100644
--- a/src/Exceptions/WrongMethodNameException.php
+++ b/src/Exceptions/WrongMethodNameException.php
@@ -1,13 +1,13 @@
-*
-* For the full copyright and license information, please view the LICENSE
-* file that was distributed with this source code.
-*/
+ * This file is part of https://github.com/josantonius/php-exception-handler repository.
+ *
+ * (c) Josantonius
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
namespace Josantonius\ExceptionHandler\Exceptions;
diff --git a/tests/ExceptionHandlerTest.php b/tests/ExceptionHandlerTest.php
index e635a73..25dd9e5 100644
--- a/tests/ExceptionHandlerTest.php
+++ b/tests/ExceptionHandlerTest.php
@@ -1,13 +1,15 @@
-*
-* For the full copyright and license information, please view the LICENSE
-* file that was distributed with this source code.
-*/
+ * This file is part of https://github.com/josantonius/php-exception-handler repository.
+ *
+ * (c) Josantonius
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ *
+ * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
+ */
namespace Josantonius\ErrorHandler\Tests;
@@ -31,14 +33,14 @@ public function setUp(): void
$this->handler = new Handler();
}
- public function testShouldFailIfCallableCallbackIsNotPassed(): void
+ public function test_should_fail_if_callable_callback_is_not_passed(): void
{
$this->expectException(NotCallableException::class);
new ExceptionHandler(callback: 'foo');
}
- public function testShouldFailIfTheMethodNamesNotContainValidDataType(): void
+ public function test_should_fail_if_the_method_names_not_contain_valid_data_type(): void
{
$this->expectException(WrongMethodNameException::class);
@@ -48,7 +50,7 @@ public function testShouldFailIfTheMethodNamesNotContainValidDataType(): void
);
}
- public function testShouldSetTheHandlerOnlyWithTheCallback(): void
+ public function test_should_set_the_handler_only_with_the_callback(): void
{
$this->assertInstanceOf(
ExceptionHandler::class,
@@ -56,7 +58,7 @@ public function testShouldSetTheHandlerOnlyWithTheCallback(): void
);
}
- public function testShouldSetTheHandlerOnlyWithCallsToRunBefore(): void
+ public function test_should_set_the_handler_only_with_calls_to_run_before(): void
{
$this->assertInstanceOf(
ExceptionHandler::class,
@@ -67,7 +69,7 @@ public function testShouldSetTheHandlerOnlyWithCallsToRunBefore(): void
);
}
- public function testShouldSetTheHandlerOnlyWithCallsToAfter(): void
+ public function test_should_set_the_handler_only_with_calls_to_after(): void
{
$this->assertInstanceOf(
ExceptionHandler::class,
@@ -78,7 +80,7 @@ public function testShouldSetTheHandlerOnlyWithCallsToAfter(): void
);
}
- public function testShouldCallTheCallbackWhenAnExceptionIsThrow(): void
+ public function test_should_call_the_callback_when_an_exception_is_throw(): void
{
$exceptionHandler = new ExceptionHandler(callback: $this->handler->init(...));
@@ -94,7 +96,7 @@ public function testShouldCallTheCallbackWhenAnExceptionIsThrow(): void
$this->assertEquals('init', History::get(0)->methodName);
}
- public function testShouldCallTheCallbackBeforeRunMethodsWhenAnExceptionIsThrow(): void
+ public function test_should_call_the_callback_before_run_methods_when_exception_is_throw(): void
{
$exceptionHandler = new ExceptionHandler(
callback: $this->handler->init(...),
@@ -113,7 +115,7 @@ public function testShouldCallTheCallbackBeforeRunMethodsWhenAnExceptionIsThrow(
$this->assertEquals('context', History::get(0)->methodName);
}
- public function testShouldCallTheCallbackAfterRunMethodsWhenAnExceptionIsThrow(): void
+ public function test_should_call_the_callback_after_run_methods_when_exception_is_throw(): void
{
$exceptionHandler = new ExceptionHandler(
callback: $this->handler->init(...),
@@ -134,7 +136,7 @@ public function testShouldCallTheCallbackAfterRunMethodsWhenAnExceptionIsThrow()
$this->assertEquals('render', History::get(2)->methodName);
}
- public function testShouldCallTheCallbackAfterAndBeforeRunMethodsWhenAnExceptionIsThrow(): void
+ public function test_should_call_callback_and_all_methods_when_an_exception_is_throw(): void
{
$exceptionHandler = new ExceptionHandler(
callback: $this->handler->init(...),