Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93514 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99367 invoked from network); 25 May 2016 16:21:34 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 May 2016 16:21:34 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.162 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.162 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.162] ([81.169.146.162:13964] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/E3-14311-C01D5475 for ; Wed, 25 May 2016 12:21:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1464193290; l=5799; s=domk; d=kelunik.com; h=Content-Type:Cc:To:From:Subject:Date:References:In-Reply-To: MIME-Version; bh=kbsJQEWRTSxHcx19hia+JzIV5ro9eyQBJQx0rCVFG88=; b=Ps5AyHkNB+dr8YKgoqmbK0pAHMK3l69NJy2g+1Hzb3h8ByiOhbXEg+W9uirdVuI94IJ Tu1d+cSyLrPHcuWqqkvAf+4xRfszYMTySqSU7g5DZrjCiWaM6jEo8EMlxiFbrMb8Y5Dre mOgmxtwYNALCSutmo+TwfyGRp286XMeaFBU= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLGvomb4bl9EfHtOnA6 X-RZG-CLASS-ID: mo00 Received: from mail-wm0-f53.google.com ([74.125.82.53]) by smtp.strato.de (RZmta 37.27 AUTH) with ESMTPSA id L0747cs4PGLUokS (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp384r1 with 384 ECDH bits, eq. 7680 bits RSA)) (Client did not present a certificate) for ; Wed, 25 May 2016 18:21:30 +0200 (CEST) Received: by mail-wm0-f53.google.com with SMTP id z87so69174093wmh.0 for ; Wed, 25 May 2016 09:21:29 -0700 (PDT) X-Gm-Message-State: ALyK8tKR20HcYFcxpdL9jZKgFmB4a4J7Y3tIXmS7ZO0j4c9zYKzlPqpcw7YoGeVnjNqm3Q7S3px6NwR/nLlEkw== MIME-Version: 1.0 X-Received: by 10.194.62.99 with SMTP id x3mr4851689wjr.128.1464193289864; Wed, 25 May 2016 09:21:29 -0700 (PDT) Received: by 10.28.53.132 with HTTP; Wed, 25 May 2016 09:21:29 -0700 (PDT) In-Reply-To: <7B.12.14311.F79C5475@pb1.pair.com> References: <7B.12.14311.F79C5475@pb1.pair.com> Date: Wed, 25 May 2016 18:21:29 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Andrea Faulds Cc: PHP Internals Content-Type: multipart/alternative; boundary=047d7b86db22ecd2720533ad1030 Subject: Re: [PHP-DEV] [RFC][Vote] Typed Properties From: me@kelunik.com (Niklas Keller) --047d7b86db22ecd2720533ad1030 Content-Type: text/plain; charset=UTF-8 > > Hi Niklas, > > Niklas Keller wrote: > >> >> I disagree here. Properties are always null by default. The current patch >> disallows >> access to uninitialized variables only if they're not nullable, since null >> isn't a valid value then. >> >> I don't think having to explicitly set them to null is the think we want. >> And it's not what I'd expect given the current system. >> > > PHP's existing untyped properties are implicitly initialised to null, and > so yes, we would essentially only be copying our existing behaviour. > > However, I think it is worth asking whether our existing behaviour is > useful before we preserve it here. From my perspective, it is unhelpful > that PHP does not warn you about using properties you haven't initialised, > and this applies to both typed and untyped properties. In some cases (like > in my linked list example in a previous email), null might be a meaningful > value and worth distinguishing from a property not having being initialised > yet. > Null shouldn't have any meaning apart from "not set". It should never be a meaningful value. > We can't change the behaviour of our existing untyped properties (or at > least, that's beyond the scope of this RFC), but we could choose the > behaviour we find more useful for our typed properties. > > Consider that we did something like this for parameters. Not providing an > untyped parameter gives an E_WARNING: > > $ php -r 'function foo($a) {} foo();' > PHP Warning: Missing argument 1 for foo(), called in Command line code on > line 1 and defined in Command line code on line 1 > > But not providing a typed parameter gives a TypeError: > > $ php -r 'function foo(int $a) {} foo();' > PHP Fatal error: Uncaught TypeError: Argument 1 passed to foo() must be > of the type integer, none given, called in Command line code on line 1 and > defined in Command line code:1 > Stack trace: > #0 Command line code(1): foo() > #1 {main} > thrown in Command line code on line 1 > > So there's a precedent for applying stricter rules when type declarations > are used. > > Thanks! > > > -- > Andrea Faulds > https://ajf.me/ > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --047d7b86db22ecd2720533ad1030--