Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109677 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 91665 invoked from network); 16 Apr 2020 11:59:47 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Apr 2020 11:59:47 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A46861801FD for ; Thu, 16 Apr 2020 03:29:56 -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,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.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 ; Thu, 16 Apr 2020 03:29:56 -0700 (PDT) Received: by mail-ot1-f45.google.com with SMTP id w12so2585363otm.13 for ; Thu, 16 Apr 2020 03:29:56 -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=YsaP0MTTRs0pSQOczaBSGPyIeOMa9TKrEByLWOLxobU=; b=m3i0NIx+28kJKu04DblC6dXQWzc8SLDzh24XTEa9SDHPtHQNPcr6N6uCY3qqIHMtOV AlFybos8bmr667PB/vfIM9mPmd4lCEdapu1PxYLL+04dGfYjVHJvhcKKd2G7Utr75gFs Qhi10PQW9lrHoRcnvJunoQRIt0dKiW8yoixccziUyV4gW7JioJLjumRPZJx1UlYPrA91 v71WfdaulnQDOjuE2tWwJEiJHWlr4S/IPcw+RLfVBI8Zkkw3cuKT/ChriwTBAlG9QxHU 27yWxN95a0o5vGl1Zz5MBqjmj+iZdp44uoW/AxhPpsWBMEm//TaJy4WD+MpMRz+GdbZh GOfw== 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=YsaP0MTTRs0pSQOczaBSGPyIeOMa9TKrEByLWOLxobU=; b=Jo1+Fflt11ePBu2YqzOmYYAOjHxDhZuValdoTSHUIEp7wOAAcVIN2SQFxixSU5nfEu V+JLKj1lK3aVoRRNkXWCTH3C3dBiKhbUPVesAltVfmA5miboOEjZxExVJMSoPknmJJSq b9V/zo4nP1YQqTEi3fJsZg7C9ph0D5o6lrWU9X+UcqPrcPC+fo1CHLkFKr93CfiGaUh8 Uh8n13hmC3aXklMEf2U1C0+ey6OWW26Jw9HAj9OZrygt/jMgn2I40p8PIldhj5uimj1v ElXKgKxgX4P5MCAE9o3Vw7kgw9PkYes13lcMm5dLYCBlEARpbnbKMs2oLD1/pg97CuEW aI+w== X-Gm-Message-State: AGi0PuaJ5Q4ru2L7A1x1OzKTZNTvUsHkUZTm/Mao1bPIgvrGDOPLJEb2 b2Dqxu/LySY+3pn+HwypGPj0P76Az8AnkLnZMRU= X-Google-Smtp-Source: APiQypKwzkfLZ25fFMiBs5mYMEM3eVwHdjvX1J8h+GikrJyn33gC46dABhTE39pNNQUa+a8dhP8JyGpiqJnu9vDK3kw= X-Received: by 2002:a05:6830:114e:: with SMTP id x14mr1327388otq.214.1587032992426; Thu, 16 Apr 2020 03:29:52 -0700 (PDT) MIME-Version: 1.0 References: <2b8e5da5-2f21-57a2-7e7d-243c686cc69d@web.de> In-Reply-To: <2b8e5da5-2f21-57a2-7e7d-243c686cc69d@web.de> Date: Thu, 16 Apr 2020 12:29:40 +0200 Message-ID: To: Enno Woortmann Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000c2b11005a365e97f" Subject: Re: [PHP-DEV] Type hints in array destructuring expressions From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --000000000000c2b11005a365e97f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Enno, czw., 16 kwi 2020 o 12:20 Enno Woortmann napisa=C5= =82(a): > Hi together, > > as the voting for the "Type casting in array destructuring expressions" > shows a clear direction to be declined (sad faces on my side, I really > would've liked it as a feature completion of the casting feature set > without the need for a really new syntax, as the parser also already > coverred it, but ok, time to continue :D ), combined with a strong > interest for the topic "type checks in array destructuring expressions" > (as well in the discussion as in the vote) I've set up a first draft of > an RFC covering this topic: > > https://wiki.php.net/rfc/typehint_array_desctructuring > > The discussion around the casting in array destructuring brought up the > idea to perform regular type checks in array destructuring expressions. > This RFC proposes a new syntax to type hint a variable inside an array > destructuring expression: > > $data =3D [42, 'Example', 2002]; > [int $id, string $data, int $year] =3D $data; > > 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); And then expect the $id to behave more like typed property with type guard. At least this is me what would expect from putting a type in from of variable name like in array destructuring example. Why? Cause it has a type constraint in from of variable name just like typed properties have. Cheers, Micha=C5=82 Brzuchalski --000000000000c2b11005a365e97f--