Top-posting, since I'm taking off now.

>From outside the class, properties are not visible at all, so their types
are un-important from outer scopes.

echo $foo->bar; is not the same in instance method body or outside of the
class.
On Jun 10, 2016 2:55 PM, "Niklas Keller" <m...@kelunik.com> wrote:

> 2016-06-10 14:39 GMT+02:00 Marco Pivetta <ocram...@gmail.com>:
>
>> As already mentioned on twitter, I voted "no" on this RFC as it currently
>> stands. I might reconsider if following points are addressed:
>>
>>  1. __get semantics are not changed: let __get behave like it usually
>> does,
>> and let the user define a type hint on __get, should any be applicable.
>> Basically:
>>
>> class Foo
>> {
>>     private int $bar = 123;
>>     public function __get($name) { return 'banana'; } // *ALWAYS* works -
>> why would I even want a type error here?
>> }
>>
>
> You want a type error if bar is unset, mainly because Foo->bar should
> always be an int.
> If you unset it and set it again, it still has to be an int. And
> reflection will tell you it's always an int.
> So why should __get be allowed to return something different?
>
>
>>  * by-ref access should be enabled when the reference property has the
>> same
>> declared type as the source one
>>
>> class Foo
>> {
>>     public int $bar = 123;
>> }
>>
>> class Bar
>> {
>>     public int $baz = 456;
>>     public string $taz = 'taz';
>> }
>>
>> $foo = new Foo;
>> $bar = new Bar;
>>
>> $bar->baz = & $foo->bar; // works
>> $bar->taz = & $foo->bar; // crashes
>>
>> Cheers,
>>
>>
>> Marco Pivetta
>>
>> http://twitter.com/Ocramius
>>
>> http://ocramius.github.com/
>>
>> On 10 June 2016 at 12:38, Joe Watkins <pthre...@pthreads.org> wrote:
>>
>> > Afternoon internals,
>> >
>> >     The vote for typed properties has been restarted.
>> >
>> >     Please take part: https://wiki.php.net/rfc/typed-properties
>> >
>> > Cheers
>> > Joe
>> >
>>
>
>

Reply via email to