Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103240 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 68114 invoked from network); 24 Sep 2018 00:09:30 -0000 Received: from unknown (HELO backup0.admin.net.pl) (80.72.35.163) by pb1.pair.com with SMTP; 24 Sep 2018 00:09:30 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=korulczyk.pl; s=devil; h=Content-Transfer-Encoding:Content-Type:In-Reply-To :MIME-Version:Date:Message-ID:From:References:To:Subject:Sender:Reply-To:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Kpb065fYSfhtph6giao7aiNMePijQLmloC0IggK7Vog=; b=gqalDXDk9IZW4EIw3QooqrwdP1 AppHUTRfZOuEFNzFqH+d/lf56PHFupCfi1nIM6NRxltHAP1nOhwV9xVNSd6KQQroccoaMcD7ropVV xp0SBQHX+Eh+21PJTD9YqEBMp1jB4vtWBijPfoHou0L1q4e3cMTPnbiz3s1c42zKGVdw=; To: internals@lists.php.net References: <1681263.Ri4PIu1jiQ@vulcan> <1476841B-EEBA-4513-8DD8-7ACE1F662372@gmail.com> Message-ID: Date: Sun, 23 Sep 2018 22:16:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1476841B-EEBA-4513-8DD8-7ACE1F662372@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-AV-Check: Passed X-System-Sender: robert@korulczyk.pl Subject: Re: [PHP-DEV] [RFC] [VOTE] Typed properties v2 From: robert@korulczyk.pl (Robert Korulczyk) > Just to be sure you don’t miss the herd that this elephant is concealing: > > In addition, you *must* forbid unset() on those properties... Shouldn't we delegate the whole problem to object type resolving and make it more strict? Right now properties are not guaranteed at all - you can have `Foo` class with `$bar` property, but it does not mean that instance of `Foo` will actually have this property. The current implementation of typed properties seems to be pretty consistent with this. Type check gives you nothing as far as the object's properties are concerned. But if `$foo instanceof Foo` or `function (Foo $foo)` will test that `$foo`: 1. is an instance of `Foo`, 2. has all properties defined in `Foo`, 3. all typehinted properties are initialized, then the problem will basically disappear - you can protect yourself from propagating uninitialized object by typehints or type checks (which you would probably do anyway). And you still can create an uninitialized object for lazy initialization or whatever you want. -- Regards, Robert Korulczyk