Skip to content

Commit 076b9e6

Browse files
committed
Refactored #642 test to reduce it to the actual bug
Reading a property from an interface proxy used to lead to a fatal error, but should be a notice instead.
1 parent d1ccf94 commit 076b9e6

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,27 @@
11
--TEST--
2-
Verifies that lazy loading value holder factory can generate proxy for interfaces.
2+
Verifies that lazy loading value holder proxies for interfaces disallow public property read attempts
33
--FILE--
44
<?php
55

66
require_once __DIR__ . '/init.php';
77

88
interface MyInterface
99
{
10-
public function do();
11-
}
12-
13-
class MyClass implements MyInterface
14-
{
15-
public function do()
16-
{
17-
echo 'Hello';
18-
}
1910
}
2011

2112
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($configuration);
2213

2314
$proxy = $factory
24-
->createProxy(MyInterface::class, function (& $wrapped, $proxy, $method, array $parameters, & $initializer) {
15+
->createProxy(MyInterface::class, function (& $wrapped, $proxy, $method, array $parameters, & $initializer) : bool {
2516
$initializer = null;
26-
$wrapped = new MyClass();
17+
$wrapped = new class implements MyInterface {
18+
};
19+
20+
return true;
2721
});
2822

29-
$proxy->do();
30-
$proxy->someDynamicProperty = ' World';
3123
echo $proxy->someDynamicProperty;
3224

3325
?>
3426
--EXPECTF--
35-
Hello
3627
Notice: Undefined property: MyInterface::$someDynamicProperty %s
37-
World

0 commit comments

Comments
 (0)