mirror of
https://github.com/danog/amp.git
synced 2024-11-26 20:15:00 +01:00
Use eval to prevent multiple definitions warnings for Emitter and Deferred
This commit is contained in:
parent
a0b8de40fb
commit
b810ff1034
@ -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.
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user