Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94836 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38263 invoked from network); 4 Aug 2016 21:04:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Aug 2016 21:04:29 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.48 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.48 mail-wm0-f48.google.com Received: from [74.125.82.48] ([74.125.82.48:38848] helo=mail-wm0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F7/70-33134-CDDA3A75 for ; Thu, 04 Aug 2016 17:04:29 -0400 Received: by mail-wm0-f48.google.com with SMTP id o80so9662149wme.1 for ; Thu, 04 Aug 2016 14:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=d95HdIY4QBp4blHQZOT9SULWZRRg2q0vZbsmng8uMN0=; b=FSJxixpLATbG79XxDT5+tJDg08tIKJ3co2Dgb9dtqr8dohNcFYVwe0P/e3WO5Ecgsf zaNxV9j/4Td6a/MNBtLOaPqdjM/HkOPQ3Rl8AvIkHY4/Bdn/lmhn26AgTPZ2PRvJVpkv V242tQLpIbgQpp5vmgrEguk1aSd1HRA9FMe4u4BT/WtmjXzKgLp5/zTReJIJUv84BGts MZ1IpWtIUasCIPy9HuQGr/WQ9T0y/0KhRl0rIRasAFbCZexYb9kXt51TUKoapB36eKO7 Je63os9Yvqgnn4QFrEk92pfjk+HpblDX32Z6fK5z/bU628hK+OpLSzi11r1Yh0uqhdWR oovw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=d95HdIY4QBp4blHQZOT9SULWZRRg2q0vZbsmng8uMN0=; b=kE4FxdJIZrs4y7ezt0yGTHCJkmKLDGbixlihHtcMymf2SkMx93lmdhBeIKwAjlloRw lYR6QCSiljmdHYIrgpeHXADIOaESG8/X2XtmL/p7DG1uD6wx7QOiOUEFZwHtmmCkRTnG ldVPqSwqO4uszFrGVyayNbwmGMWE6pQKx2t23DqpYsH6ludziwkH5N5brwpA9QSMDMJ2 CmobfE0wis4g19hF0bRE7jEDVdo34auV7zcIrBqQdtZANlcIGj6ZLeu+T/lVYv2NVX+9 gfT9F/BMjwXzvQ5kOdgdH7uID7Ju+R2BN7uDkWIbpLz8BaPsJQhAMQn+fcmVjaZPb8DS 288g== X-Gm-Message-State: AEkoouubMq4qZ1pR7wy2VRPwc00lJlTxwJt30wrUvsPwxyl0R2s+L7L9SxbXI9ZhuTVfjQ== X-Received: by 10.194.169.39 with SMTP id ab7mr77172250wjc.0.1470344665740; Thu, 04 Aug 2016 14:04:25 -0700 (PDT) Received: from [192.168.1.5] ([95.148.161.240]) by smtp.googlemail.com with ESMTPSA id d8sm5389248wmi.0.2016.08.04.14.04.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Aug 2016 14:04:25 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <27c5add4-2c4c-bab1-6ca7-9c191917dd0e@gmail.com> Date: Thu, 4 Aug 2016 22:04:16 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Adding validate_var_array()/validate_input_array() to which version? From: rowan.collins@gmail.com (Rowan Collins) Hi Yasuo, On 04/08/2016 20:29, Yasuo Ohgaki wrote: > One of my objective is following best practices. > Prefer exception over error is one of them. Although, I strongly suggest > to use exception for validation errors, I will have choices. Best practice is to use exceptions to indicate an error *inside* the function, i.e. something going wrong with the function itself. If I run (as a simplified example) validate_var('abc', FILTER_NUMERIC) that's not something going wrong inside validate_var(), so validate_var() shouldn't be throwing an exception, IMO. Now, the *reason* I'm calling validate_var may be that the function I'm writing will go wrong if the validation doesn't pass, but that's up to *me* to throw an exception: if ( validate_var($foo, FILTER_NUMERIC) ) { throw new InvalidArgumentException; } That said, in another message you explained that this isn't intended for "validation" in the sense of "form validation", but in a more restricted sense of "dangerous data"; I think the name misled me, and may mislead others, if that is the sole purpose of the function. I'm still not entirely convinced, though, that a boolean-returning function wouldn't be enough to fill both purposes. Regards, -- Rowan Collins [IMSoP]