Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84309 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44729 invoked from network); 5 Mar 2015 00:51:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Mar 2015 00:51:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.192.49 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.192.49 mail-qg0-f49.google.com Received: from [209.85.192.49] ([209.85.192.49:45277] helo=mail-qg0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 13/9C-56703-AA8A7F45 for ; Wed, 04 Mar 2015 19:51:54 -0500 Received: by qgaj5 with SMTP id j5so2815169qga.12 for ; Wed, 04 Mar 2015 16:51:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=gIFkR21vRmI2aD5kgr6q0lCNN87NtwDQZinhpB5lKcU=; b=zNFUqimYtWn2PPMLK0P70iwoFB6wnz3whfgoIvKjr+UUrBaa2vbdRMEPwuzZvH1nqs CdzzE7YAIRfPMqmps7tZ1xqzb5o4p2JB0G5xg7SSfFgC5OUd8qjnWXypYS5Ak97RxzWx J0pKUMIkVjVzJ1n5vPFOv4BNYzpotmk5x1XF0BlNBcyAtsbaQ/HQsPCCIMrfwypaEej8 Wem8tG/k32AsHpnmfK5S0c1aqF+rnRi+QZM8tR2XEAOc9WBfdkEMPR8UhejpS6pzdxdO WvtfPbUdRTdl1ZjpNCDfDzAXIXO06cg+3wR3HxkLxtmeq0XpLMGumvdTSZ0ntKqDVrt7 8jgw== X-Received: by 10.140.28.36 with SMTP id 33mr9241182qgy.6.1425516711408; Wed, 04 Mar 2015 16:51:51 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.229.198.8 with HTTP; Wed, 4 Mar 2015 16:51:11 -0800 (PST) In-Reply-To: References: Date: Thu, 5 Mar 2015 09:51:11 +0900 X-Google-Sender-Auth: u5i32hYNTBZAN_Vd9-BsMqIdLws Message-ID: To: marcio3w@gmail.com Cc: PHP internals Content-Type: multipart/alternative; boundary=001a113a9a64347bfa05107ff92a Subject: Re: [PHP-DEV][RFC][DISCUSSION] Strict Argument Count From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a113a9a64347bfa05107ff92a Content-Type: text/plain; charset=UTF-8 Hi Marcio, On Thu, Mar 5, 2015 at 4:07 AM, Marcio Almada wrote: > 2015-03-03 16:48 GMT-03:00 Yasuo Ohgaki : > >> Hi Marcio, >> >> > I understand your reasons. Compatibility is important, but detecting >> function body contents and >> suppressing errors by engine is too hacky. Raising E_DEPRECATE/E_STRICT >> by function definition seems >> the way to go. IMO. >> >> > Just one correction, we are not "suppressing" the warning. It just emits > the warning conditionally and that's not hacky at all. We already have > other situations where warnings are emitted just when certain conditions > are met. > > >> [yohgaki@dev github-php-src]$ php -r 'function f(...$a) {var_dump($a);}; >> f(1,2,3);' >> array(3) { >> [0]=> >> int(1) >> [1]=> >> int(2) >> [2]=> >> int(3) >> } >> [yohgaki@dev github-php-src]$ php -r 'function f($a) {var_dump($a);}; >> f(1,2,3);' >> int(1) >> >> is current behavior. The latter would be >> >> [yohgaki@dev github-php-src]$ php -r 'function f($a) {var_dump($a);}; >> f(1,2,3);' >> Deprecated: Excessive argument for f() without "...", called in Command >> line code on line 1 and defined in Command line code on line 1 >> int(1) >> >> > Using only the function signatures, overlooking *func_get_args()*, would > be in practice an indirect deprecation of* func_get_args()* and that's > not negotiable at all, at least on this RFC. > > We simply can't do this now because it would be an enormous BC break and > PHP 5.5, which has no "first class" variadics, is still supported. I > understand the reasons you want to do it, but I think we should wait a bit > more before discussing a possible *func_get_args* deprecation (if it will > ever be deprecated). That's not the point addresses by this RFC. > I don't think we need to deprecate func_get_args(). We may have array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } "...$a" packs arguments. Using "..." as variable parameter indication may be allowed. Strictly speaking, it's not needed, though. > > >> User may have a lot of E_DEPRECATED errors anyway if strict scalar type >> hint passes. >> > > That's highly speculative. We don't even know if the proposal of scalar > typehints with BC breaks will ever get voted, neither if it will pass. It's > not a good idea to take decisions based upon that. Don't you think so? > It's related, but it's different issue. > > >> I like the idea. Please use function definition for errors. (E_DEPRECTED >> or E_STRICT whichever >> is suitable) >> >> > I'm proposing a warning because currently PHP internal functions already > use a warning to indicate wrong argument count. Using E_STRICT or whichever > would look inconsistent IMMO at a first sight. But I think that E_STRICT || > E_WARNING || E_DEPRECATED is a very debatable topic > I don't care much about error types, because I change code so that any errors are not raised anyway. E_WARNING in this case makes sense because users made obvious errors. I understand you would like to address errors in older code with compiler change. We don't have to care much for older broken code. IMO. I understand importance of argument count check. Your wordpress research clearly shows that we must raise error for wrong number of arguments. Looking into function body and checking certain function existence seems just too much for a language. However, I don't have too strong opinion for this. I would like to have comments from engine developers. Any thoughts? Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a113a9a64347bfa05107ff92a--