From fd6380e535787b2515881dcaaf8a7ae17058404c Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Wed, 29 Apr 2026 13:08:41 +0400 Subject: [PATCH 1/3] [#474] Remove stop()-driven shared control flow --- src/App/Exceptions/StopExecutionException.php | 34 ------------------- src/App/Helpers/app.php | 16 --------- tests/Unit/Http/Helpers/HttpHelperTest.php | 13 ++----- 3 files changed, 2 insertions(+), 61 deletions(-) delete mode 100644 src/App/Exceptions/StopExecutionException.php diff --git a/src/App/Exceptions/StopExecutionException.php b/src/App/Exceptions/StopExecutionException.php deleted file mode 100644 index f8c5e06d1..000000000 --- a/src/App/Exceptions/StopExecutionException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) - * @link http://quantum.softberg.org/ - * @since 3.0.0 - */ - -namespace Quantum\App\Exceptions; - -use Quantum\App\Enums\ExceptionMessages; - -/** - * Class StopExecutionException - * @package Quantum\App - */ -class StopExecutionException extends BaseException -{ - public static function executionTerminated(?int $code): self - { - return new self( - ExceptionMessages::EXECUTION_TERMINATED, - $code ?? 0 - ); - } -} diff --git a/src/App/Helpers/app.php b/src/App/Helpers/app.php index e140c56d4..b9f0b274d 100644 --- a/src/App/Helpers/app.php +++ b/src/App/Helpers/app.php @@ -11,19 +11,3 @@ * @link http://quantum.softberg.org/ * @since 3.0.0 */ - -use Quantum\App\Exceptions\StopExecutionException; - -/** - * Stops the app execution - * @return never - * @throws StopExecutionException - */ -function stop(?Closure $closure = null, ?int $code = 0): void -{ - if ($closure instanceof Closure) { - $closure(); - } - - throw StopExecutionException::executionTerminated($code); -} diff --git a/tests/Unit/Http/Helpers/HttpHelperTest.php b/tests/Unit/Http/Helpers/HttpHelperTest.php index 8cac6966c..483b06800 100644 --- a/tests/Unit/Http/Helpers/HttpHelperTest.php +++ b/tests/Unit/Http/Helpers/HttpHelperTest.php @@ -2,7 +2,6 @@ namespace Quantum\Tests\Unit\Http\Helpers; -use Quantum\App\Exceptions\StopExecutionException; use Quantum\Session\Factories\SessionFactory; use Quantum\Tests\Unit\AppTestCase; use Quantum\Router\RouteCollection; @@ -104,11 +103,7 @@ public function testRedirecting(): void { $this->assertFalse($this->response->hasHeader('Location')); - try { - redirect('/home'); - } catch (StopExecutionException $e) { - - } + redirect('/home'); $this->assertTrue($this->response->hasHeader('Location')); @@ -121,11 +116,7 @@ public function testRedirectWithOldData(): void $this->request->create('POST', '/', ['firstname' => 'Josh', 'lastname' => 'Doe']); - try { - redirectWith('/signup', $this->request->all()); - } catch (StopExecutionException $e) { - - } + redirectWith('/signup', $this->request->all()); $this->assertTrue($this->response->hasHeader('Location')); From 3561408e03bf1f049e57879084b5c72e6e346371 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Wed, 29 Apr 2026 13:10:15 +0400 Subject: [PATCH 2/3] [#474] Align ExitCode enum docblocks with project style --- src/App/Enums/ExitCode.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/App/Enums/ExitCode.php b/src/App/Enums/ExitCode.php index 7ceb37c18..2d1745252 100644 --- a/src/App/Enums/ExitCode.php +++ b/src/App/Enums/ExitCode.php @@ -2,8 +2,25 @@ declare(strict_types=1); +/** + * Quantum PHP Framework + * + * An open source software development framework for PHP + * + * @package Quantum + * @author Arman Ag. + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + namespace Quantum\App\Enums; +/** + * Class ExitCode + * @package Quantum\App + * @codeCoverageIgnore + */ final class ExitCode { public const SUCCESS = 0; @@ -11,4 +28,8 @@ final class ExitCode public const FAILURE = 1; public const INVALID = 2; + + private function __construct() + { + } } From a93f969c0bdac841ee4fde83532097a17963b159 Mon Sep 17 00:00:00 2001 From: Arman <407448+armanist@users.noreply.github.com> Date: Wed, 29 Apr 2026 13:29:33 +0400 Subject: [PATCH 3/3] [#474] Assert redirect helpers return response instance --- tests/Unit/Http/Helpers/HttpHelperTest.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/Unit/Http/Helpers/HttpHelperTest.php b/tests/Unit/Http/Helpers/HttpHelperTest.php index 483b06800..6f564b415 100644 --- a/tests/Unit/Http/Helpers/HttpHelperTest.php +++ b/tests/Unit/Http/Helpers/HttpHelperTest.php @@ -103,7 +103,9 @@ public function testRedirecting(): void { $this->assertFalse($this->response->hasHeader('Location')); - redirect('/home'); + $redirectResponse = redirect('/home'); + + $this->assertSame($this->response, $redirectResponse); $this->assertTrue($this->response->hasHeader('Location')); @@ -116,7 +118,9 @@ public function testRedirectWithOldData(): void $this->request->create('POST', '/', ['firstname' => 'Josh', 'lastname' => 'Doe']); - redirectWith('/signup', $this->request->all()); + $redirectResponse = redirectWith('/signup', $this->request->all()); + + $this->assertSame($this->response, $redirectResponse); $this->assertTrue($this->response->hasHeader('Location'));