Re: [RFC Discussion] Typed Properties
| From: | Yasuo Ohgaki | Date: | Thu, 17 Mar 2016 02:03:00 +0000 |
| Subject: | Re: [RFC Discussion] Typed Properties | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91726@lists.php.net to get a copy of this message | ||
Hi all,
On Thu, Mar 17, 2016 at 8:30 AM, Johannes Schlüter
<johannes@schlueters.de> wrote:
> On Wed, 2016-03-16 at 15:29 -0400, Phil Sturgeon wrote:
>> > What's expected here:
>> >
>> > class A {
>> > public int $i;
>> > }
>> >
>> > $a = new A();
>> > $r = &$a->i;
>> > $r = "foobar";
>
>> I put your code into 3v4l so you could see what would happen:
>>
>> https://3v4l.org/taC8D
>>
>> Fatal error: Uncaught TypeError: Typed property A::$i must not be referenced
>>
>> Is that what you expect? If not, what would you expect?
I expect work like parameter type hint.
[yohgaki@dev github-php-src]$ ./php-bin -a
Interactive shell
php > declare(strict_types=1);
php > function foo(int $i) { $i='abc'; var_dump($i); }
php > foo(123);
string(3) "abc"
PHP is not strongly typed language (at least now).
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net