On 6 September 2017 at 12:15, Rowan Collins <rowan.coll...@gmail.com> 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 <yohg...@ohgaki.net> 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.)

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to