Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109681 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 330 invoked from network); 16 Apr 2020 12:30:28 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Apr 2020 12:30:28 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 321811804C3 for ; Thu, 16 Apr 2020 04:00:37 -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=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLY, HTML_MESSAGE,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-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) (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 ; Thu, 16 Apr 2020 04:00:36 -0700 (PDT) Received: by mail-oi1-f177.google.com with SMTP id r25so6359688oij.4 for ; Thu, 16 Apr 2020 04:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=yfIewworSeFN8rcyCV6ddxyZs8k/6u8d4SfFxByDlmY=; b=Wjue/ILF6itA6fEIEMwaqjL03f6pp31eSRrkPfOBUhJns5TsoQ46UMWurhz8cjh4FJ 8BbwDVf1osE/D1M8skcA/4pfID4aXrtBnuJJj7HO2dg0ZmJ+mlC40oL0CxkMpvM3/N6O 7hE/u9onB3nO43nQ+p+7JEAzZqu73maYyiMBx/acqFMkO0ZnKaPiC3jwRNCSC23Rvwl6 I5SIzL+VuPr5NHx9g2FaeaKvxPuMV2gcKRrvfKcT4thMRJv1IlPwUpkqu1Mu5cF12wZ/ Skqs6jv0wDblrsnzxqy3DPvhbvDh/u0iLDQ5jUM0r+TkdNLrXlJKFYmqBWVw2HeZqqjq 5VOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=yfIewworSeFN8rcyCV6ddxyZs8k/6u8d4SfFxByDlmY=; b=UfdW9Ceet7sLI5EnDuuvxmR0RcPf5GVIL48pJF1TdYyCFdom5eZE6pBSGWsjdWxkmd UV+YJXE2uQMNFulzZUHtTLMciotB4ocpIV5x9noRBYiIShDzGg5E7+qVAxumD936BSh1 K+rM/NcSH6G9Lcj9orrS+TDOEhefPAgDIdtvbQA2bIhSB9Lkfx6gru9rgND22aGSorXV rHSex68alSIYyYugayo0TkxLB2Hd0yH7V8MaNkicFQtGMhBaGRbf99BHbg/B8In9v/v7 AGm3Vhna8dc0uWnqnL6dbFVUfhl8T4XoWaSwF9fNA15e4+KTueaAI/y9b02kekGv7RET alBQ== X-Gm-Message-State: AGi0PuaQRzcHAN7hvZkJbicvW9L13WkYhqT1rZjHd1k4bTHV5OlVR0kb atUoRQRPxCqlbxH1KFqSsTw2lPM8XrDxslm7AIY= X-Google-Smtp-Source: APiQypI4vn1/iV1AlUGvwvE+HPt4J1SpIk6Ua9lk37Dv6/HWpkRG8qpaOC69vxsBy5ejoJO8X0gK+KkOVAX6JfLJxDA= X-Received: by 2002:a05:6808:485:: with SMTP id z5mr2390551oid.78.1587034836168; Thu, 16 Apr 2020 04:00:36 -0700 (PDT) MIME-Version: 1.0 References: <2b8e5da5-2f21-57a2-7e7d-243c686cc69d@web.de> In-Reply-To: Date: Thu, 16 Apr 2020 13:00:24 +0200 Message-ID: To: Nicolas Grekas Cc: Enno Woortmann , PHP Internals List Content-Type: multipart/alternative; boundary="000000000000a7f48e05a366576c" Subject: Re: [PHP-DEV] Type hints in array destructuring expressions From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --000000000000a7f48e05a366576c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Nicolas, czw., 16 kwi 2020 o 12:48 Nicolas Grekas napisa=C5=82(a): > > > https://wiki.php.net/rfc/typehint_array_desctructuring >> > > Thanks, Enno, I like it a lot! > I hope the implementation won't find any blocker. > > > >> I fear that if you go that path people would automatically expect it to = be >> possible to write: >> >> int $id =3D $data['id']; >> int $id =3D getIdFromData($data); >> > > That would be a nice addition I guess - maybe for a separate RFC to keep > the focus clear on this one. > > > >> And then expect the $id to behave more like typed property with type >> guard. >> > > I would not expect the type guard on my side, like function arguments > don't provide type guards and also because this is PHP: runtime checks sl= ow > down the engine. Thus I would expect this to be guarded by static type > analyzers for ppl who care (I'm not sure it matters personally, see SSA > transformations), and on assignation otherwise to balance perf vs runtime > overhead. (Note that the expectation you describe is a valid one, I'm jus= t > explaining that a different expectation exists, and why) > > Agree this would slow things down but if it could be potentially type checked on the assignment with type constraint in front of the variable name I think that would be a neat feature. So to work as a function parameter but not like a typed property. Cheers, Micha=C5=82 Brzuchalski --000000000000a7f48e05a366576c--