Re: [PHP-DEV] Unsetting declared fields

2017-01-16 Thread Marco Pivetta
Hi Michał, On Mon, Jan 16, 2017 at 10:30 AM, Michał Brzuchalski wrote: > As I am familiar with those interceptions, I tend to point out some dirty > hacks > when reflection tells you property exists while getting notice on set, see > https://3v4l.org/VDMHm > > > class

Re: [PHP-DEV] Unsetting declared fields

2017-01-16 Thread Michał Brzuchalski
As I am familiar with those interceptions, I tend to point out some dirty hacks when reflection tells you property exists while getting notice on set, see https://3v4l.org/VDMHm bar); } } $foo = new FooHack(new Foo); $reflectionFooBar = new \ReflectionProperty(Foo::class, 'bar');

Re: [PHP-DEV] Unsetting declared fields

2017-01-16 Thread Marco Pivetta
On Mon, Jan 16, 2017 at 9:49 AM, Michał Brzuchalski wrote: > Hi Marco, > > 2017-01-16 0:27 GMT+01:00 Marco Pivetta : > >> Hi Wes, >> >> This has been discussed before, and it's currently used to intercept >> access >> to properties. Since we don't have

Re: [PHP-DEV] Unsetting declared fields

2017-01-16 Thread Michał Brzuchalski
2017-01-16 9:49 GMT+01:00 Michał Brzuchalski : > Hi Marco, > > 2017-01-16 0:27 GMT+01:00 Marco Pivetta : > >> Hi Wes, >> >> This has been discussed before, and it's currently used to intercept >> access >> to properties. Since we don't have property

Re: [PHP-DEV] Unsetting declared fields

2017-01-16 Thread Michał Brzuchalski
Hi Marco, 2017-01-16 0:27 GMT+01:00 Marco Pivetta : > Hi Wes, > > This has been discussed before, and it's currently used to intercept access > to properties. Since we don't have property accessors (sigh), the code > (simplified version) would look like following: > > class

Re: [PHP-DEV] Unsetting declared fields

2017-01-15 Thread Wes
I do that too... but I feel bad for doing it :P Property accessors would be great to have...

Re: [PHP-DEV] Unsetting declared fields

2017-01-15 Thread Marco Pivetta
Almost forgot: these examples apply also to private and protected properties. That's currently the only way to make the behavior consistent across friend objects (same scope). On Mon, Jan 16, 2017 at 12:27 AM, Marco Pivetta wrote: > Hi Wes, > > This has been discussed

Re: [PHP-DEV] Unsetting declared fields

2017-01-15 Thread Marco Pivetta
Hi Wes, This has been discussed before, and it's currently used to intercept access to properties. Since we don't have property accessors (sigh), the code (simplified version) would look like following: class Foo { public $bar = 'baz'; } class FooInterceptor extends Foo { private

[PHP-DEV] Unsetting declared fields

2017-01-15 Thread Wes
Hello elephpants. Currently PHP allows explicitly declared fields (eg public $foo = 10;) to be removed entirely through unset (eg unset($obj->foo)). Now that isn't really an issue as properties in php are currently untyped and therefore nullable; at worst you would get a notice. But it would