Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114641 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 1444 invoked from network); 27 May 2021 13:44:05 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 May 2021 13:44:05 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CFD20180211 for ; Thu, 27 May 2021 06:55:51 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 27 May 2021 06:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1622123749; bh=mCEM25XgfHTGCmSdZ20UJLJ8knMY07i9mMscxn3VTaE=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=Jpg5YyTjafnF4GdLiiIHppBWzcCJWEaWQpneaihGaFB0JWSWbPygo7AhMU5UKxN02 uDBql6ZXmZCSe4U9jjOCmUc4tY3MCGzpBMO9H6RV9INcWlDCf4cCAke6OEyayRGvw7 8ZN3h8JCqK308iceR2zRrc61Zq8+JbOIAunJJHI0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.120] ([24.134.51.41]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N63Vi-1lNzKv1rD6-016Q4H for ; Thu, 27 May 2021 15:55:49 +0200 To: internals@lists.php.net References: Message-ID: <319c4288-5934-b218-d6eb-0b787a2cdef1@gmx.net> Date: Thu, 27 May 2021 15:55:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Provags-ID: V03:K1:McRBzRyRyReCJc3YgMrg4gs4rRbgtLcqOKRAYYLuhzcyCTVSjuF 1yNoYw9ZMaE7vz2CtXr7vA8Ol3vaQwOaVlS5kReDwKxfMBcn/9VDn8p7c3qraYG8+ECBliI DlWjG1rIk6JxwQT1p7RhjkwFwhdI70D9NHv2Q3x77oVpW7e0G+Ph5V5Nnv8a0soIMC9Jht8 SOA8Z4Bs/GT7leOBr7+sA== X-UI-Out-Filterresults: notjunk:1;V03:K0:raBkiZQbsis=:Ctv+VvfJBSKXQjsSPfRJFf Xm6r6BsVT6gVE4rYxpsxUzzrJr7wV7ZfeOA9L26/MYVwqb3xvDzDKyxEBr2iBoI9KGv+829o0 JFKsY7LyxeF39b1r/4/oQ9JxVgXFPxwfjOqA+FXzAL0Kkdd6XsMspeK1M1xFV6+sQmfKaseYz d3pnnD+IZt3Vsp9d6qXsqXnsADKEprcpXwj2lYPEZhdS+pn8T8VoH40C0Ays5+pWQJ+kttbpL dk5YaiNOLNjfhvVagf9GilneMEnCGXbhMeLQEBMsJ6TcaNBgq835oWxjV+JezhsYgZTYyIhjp 7bwCdOVAC3yo3epdyZCOUqJuY0m/n0RzZP70+wk1U5na6d4DWogWfa22yiEF00cHT3boUPMWB 6wDuGwdPXbMa9asAvpdLguJmTMXQkL8R0P0xgMbz3aZVgHf/7c/8lKaXbpPoxtYrB1yEmshPu BOeR5lRUd4KEQTGck/rbBytR0ekhSkBCBGb6t2Mhd2KI+OWkliwvyECA+1tH0GpegQhdgl1Cf LT0XU2gRF0bDHUIATUzt1A8qeqL3w7dOpFvHRWCbcWDOQYOlcl+79fx9muoyhpiMcvzjHTZUF Q5bmZcEOEj7SD/6Cb1N4Mkn7BCWk7nYjzgsS3whSspQBCX4CXFb2Z7alcJScKQdbQwUdCnluS GL6qFT8qqzsRwwkc7I2I1oxX5eZMHcHNbTf9MPin2cJ/1piajMvfCQmhmBaP+RkThpkcm+VUs bghv4d7FlMmORIwT6fFs1aoWa00nw7krnTaQwhhiS8o88pMUjXEIpyxdlIIviLZ5FQnWf+5zL rGSx3JV87FVOl7X/kifJoQNoIsWId67aYMe4M4thzs9T1/074z75pqWV6nD8c0BlvMMTEgjnD gaqy4lZYJk5hwkcAumSLIUp+y8C2WvJZQWQumYMNSqqnTJeZyqvMoEi9WZVVGkdfykrn47Vmc X8jKkRxUyIaZxEPJy+ynggkyjfNiSxRJ6jlLHEWZS8L8099OTL0JD1R+alIlSlpCtGODtoFgP ChZHBuiqVDTFcJWbqVrjso9GGncH/ju+7TzerS+4vg4zOKhQPRyRNS9EzK9zwHPSi+wEfXDrA i3CnPJWIVvCQvrshGuqXnwNm4w4NDhWRZ1x Subject: Re: [PHP-DEV] Consensus Gathering: is_initialized From: a.leathley@gmx.net (Andreas Leathley) On 26.05.21 12:13, Joe Watkins wrote: > Not absolutely convinced that it's a good idea, I asked Nikita to review= , > and he's unconvinced also and suggested a discussion should be started. > > You can read both of our thoughts about it on the PR. > > What I'm looking for now, is reasons that we are wrong - good use cases > that aren't born from code that is doing bad things ... > > Equally if you think this is really bad even if the reason has already b= een > mentioned, please make noise. I like it because it is very clear and takes into account the current scope. The alternatives are more messy: - When using "isset" on class properties, it is not obvious if you are checking for initialized state or for null, as it does both - When using reflection, scope does not matter (and you have to explicitely set a property to accessible for private properties) While it is not common that I need to check if a property is initialized, I do think there should be a straightforward way to do it. Setting properties through a constructor is not the only way of initializing parts of a class - some use cases were already brought up, like caching or lazy loading. Also, is_initialized cannot be done in userland, as passing an unitialized property to a function already leads to an error, so every way of checking now is a workaround that cannot be made clearer for the reader of the code. I would prefer it if it also worked for untyped properties, just to be consistent. Static analyzers would also have a much easier time understanding the code compared to now. When using isset on a non-nullable property a static analyzer would rightfully complain that the property is not nullable, as it assumes you are checking for null, not for uninitialized - isset in this case is abused to check for uninitialized, hiding the actual intent. Not sure how good static analyzers are at understanding the reflection code, but is_initialized would make things clearer for both humans and analyzers.