Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:96902 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70572 invoked from network); 15 Nov 2016 23:44:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Nov 2016 23:44:39 -0000 Authentication-Results: pb1.pair.com header.from=tendoaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tendoaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.48 as permitted sender) X-PHP-List-Original-Sender: tendoaki@gmail.com X-Host-Fingerprint: 209.85.213.48 mail-vk0-f48.google.com Received: from [209.85.213.48] ([209.85.213.48:33356] helo=mail-vk0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A4/57-05303-7ED9B285 for ; Tue, 15 Nov 2016 18:44:39 -0500 Received: by mail-vk0-f48.google.com with SMTP id 137so102473218vkl.0 for ; Tue, 15 Nov 2016 15:44:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to; bh=SWe6iFsjEUnKIRAMu2KgqA5TboWz47LkGnmcN+0iy/s=; b=Q2m3cAmYUyr92LYL64igfOzu0VDoiaMydFYqIQvxfctTiMbXQbaDaees28hAdzHH2k rVRe/6lWKgOQxexkzHCsokNsLi2eIxTBczsUH1XKs76YIwo44ht/p3XO86ARgqdSyhDO /MdKr44KRRyql9HljB1Ze5XItcXfZNDnDTI50I3dfIDnOFRQ7rP6bwMfyZrN42QMb7c+ O54TdrOCR75AKHAZWy/wdTCpFDrSeF6DIgNwoThfZ4D7+STEBxll/6m2PW1CbtgBZAOZ xLiIDIpIMKWnHAxa70OXD/Bze5i5tz/kbmzmgpRogmtdL+8YRlETpgCcjkkW3F2A8fZo XdOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=SWe6iFsjEUnKIRAMu2KgqA5TboWz47LkGnmcN+0iy/s=; b=P2jZlA1Nl9MnM3Y7W80fXgMtePULJnyGBM/Aq6xFCgct3Sk/pULqXy8rRUzVjKudxA rEZddttiQngVqDPmxWDCGTYMALd+KiBLOeocae3gY7SIsfDGgZNfhSR/6Rj8H16mYA+t HxgX6C/zZpfn4xPnHuEzAxVaBc7TT/KZ6tIOKHs+VnY1Vjk+o40NxcICGt6Qpqdnn4RX OPnqLb0ra5NXy0cUCKj6RhVAOAqBfOo4iqRMHwakRmYrtnjygXWHrbUHd5v3ECoGNr1X q6VuTYz3yist7r+Jn+pexIrA2ntphB705rC8PuqA24uqtxj+kKt8dzmOMRY5f1I558mI LuQw== X-Gm-Message-State: ABUngvds1wOneUTa/8A1l5JMW+N2GKHDKy/tX7tzykEKe7ZXEPMVpVR4ahFRvX+bg47AugNYnKs4S4TyNVANfQ== X-Received: by 10.31.108.144 with SMTP id j16mr12493067vki.93.1479253476385; Tue, 15 Nov 2016 15:44:36 -0800 (PST) MIME-Version: 1.0 Date: Tue, 15 Nov 2016 23:44:25 +0000 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=001a11478b70fe27aa05415f893d Subject: [PHP-DEV] Type locked variables From: tendoaki@gmail.com (Michael Morris) --001a11478b70fe27aa05415f893d Content-Type: text/plain; charset=UTF-8 Perhaps it's time to revisit the idea of allowing variables to have their types locked down. The keywords needed are already reserved. So... string $a = "hello"; int $b = 5; Once declared this way the variable's type won't change unless it gets unset. In normal mode PHP will coerce any assignment to the variable to the desired type. If declare strict types is on then assigning the wrong type to a variable would raise a type error. Note this would simplify one of the use cases of setters - insuring the class member is of a valid type. The idea of function overloading reminded me of this. I'd consider being able to do this sort of type lockdown to be prerequisite to having overloaded functions. Since this approach is entirely opt in I don't think it would make the language harder to learn. --001a11478b70fe27aa05415f893d--