Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102846 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 83754 invoked from network); 16 Jul 2018 11:50:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2018 11:50:58 -0000 Authentication-Results: pb1.pair.com header.from=lester@lsces.co.uk; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=lester@lsces.co.uk; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain lsces.co.uk designates 185.153.204.204 as permitted sender) X-PHP-List-Original-Sender: lester@lsces.co.uk X-Host-Fingerprint: 185.153.204.204 mail4.serversure.net Linux 2.6 Received: from [185.153.204.204] ([185.153.204.204:56792] helo=mail4.serversure.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 3A/F9-39793-1A68C4B5 for ; Mon, 16 Jul 2018 07:50:57 -0400 Received: (qmail 32648 invoked by uid 89); 16 Jul 2018 11:50:54 -0000 Received: by simscan 1.3.1 ppid: 32640, pid: 32645, t: 0.1014s scanners: attach: 1.3.1 clamav: 0.96/m:52/d:10677 Received: from unknown (HELO ?10.0.0.126?) (lester@lsces.co.uk@81.138.11.136) by mail4.serversure.net with ESMTPA; 16 Jul 2018 11:50:54 -0000 To: internals@lists.php.net References: Message-ID: <6239bb14-4cd3-14cf-3d44-64175f24c832@lsces.co.uk> Date: Mon, 16 Jul 2018 12:50:53 +0100 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: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] Optional typehint check for parameters From: lester@lsces.co.uk (Lester Caine) On 16/07/18 12:14, Zeljko Mitic wrote: > But please, do keep in mind that I would like to have this feature as > optional. The problem with most of these 'improvements' to PHP is that the case is always made that 'you do not have to use it' and this is yet another load on the code base that 'you do not have to use'. However SOMEONE will come up with a use in a library that means one has little option but to have to use it and switching off would break that. As Yasuo has said, there are other ways of doing the same thing, and moving the 'problem' over to the IDE allows a LOT more flexibility in doing this sort of code management. The fact that once added, typehint is then a done deal, other areas will also be under pressure to enforce typing and we are stuck with one sides restricted view of how it should work. EVERY variable has a range of limitations and simply enforcing a 'number' when it also needs to be tested for size STILL needs the docblock comments to provide THAT information. Since most processing starts with text strings, enforcing binary data rules already needs some means of converting the input to binary and so is it really so bad to pass the raw variable and test that it is in the correct range within the function ... and PROPERLY handle an invalid input within the proper program flow rather than kicking it out to some other part of the code. Adding a valid default replacing the duff entry may be the correct response. Having to handle all of that BEFORE calling the function is simply the wrong way of programming! Switches to control what features are enablled may no longer be politically correct, but not providing options for some of these 'extras' is just going to increase the pressure on not upgrading and nothing I am seeing for PHP7.3 gives me any reason to need to worry about using it at all ... typehints are certainly an extra negative to changing ... 7.0.x is stable on my LTS platform, so I'll stay on that ... -- Lester Caine - G8HFL ----------------------------- Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk