diff options
author | Andrea Faulds <ajf@ajf.me> | 2014-07-30 03:21:44 +0100 |
---|---|---|
committer | Andrea Faulds <ajf@ajf.me> | 2014-07-30 03:21:44 +0100 |
commit | 85bf8b4ff19b9ab4f30be0265db9a18805b0ebc0 (patch) | |
tree | 08f6fbd6e4046a8e1b2c05ff9b886160d4cec38c /Zend/zend_closures.c | |
parent | f65bdda469dfc30bd28652a6aa94d369eac1b6b2 (diff) | |
download | php-git-85bf8b4ff19b9ab4f30be0265db9a18805b0ebc0.tar.gz |
Fixed unbound scoped closure edge cases and added tests for them
Diffstat (limited to 'Zend/zend_closures.c')
-rw-r--r-- | Zend/zend_closures.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index 72823a5a0b..a5735f4c79 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -563,6 +563,12 @@ ZEND_API void zend_create_closure_ex(zval *res, zend_function *func, zend_class_ If an unbound scoped closure is desired, the parameter must be set to 1*/ } else if (!unbound_scoped) { closure->func.common.fn_flags |= ZEND_ACC_STATIC; + /* Unbound but scoped was explicitly specified and we wish to avoid E_ERROR when calling without object + We don't do this if it has implict allowed static (i.e. is a method, should E_STRICT) + Nor do we do this if it's an internal function (which would blow up if $this was NULL) + (In that case, we're actually creating a closure which can't be called without apply) */ + } else if ((func->common.fn_flags & ZEND_ACC_ALLOW_STATIC) == 0 && func->type == ZEND_USER_FUNCTION) { + closure->func.common.fn_flags |= ZEND_ACC_ALLOW_STATIC_EXPLICIT; } } } |