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