1--TEST-- 2Changing scope with Closure::bindTo() does not confuse asymmetric visibility 3--FILE-- 4<?php 5 6class Foo { 7 public private(set) int $bar = 1; 8} 9class Bar {} 10 11$foo = new Foo(); 12 13$c = function () use ($foo) { 14 $foo->bar++; 15}; 16 17($c->bindTo(null, Foo::class))(); 18var_dump($foo->bar); 19try { 20 $c(); 21} catch (Error $e) { 22 echo $e->getMessage(), "\n"; 23} 24try { 25 ($c->bindTo(null, Bar::class))(); 26} catch (Error $e) { 27 echo $e->getMessage(), "\n"; 28} 29var_dump($foo->bar); 30 31?> 32--EXPECT-- 33int(2) 34Cannot modify private(set) property Foo::$bar from global scope 35Cannot modify private(set) property Foo::$bar from scope Bar 36int(2) 37