Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100409 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40869 invoked from network); 6 Sep 2017 11:38:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Sep 2017 11:38:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=danack@basereality.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=danack@basereality.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain basereality.com from 209.85.192.180 cause and error) X-PHP-List-Original-Sender: danack@basereality.com X-Host-Fingerprint: 209.85.192.180 mail-pf0-f180.google.com Received: from [209.85.192.180] ([209.85.192.180:35708] helo=mail-pf0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 39/53-10715-E1EDFA95 for ; Wed, 06 Sep 2017 07:38:07 -0400 Received: by mail-pf0-f180.google.com with SMTP id g13so12407755pfm.2 for ; Wed, 06 Sep 2017 04:38:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=aCzlIJz0Z8TME+0BgXkMMuwwoV686rTleSFKSg4V1X4=; b=RSrShy9LbNu3GZ9V/3Jb8Ans22bnpsCHWMkYXMxQAuVq+h3SI7Y/8pqKb986Lpa8wF zl2FRtz/uCAH98VcqCFGdVrsegplkxLdkPfrKg+wxOJOcn76BPFoCVUsQ0zLgY9MBYXK cS57rRdlj1LgjHB+7thdW0uOBuTf1SgnY7ARXJCXDMEHxOUkdQcJacJbyIq9kHW6zcHH lLH5f0KwrgPTT1aLcOoYVJJzuD8mQb9GO5bcCJjKY+4h2k68OBchRY8u1CPnVwTx/bu/ qzvkwG64h54o1oSmK9M36bKXcfbIc8vs0DGZobHfghV5dfpe5C3WbIDjV1izWt90kRBR UIBg== 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:cc; bh=aCzlIJz0Z8TME+0BgXkMMuwwoV686rTleSFKSg4V1X4=; b=QWXwh7aDCVYuuH93YOqRo9t4nFomKpgJfFaveQnGYastTRSBQw/xHsUXw6V12i41y5 bmvk8ut8kkNYzdjGDea5eDlgTvtrHjpu5kL49xcMsNuduNaVhxKaIzzRagbQiFmHV2jK DfGNoJlrKiyAP3lCVzmSArtz0aACCMw7w55Ty8zAJVY6zg2zDQATizOvpdFz+Ytx8s36 QZw2AS4g5GCiXu1DhAvxPgBGlZhKtFYFMsumJG4ZqgVEE3NJuwWT8tBS88UReqZQ8y+y Zt76IV3ucEqkxRrU1ErHQdcu5iqY6IXkhY4djJPEBgzSasBnFeLVUaDfA8NAdoQKxtTr qnww== X-Gm-Message-State: AHPjjUgXWWVbTwSuwg6//2MRnWrCS8joVnPNx1i6y9etFWlyB5hU8JBn 1jQDCGYUy5qnUB/GOwKPrGKs5vZz7IJyt2rm3Q== X-Google-Smtp-Source: ADKCNb4otOTRIE/M6VTJ/lC7PqocpKZUoppPs73bXoZB/jnXzgT7qRe7Va44hnqXWhsm2BGmhv9h5DawpFu3kps42c8= X-Received: by 10.84.178.129 with SMTP id z1mr8172909plb.100.1504697884485; Wed, 06 Sep 2017 04:38:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.180.133 with HTTP; Wed, 6 Sep 2017 04:38:03 -0700 (PDT) X-Originating-IP: [81.143.203.71] In-Reply-To: References: <0C7F986C-B0BC-4315-98ED-B4FD003B9399@gmail.com> <2a4491b4-e6f5-4297-beec-363f373a93e6@lsces.co.uk> <3f8be7b1-0e59-21c6-4fe8-8299b2c05645@rhsoft.net> <6ba62d62-f1ab-9e7b-93f0-a1a9238c47a6@lsces.co.uk> <0db9cfa3-2b31-ee41-713c-889b7cc06406@lsces.co.uk> Date: Wed, 6 Sep 2017 12:38:03 +0100 Message-ID: To: Rowan Collins Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] A validator module for PHP7 From: danack@basereality.com (Dan Ackroyd) On 6 September 2017 at 12:15, Rowan Collins wrote: > If you have suggestions for how the format should look Don't use a format. Just write code - see below. > Which is why Yasuo and I have both suggested we work together If you're going to work together and continue the conversation, please can you move this conversation elsewhere? It doesn't appear to be actually anything to do with PHP internals. On 4 September 2017 at 07:33, Yasuo Ohgaki wrote: > > Since I didn't get much feedbacks during the RFC discussion, I cannot tell > what part is disliked. Yes you did. You got feedback during the discussion and also during the vote. For example: http://news.php.net/php.internals/95164 However you continually choose to ignore that feedback. I will attempt once more, to get the main point through to you. Perhaps a small amount of repetition, will get it through: This type of library should be done in PHP, not in C. This type of library should be done in PHP, not in C. This type of library should be done in PHP, not in C. This type of library should be done in PHP, not in C. This type of library should be done in PHP, not in C. This type of library should be done in PHP, not in C. This type of library should be done in PHP, not in C. This type of library should be done in PHP, not in C. This type of library should be done in PHP, not in C. This type of library should be done in PHP, not in C. This type of library should be done in PHP, not in C. cheers Dan Ack function validateOrderAmount($value) : int { $count = preg_match("/[^0-9]*/", $value); if ($count) { throw new InvalidOrderAmount("The order value must contain only digits."); } $value = intval($value); if ($value < 1) { throw new InvalidOrderAmount("The order value must be one or more."); } if ($value >= MAX_ORDER_AMOUNT) { throw new InvalidOrderAmount( "Order value to big. Maximum allowed value is ".MAX_ORDER_AMOUNT ); } return $value; } (i'd probably recommend not using exceptions, but instead return [$valid, $value] to allow validating multiple items without having to use exceptions for flow control.)