mirror of
https://github.com/danog/amp.git
synced 2024-11-26 20:15:00 +01:00
Swap production and dev definitions for Deferred and Emitter
This commit is contained in:
parent
210b6ff258
commit
9ff73ac681
@ -6,23 +6,13 @@ use Interop\Async\Promise;
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
try {
|
||||
if (@\assert(false)) {
|
||||
production: // PHP 7 production environment (zend.assertions=0)
|
||||
final class Deferred implements Promise {
|
||||
use Internal\Placeholder {
|
||||
resolve as public;
|
||||
fail as public;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Interop\Async\Promise
|
||||
*/
|
||||
public function promise(): Promise {
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
development: // PHP 7 development (zend.assertions=1) or PHP 5.x
|
||||
if (!@\assert(false)) {
|
||||
development: // PHP 7 development (zend.assertions=1)
|
||||
/**
|
||||
* Deferred is a container for a promise that is resolved using the resolve() and fail() methods of this object.
|
||||
* The contained promise may be accessed using the promise() method. This object should not be part of a public
|
||||
* API, but used internally to create and resolve a promise.
|
||||
*/
|
||||
final class Deferred {
|
||||
/**
|
||||
* @var \Interop\Async\Promise
|
||||
@ -71,6 +61,24 @@ try {
|
||||
($this->fail)($reason);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
production: // PHP 7 production environment (zend.assertions=0)
|
||||
/**
|
||||
* An optimized version of Deferred for production environments that is itself the promise.
|
||||
*/
|
||||
final class Deferred implements Promise {
|
||||
use Internal\Placeholder {
|
||||
resolve as public;
|
||||
fail as public;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Interop\Async\Promise
|
||||
*/
|
||||
public function promise(): Promise {
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\AssertionError $exception) {
|
||||
goto development; // zend.assertions=1 and assert.exception=1, use development definition.
|
||||
|
@ -6,24 +6,13 @@ use Interop\Async\Promise;
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
try {
|
||||
if (@\assert(false)) {
|
||||
production: // PHP 7 production environment (zend.assertions=0)
|
||||
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;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
development: // PHP 7 development (zend.assertions=1) or PHP 5.x
|
||||
if (!@\assert(false)) {
|
||||
development: // PHP 7 development (zend.assertions=1)
|
||||
/**
|
||||
* Deferred is a container for a stream that can emit values using the emit() method and resolved using the
|
||||
* resolve() and fail() methods of this object. The contained stream may be accessed using the stream() method.
|
||||
* This object should not be part of a public API, but used internally to create and emit values from a stream.
|
||||
*/
|
||||
final class Emitter {
|
||||
/**
|
||||
* @var \Amp\Stream
|
||||
@ -34,12 +23,12 @@ try {
|
||||
* @var callable
|
||||
*/
|
||||
private $emit;
|
||||
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
private $resolve;
|
||||
|
||||
|
||||
/**
|
||||
* @var callable
|
||||
*/
|
||||
@ -91,6 +80,25 @@ try {
|
||||
($this->fail)($reason);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
production: // PHP 7 production environment (zend.assertions=0)
|
||||
/**
|
||||
* An optimized version of Emitter for production environments that is itself the stream.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (\AssertionError $exception) {
|
||||
goto development; // zend.assertions=1 and assert.exception=1, use development definition.
|
||||
|
Loading…
Reference in New Issue
Block a user