Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109273 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70217 invoked from network); 24 Mar 2020 15:59:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 24 Mar 2020 15:59:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 17AF21801FD for ; Tue, 24 Mar 2020 07:24:02 -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-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 ; Tue, 24 Mar 2020 07:24:01 -0700 (PDT) Received: by mail-wr1-f45.google.com with SMTP id u10so1321057wro.7 for ; Tue, 24 Mar 2020 07:24:01 -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=BBqav7i+NCaTrea8h28aKU/pUuYXqAMWxQmO4+NyoWw=; b=DXAdFkKIchfPeKbwpdqH5irwFIfXeWiK+TaLox9BvgSvOU6+IEwKhfoQUboZ4rYFUh gEK2/MSADoOSDtxQpQasze6kNoxfvm7UF2zFZ6iEsGJveXL5oZoqTbF96mkSKq2tT1LT V6/uLnL6Ui6HncOdWW5p3i1g/YRD/qDxkBi8wMRfujgBMfFfq+vmJOfW7JBkMhtz7aQG pfQQq2EcWxBD3tYqVxXv9VQH27fTvFnrWT1p6dMFxSM63UIvx0y9AooAKLedo4aicqnJ Bkkz0UssC4rHwi5PKDHUc3ISA2n9haRdapcPkvGi53UaVEOyhdMl7Xfr0rvmkhlir653 lkfw== 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=BBqav7i+NCaTrea8h28aKU/pUuYXqAMWxQmO4+NyoWw=; b=EsCUqi/CuNZfXUpLRf6C6hFfZY9YliyQ8nU4v9RZ5ZfMiAi2llWBQCl02of4rjhGS5 h3M5UF2sOwCoNF2OQe0a4pscYtXmzAkPbJNwPPOspJVfym998fLjB5NJVa5ByXGVBGGb pMKBNr49+ZVk4mfT1y3MLgR3cRlbz+iMaBzygdfoNo9BkWQlyxTd36Dv3XQZMFGcluBo QtaLAP3MkjuGuUAU/ldhll9TbZSbDrDwK4Rb2lIPFRrF3csJAO7o5JHrebR/xYaZuWqe 3TT6duOK4keC9LgseM9c8x/qKIxSJRWzssgd1RKlgQ0+q3jc+q57FA2cNLHc8f3O0UK7 PcbA== X-Gm-Message-State: ANhLgQ10zOUkway+BYxQ/3J9GbVqBQW+pq9Nq1WO9gGvMf+bD3Jp5GS7 nYCDn5sdxJumj7qOfsUhcRE0WZ/8 X-Google-Smtp-Source: ADFU+vtEqrpN93mLesi+9A7Cf0yUWOYUgfxG0D3kPxIH5K4KgbDwB5WO6XBl/hrc6ziMLntegdCVZA== X-Received: by 2002:a5d:4091:: with SMTP id o17mr22489441wrp.254.1585059839668; Tue, 24 Mar 2020 07:23:59 -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 m12sm4376559wmi.3.2020.03.24.07.23.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Mar 2020 07:23:59 -0700 (PDT) Date: Tue, 24 Mar 2020 14:23:52 +0000 User-Agent: K-9 Mail for Android In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: internals@lists.php.net Message-ID: Subject: Re: [PHP-DEV] Type casting while array destructuring From: rowan.collins@gmail.com (Rowan Tommins) On 24 March 2020 13:32:35 GMT+00:00, Enno Woortmann wrote: > How about adding some syntactic sugar and >allow type casting inside the detructuring expression? > >$data =3D "foo:*:1023:1000::/home/foo:/bin/sh"; >[$user, $pass, (int) $uid, (int) $gid, $gecos, $home, $shell] =3D >explode(":", $data); On the one hand, this seems fairly straightforward, and although casts wou= ldn't normally appear on the left side of an expression, the intent is pret= ty clear=2E On the other hand, this is exactly the kind of thing where strict_types=3D= 1 makes things worse - you'll actually get *better* error output if you use= strict_types=3D0 and pass the string to a function marked as requiring int= =2E By forcing a cast, you're actually silencing the error, and turning all= unrecognised values to 0=2E If the desire is for stricter type handling, we probably need stricter cas= ts, perhaps using different syntax like (int!) rather than just more places= to put the existing ones=2E Regards, --=20 Rowan Tommins [IMSoP]