From b810ff10344f0f9064c2cb3c4219c27453b4a91a Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Thu, 13 Apr 2017 18:04:51 +0200 Subject: [PATCH] Use eval to prevent multiple definitions warnings for Emitter and Deferred --- lib/Deferred.php | 20 ++++++-------------- lib/Emitter.php | 21 ++++++--------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/lib/Deferred.php b/lib/Deferred.php index 71213aa..7bc2fbc 100644 --- a/lib/Deferred.php +++ b/lib/Deferred.php @@ -62,21 +62,13 @@ try { } else { production: // PHP 7 production environment (zend.assertions=0) /** - * An optimized version of Deferred for production environments that is itself the promise. + * An optimized version of Deferred for production environments that is itself the promise. Eval is used to + * prevent IDEs and other tools from reporting multiple definitions. */ - final class Deferred implements Promise { - use Internal\Placeholder { - resolve as public; - fail as public; - } - - /** - * @return \Amp\Promise - */ - public function promise(): Promise { - return $this; - } - } + eval('final class Deferred implements Promise { + use Internal\Placeholder { resolve as public; fail as public; } + public function promise(): Promise { return $this; } + }'); } } catch (\AssertionError $exception) { goto development; // zend.assertions=1 and assert.exception=1, use development definition. diff --git a/lib/Emitter.php b/lib/Emitter.php index 1421c42..26383fc 100644 --- a/lib/Emitter.php +++ b/lib/Emitter.php @@ -81,22 +81,13 @@ try { } else { production: // PHP 7 production environment (zend.assertions=0) /** - * An optimized version of Emitter for production environments that is itself the stream. + * An optimized version of Emitter for production environments that is itself the stream. Eval is used to + * prevent IDEs and other tools from reporting multiple definitions. */ - final class Emitter implements Stream { - use Internal\Producer { - emit as public; - resolve as public; - fail as public; - } - - /** - * @return \Amp\Stream - */ - public function stream(): Stream { - return $this; - } - } + eval('final class Emitter implements Stream { + use Internal\Producer { emit as public; resolve as public; fail as public; } + public function stream(): Stream { return $this; } + }'); } } catch (\AssertionError $exception) { goto development; // zend.assertions=1 and assert.exception=1, use development definition.