Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101516 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55265 invoked from network); 3 Jan 2018 17:41:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Jan 2018 17:41:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=tendoaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tendoaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.174 as permitted sender) X-PHP-List-Original-Sender: tendoaki@gmail.com X-Host-Fingerprint: 209.85.161.174 mail-yw0-f174.google.com Received: from [209.85.161.174] ([209.85.161.174:36608] helo=mail-yw0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3B/22-23177-1C51D4A5 for ; Wed, 03 Jan 2018 12:41:22 -0500 Received: by mail-yw0-f174.google.com with SMTP id r205so821610ywb.3 for ; Wed, 03 Jan 2018 09:41:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=c8TGiRlnPMDbnUpsCZe7KEkicFPKFNdlkdqzgZYmnCw=; b=AW0pBAFOWN4ilk/eZG2ZbP1PC2eTNfXLuNLH3WiT2hkLvLOGDzbS73SmFC7SMIjo9m CGhJvxObXdTeitGL5IMbSipIxrZA7pKMsv6eGvLLKJVyMotKIF+3EzmiBW9OTUxjKKXg DHy5/Mqti93b5O2iprur9LTWO7DW1xWSimHRYpomcZNFCNAQG3afvA39n3Nc0zoBawy9 shsjhN4LDllcb87REPXh2r9M5rTIBPMWaQoXGr3zkQUbO2DQakvA6pXDqd3iRi50iglT Q4HMqrEcZnHY4lAs2jCxkLW+5VORe8+qZd5JC/0RaSu5xOpbY2GVkKX7jZ6W97VjBKVH 1fLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=c8TGiRlnPMDbnUpsCZe7KEkicFPKFNdlkdqzgZYmnCw=; b=Krn9IdlbsfXBAOf5pBXiL6C7gYbQ2KPTV7LVqL6w70jOjcaIdNGf+eu7dGOPg/wYNg QVjolhjs82pI9yh/X3jFRbo8U+hn2qeylvHl/GyBpfZ7i114zWnaWQdLSpu69m92aUJd xWe8b4WEjtvchpxrVQXtOe+BKhDkir7M4Ikk/RTzXnA0Ci7fwnWW20m+6a9yVyJ0luxp fefdTRKJzhvEq9CySubf/L4gA45JVo0PYMO81VLAi0R52HjldzZHV+02eXaCS6Q+4bE/ 4lKil/dy6lxdq35Rc8xh1bwydGbsINfSc2yj8TYWQWnw/0xVWOWiBq7XpQeZeYd2YkOz mQ3w== X-Gm-Message-State: AKGB3mJ/MiCmPOE8MeRjOLj/e7siuxuPOsfmMu9yso4ABr3wFymh7nGt uDdxXoYVDnSzL2oYsR3Y0MZYFH/yvgMCMEqvVLM= X-Google-Smtp-Source: ACJfBosrFLWmSkEKNca8M3vUu58jk2QSqo73rTZTdVYjJBHXouni4YXW1hE6QgycVTdrINJvjN8xdHWvhJdp5NkaSEo= X-Received: by 10.129.84.10 with SMTP id i10mr1958775ywb.97.1515001279358; Wed, 03 Jan 2018 09:41:19 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.201.7 with HTTP; Wed, 3 Jan 2018 09:41:19 -0800 (PST) In-Reply-To: References: Date: Wed, 3 Jan 2018 12:41:19 -0500 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="001a114d35dc172cd30561e2b9e0" Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Strong Typing Syntax From: tendoaki@gmail.com (Michael Morris) --001a114d35dc172cd30561e2b9e0 Content-Type: text/plain; charset="UTF-8" On Wed, Jan 3, 2018 at 12:10 PM, Andreas Hennings wrote: > This proposal contains some interesting ideas, which I see as separate: > 1. A syntax to declare the type of local variables. > 2. A syntax to declare the type of object properties. > 3. Preventing local variables, object properties and parameters to > change their type after initialization/declaration. > > For me the point 3 is the most interesting one. > I think the other points are already discussed elsewhere in some way, > although they are clearly related to 3. > > Point 3 would be a BC break, if we would introduce it for parameters. > Current behavior: https://3v4l.org/bjaLQ > > Local variables and object properties currently cannot be types, so > point 3 would not be a BC break for them, if we introduce it together > with 1 and 2. > But then we would have an inconsistency between parameters and local > vars / object properties. > > What we could do to avoid BC break is to introduce > declare(fixed_parameter_types=1) in addition to > declare(strict_types=1). > For local variables and object properties, the type would always be fixed. > But for parameters, it would only be fixed if the > declare(fixed_parameter_types=1) is active. > > Maybe to make it less verbose, we could say declare(strict_types=2), > which would mean the combination of both those things? > Or some other type of shortcut. > I think we will have to think about shortcuts like this if we > introduce more "modes" in the future. > > There will be occasions where having an unfixed variable alongside normal ones will be desirable. > > > Currently the var keyword is used to formally declare a variable. > > Are you talking about local variables? > In which PHP version? https://3v4l.org/o0PFg > > Sorry, I'm confusing PHP for JavaScript. I forgot that the var keyword was only used in PHP 4 for class members. For some reason my brain assumed it was usable in a local scope. > Afaik, currently var is only used for class/object properties from the > time when people did not declare the visibility as > public/protected/private. > > > > If no type is specified, then "mixed" should be assumed, not "scalar". > Assuming "scalar" would be a BC break, and it would be confusing. > > Ok. I'm misusing the term scalar to mean "variable who's type can be changed at will depending on context." Sorry. --001a114d35dc172cd30561e2b9e0--