diff options
-rw-r--r-- | Zend/tests/closure_041.phpt | 2 | ||||
-rw-r--r-- | Zend/tests/closure_044.phpt | 6 | ||||
-rw-r--r-- | Zend/tests/closure_046.phpt | 4 | ||||
-rw-r--r-- | Zend/tests/no_class_const_propagation_in_closures.phpt | 2 | ||||
-rw-r--r-- | Zend/zend_closures.c | 3 |
5 files changed, 14 insertions, 3 deletions
diff --git a/Zend/tests/closure_041.phpt b/Zend/tests/closure_041.phpt index 33cf03b14c..cfe4f9487f 100644 --- a/Zend/tests/closure_041.phpt +++ b/Zend/tests/closure_041.phpt @@ -80,6 +80,8 @@ scoped to A: bool(false) bound: no scoped to A: bool(true) bound: no + +Deprecated: Unbinding $this of closure is deprecated in %s on line %d scoped to A: bool(true) bound: no After binding, with same-class instance for the bound ones diff --git a/Zend/tests/closure_044.phpt b/Zend/tests/closure_044.phpt index c71204b130..225d7540d2 100644 --- a/Zend/tests/closure_044.phpt +++ b/Zend/tests/closure_044.phpt @@ -38,7 +38,7 @@ $d = $nonstaticUnscoped->bindTo(new A, 'A'); $d(); echo "\n"; $d = $nonstaticScoped->bindTo(new A, 'A'); $d(); echo "\n"; echo "Done.\n"; ---EXPECT-- +--EXPECTF-- Before binding bool(false) bool(false) @@ -50,6 +50,8 @@ After binding, null scope, no instance bool(false) bool(false) + +Deprecated: Unbinding $this of closure is deprecated in %s on line %d bool(false) bool(false) @@ -64,6 +66,8 @@ After binding, with scope, no instance bool(true) bool(false) + +Deprecated: Unbinding $this of closure is deprecated in %s on line %d bool(true) bool(false) diff --git a/Zend/tests/closure_046.phpt b/Zend/tests/closure_046.phpt index ef8aff4bbc..e10cc1b57e 100644 --- a/Zend/tests/closure_046.phpt +++ b/Zend/tests/closure_046.phpt @@ -38,7 +38,7 @@ echo "After binding, with different instance for the bound one", "\n"; $d = $nonstaticScoped->bindTo(new B, "static"); $d(); echo "\n"; echo "Done.\n"; ---EXPECT-- +--EXPECTF-- Before binding bool(false) bool(false) @@ -50,6 +50,8 @@ After binding, no instance bool(false) bool(false) + +Deprecated: Unbinding $this of closure is deprecated in %s on line %d bool(true) bool(false) diff --git a/Zend/tests/no_class_const_propagation_in_closures.phpt b/Zend/tests/no_class_const_propagation_in_closures.phpt index e446573b9d..89d48e2d83 100644 --- a/Zend/tests/no_class_const_propagation_in_closures.phpt +++ b/Zend/tests/no_class_const_propagation_in_closures.phpt @@ -18,7 +18,7 @@ class B { } $f = (new A)->f(); -var_dump($f->bindTo(null, 'B')()); +var_dump($f->bindTo(new B, 'B')()); ?> --EXPECT-- diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c index e8688a6fd1..a8c4a89862 100644 --- a/Zend/zend_closures.c +++ b/Zend/zend_closures.c @@ -90,6 +90,9 @@ static zend_bool zend_valid_closure_binding( } else { zend_error(E_DEPRECATED, "Unbinding $this of a method is deprecated"); } + } else if (!is_fake_closure && !Z_ISUNDEF(closure->this_ptr)) { + // TODO: Only deprecate if it had $this *originally*? + zend_error(E_DEPRECATED, "Unbinding $this of closure is deprecated"); } if (scope && scope != func->common.scope && scope->type == ZEND_INTERNAL_CLASS) { |