From ac21d12e9d64e470fa340f16875959b91609ba53 Mon Sep 17 00:00:00 2001 From: shahzadamodassir Date: Thu, 14 Nov 2024 17:56:08 +0530 Subject: [PATCH] developer commit --- AUTHORS | 1 + CHANGELOG.md | 5 +++++ src/Executor.php | 22 ++++++++++++++-------- tests/Promise.Test.php | 7 +++++++ 4 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 AUTHORS create mode 100644 CHANGELOG.md create mode 100644 tests/Promise.Test.php diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..4771206 --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Shahzada Modassir \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8a92d0d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release Notes + +## [Unreleased](https://github.com/lazervel/promise/compare/v3.0.0...v3.0.1) - 11 November 2024 + +- Fixed bugs in `Promise` that caused [e.g., incorrect output, duplicate combination, etc.]. \ No newline at end of file diff --git a/src/Executor.php b/src/Executor.php index be6aa98..3bff44b 100644 --- a/src/Executor.php +++ b/src/Executor.php @@ -31,6 +31,13 @@ class Executor */ protected $state = 'pending'; + /** + * Actual callbacks Resolve, Reject and Finally store in queue + * + * @var array + */ + protected $queue = []; + /** * Flag to know if executor handler was already fired * @@ -85,12 +92,6 @@ class Executor */ private $rejected = false; - /** - * - * @var array - */ - protected $queue = []; - /** * Creates a new Executor instance. * Initializes a new instance of Executor with the given $executor. @@ -111,6 +112,11 @@ public function __construct(callable $executor) */ protected function finalExecutorExecute() : void { + if (!$this->catched && $this->rejected) { + $this->execute(); + return; + } + try { ErrorHandler::PHP_ErrorHandlerActivate(); $this->execute(); @@ -140,12 +146,12 @@ private function resolve($value = null) : void */ private function reject($value = null) : void { - $this->rejected = true; + if (!$this->locked) $this->rejected = true; $this->fireWith($value, 'rejected'); } /** - * + * Returns a forced static function Handler Resolve or Reject * * @param string $handler [required] * @return static Returns resolve or reject Handler. diff --git a/tests/Promise.Test.php b/tests/Promise.Test.php new file mode 100644 index 0000000..f724c55 --- /dev/null +++ b/tests/Promise.Test.php @@ -0,0 +1,7 @@ + \ No newline at end of file