Private and protected properties don't raise errors when accessed from invalid scope
dktapps opened this issue · comments
Dylan T. commented
Environment
- PHP: 7.2.9
- pthreads: master
- OS: windows
Reproducing Code
class B extends \Threaded{
private $a = 1;
protected $b = 2;
}
$b = new B;
var_dump($b->a);
var_dump($b->b);
Expected Output
Fatal error: Uncaught Error: Cannot access private property B::$a
Actual Output
int(1)
int(2)
Thomas Punt commented
I noticed this some time ago too. In my initial implementation of the Actor model (which followed pthreads' approach to data sharing, and therefore required a backing property store for actors), I had the following code for this:
https://github.com/tpunt/phactor/blob/9afaa2fd128bde32574b0206c9a1cdc70eda3dc7/ph_prop_store.c#L47-L87
I expect the general logic for it can be reused here.