1
0
mirror of https://github.com/danog/amp.git synced 2024-11-30 04:29:08 +01:00

Improve Deferred performance switching

This commit is contained in:
Daniel Lowrey 2015-05-27 22:03:08 -04:00
parent 0c4f04c6ab
commit 31f21da9e9

View File

@ -2,8 +2,15 @@
namespace Amp;
if (defined("AMP_PRODUCTION_MODE") && AMP_PRODUCTION_MODE) {
final class Deferred implements Promisor, Promise { use PublicPromisor; }
} else {
final class Deferred implements Promisor { use PrivatePromisor; }
try {
if (@assert(false)) {
// PHP7 production environment (zend.assertions=0, assert.exception=0)
eval("namespace Amp; final class Deferred implements Promisor, Promise { use PublicPromisor; }");
} else {
// PHP < 7 or dev environment (zend.assertions=1, assert.exception=0)
final class Deferred implements Promisor { use PrivatePromisor; }
}
} catch (\AssertionException $e) {
// PHP7 dev environment (zend.assertions=1, assert.exception=1)
eval("namespace Amp; final class Deferred implements Promisor { use PrivatePromisor; }");
}