Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109679 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 96266 invoked from network); 16 Apr 2020 12:18:40 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Apr 2020 12:18:40 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D5D131804C4 for ; Thu, 16 Apr 2020 03:48:49 -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-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (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:48:49 -0700 (PDT) Received: by mail-ot1-f54.google.com with SMTP id i22so2630279otp.12 for ; Thu, 16 Apr 2020 03:48:49 -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=rCbeP6PjJHn4qqzgLxJ+r/B9YiOx43o6foloxaXpk4c=; b=bby+L9cenozm6f5KZ8Kp2qADALAHrHyIJmgmldZwSXPOovhd12/Dtwmk8jp01TccGW 0Gn+s1GI2gBeo5p4VGSJc521U3pCpA0IZCR6Kh/GqZe3P+VIlRAZXOWtqUUKcByLHm/e zkcQ8NvsQfJ/Kc02XrxYjfYpxHPtfkLPV1Qbm25trpsgAMdunVjuJyIJO/FF8LZ1BxfE TpWRBcXXaznkGdtOvxK+asrCkD4LH7IgAZRLW6MB0dGZvobWHg6VC+5Ern9zHua0p3At nBy0RzrlC6nMNn/iFqqCTj04f2pk7w3LzBiM/lrPpyNeSppmdaR2QdFyxJV/ePbDaAa6 xqEA== 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=rCbeP6PjJHn4qqzgLxJ+r/B9YiOx43o6foloxaXpk4c=; b=GCDjnoFphpK2f6uW5lT2PpYzWCDT719g2NRxqHWcdlu5j+3Nngt6T4tNVSx76A63yU SR9aoC5m1X05rmwvG8USAOeatrRy8ObuvmSHa4CpTm9KmkpFS2HNR8OR/SaQ/iynvaq2 BSkf1YRvsypl2LXM7/U5tFZoWhU9z7QXF1AVHx76HdZypoj5zvJXB46HvwXzjtY5WjVi CBlkj6/VpDlul53QS6kqD9GPHWs/4Gnkb4JFavYNZYjWPmd7SmFz8rwsP8eU9OLboDH9 ji8IfF8cFAGrCFAkhI+ZxsIN6sxIh0fV0UG4rPgQm5djZOhlSYjAd1AlcGsEGH6b93w5 c37Q== X-Gm-Message-State: AGi0Pub08wxcEFyA95odjwiVQzUalZJqZRsRT+Ndl2Rq1sviziYR5/kF 96mHmkoidpkIEEjS1C55DwbxM3BZ/iT/MW4zu8k= X-Google-Smtp-Source: APiQypLRtrpptP8TSqtruMscT+pYY6XfeYjArG7idQTROSV4djBI7Ogu29jbI9bvvr1PGsYhG8iv7C9wJuPVsn+vVHg= X-Received: by 2002:a9d:19ca:: with SMTP id k68mr26685105otk.232.1587034127153; Thu, 16 Apr 2020 03:48:47 -0700 (PDT) MIME-Version: 1.0 References: <2b8e5da5-2f21-57a2-7e7d-243c686cc69d@web.de> In-Reply-To: Date: Thu, 16 Apr 2020 12:48:34 +0200 Message-ID: To: =?UTF-8?Q?Micha=C5=82_Brzuchalski?= Cc: Enno Woortmann , PHP Internals List Content-Type: multipart/alternative; boundary="000000000000653cd205a3662df2" Subject: Re: [PHP-DEV] Type hints in array destructuring expressions From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000653cd205a3662df2 Content-Type: text/plain; charset="UTF-8" > > 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 = $data['id']; > int $id = 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 slow 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 just explaining that a different expectation exists, and why) Nicolas --000000000000653cd205a3662df2--