Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110963 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 32133 invoked from network); 12 Jul 2020 13:27:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Jul 2020 13:27:20 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EDF801804A7 for ; Sun, 12 Jul 2020 05:19:13 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 12 Jul 2020 05:19:13 -0700 (PDT) Received: by mail-wm1-f47.google.com with SMTP id a6so11672795wmm.0 for ; Sun, 12 Jul 2020 05:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:from:message-id; bh=RyL5FN+IPqXhzN3JzIGLRHA2AK1Q6xKZSJmfOq07qBQ=; b=GsQ1xs9nWrR7nELh2/XqRXs1mioaT5rQ4O15tCTMbt5HWNdomPACfEqr8u1zldBVEU pqMiygMR4GhClcQ0G5t4jKlBUoe0dI/ytrcYTswhmgp4T740hKFpyHvaovAzHOWgvXE/ mY+WYRVeF+9UAhC+KxKQM2hgiMJIzDHWDtZprSEPKfLmMxjPgvD7XvLNmfj30siUM/R7 Vnq60Yf57cEI3+ihnZtNT8NjsDYVLDbvO5DgGOhRDodZ/43RqVYX4kCa5ipIjaU465ny exez9RJl1gl8WXZ/qxKvDGixq49NNA69t4M5FpKPCs1YkZqWzVfm05uMOQkLSqT/9f57 YzaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=RyL5FN+IPqXhzN3JzIGLRHA2AK1Q6xKZSJmfOq07qBQ=; b=TWOz4ORI3caKHHvLsK17/SsPcriMUsODWLoeLfPefciHqxYl6cYnD3klVB7yVtjcHM iUDCO/6ZZRK31our/qgv1je+jfQVBdx45QF0YCpndWiEvU46rJF/tztmLr+tjuzIUK8J 6d4cpDGL7ihMWGtFx0FZppX2GfDsxZvLR3FTWqCVvgrsnmlyUGdHtRr+Il2Ic6WBw+c/ s3zlqbN6+iRzaPn9p9z9gjxdHDxsr9U7edD8cBaWZszO3YNk7bcfZFhztww1w+MnQOSG 3K9d+7IutVFgGkY2DjJM/tAtbqwVX1tkfjxfxnu20DyIlfKakAT4hKoEKImGA/AyHHjW aSgg== X-Gm-Message-State: AOAM533ff6CqFABQxUGJ2ACX4AEVMCN4GJOaWooOTPPKvBH8OnIb1+aP Bjdx8//U4DkoYoQBlFp0DC5pNXmG X-Google-Smtp-Source: ABdhPJw076IuK7nRRsPH4DvdbvLlFRnOH8sP6SsVEBXVqLspPiaAMPN5gyMXLAnu+X5Hau/z5lNeSA== X-Received: by 2002:a1c:544f:: with SMTP id p15mr13847554wmi.84.1594556349748; Sun, 12 Jul 2020 05:19:09 -0700 (PDT) Received: from [192.168.0.12] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.gmail.com with ESMTPSA id u65sm18733327wmg.5.2020.07.12.05.19.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 Jul 2020 05:19:09 -0700 (PDT) Date: Sun, 12 Jul 2020 13:19:08 +0100 User-Agent: K-9 Mail for Android In-Reply-To: <173428d5cae.fd7702bf74344.4165657030995153344@manuelcanga.dev> References: <173428d5cae.fd7702bf74344.4165657030995153344@manuelcanga.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net Message-ID: <156CE5DB-BD37-4EA3-A1B3-5E88DA5E73BA@gmail.com> Subject: Re: [PHP-DEV] [VOTE] Named arguments From: rowan.collins@gmail.com (Rowan Tommins) On 12 July 2020 11:24:50 BST, Manuel Canga wrote: >4=2E Other option is creating a new function( not yet available in PHP ) >like: > >``` >array_check_scheme( array $array, array $scheme, bool $forced =3D false= =20 >): bool >``` The problem with this, whether built in or not, is that you have to expres= s everything with strings rather than keywords=2E That means, for instance,= that invalid values in the definitions themselves will only error at run-t= ime=2E The definitions also tend to get verbose pretty quickly=2E To make it concise and checked at compile-time, you need it to be a constr= uct that pairs identifiers to types without first representing them as stri= ngs, e=2Eg=2E to write `?string $foo =3D 'hello'` rather than `'foo' =3D> [= 'type'=3D>'string', 'nullable'=3D>true, 'default'=3D>'hello']`=2E It turns = out we already have a construct for doing that: function signatures=2E If the input is an actual array or object coming from "outside", you're pr= obably going to want a more extensible validation system anyway=2E Those ar= e really hard to design, and probably best left to userland where people ca= n choose the tradeoffs they prefer=2E Regards, --=20 Rowan Tommins [IMSoP]