Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:109727 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 70016 invoked from network); 20 Apr 2020 18:30:40 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Apr 2020 18:30:40 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DC4EF1804F8 for ; Mon, 20 Apr 2020 10:01:52 -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_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-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.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 ; Mon, 20 Apr 2020 10:01:49 -0700 (PDT) Received: by mail-qk1-f177.google.com with SMTP id s63so11416163qke.4 for ; Mon, 20 Apr 2020 10:01: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=Q8rBVwYmoW1pl0YdLSOhn5Hva1Pc2p8JYy4mkEceFt8=; b=bAn4ob9M72PZdHzZeTfIpRq48bSCeO37Rz+HraBeEzKmd16TnGgX3SaAhocMWKc4FG 1fgMLGsOFpErA7I9MRYbRPagC7hPGWcixaCHpTkFRSQCpeJULaddCfHSRM0vETlg2Qhk PUoCo0s77BkbD0/YsF3AbhSU+yTJdxBRjA43vfSHMV2A8WBzmh8ZPcN+8hpao8nZZ5ss hZNyamagr8k9/vqM47Rl1iCWZ5uwKxPkFa2ty1g447oM1d5MlC2KmbitK34KriB2YWm2 mN5wXI2qPJ29LZfmfNptFcWkckaI0qgA1DaDLrsYKQkps/y0IEeX4DNp2IuEJvfZ06C/ nOfA== 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=Q8rBVwYmoW1pl0YdLSOhn5Hva1Pc2p8JYy4mkEceFt8=; b=QEnZ1yxO/JM0Yd+O666fKRJQ1VhIe1RF1+mxhVTpG2/5V2LRvpacWnze99ROZsBNXo WGGv2V3KSyX508RKz4lH07nBDNPkTt4N5ZEqCT0MCIdS7vkM2SZqt5bkl82fKGGRttBV VrleqrilW5PvLvt9igmWm5SgjB6c/DvEDeMJjJh6JN/4YyqUyhTvuXEY1ykzm4LmDTt9 wHAHf9bHmbx75vBFhgcGgsxCBX5r8meaAz+GeExZPsz6tgjATjEQA3E87RPJwlcDI/oT zg0u9R31qMJopWQgv55xV3mowuV+h2WZXpn0cs32vHFMEF45VYrI2rcOGEy0S9PPri6f JmOw== X-Gm-Message-State: AGi0PuZ1LqTkP1OZ/0J8FvWUqXLK4R69Fy25X146jmdzpKe8u4cGHgGV E1VovMUc7Iglipv/ae3yQ6TFGWtVPaT3TAAalNc= X-Google-Smtp-Source: APiQypJv9BJPHFV3zc5R1uo62UTdYhMEhLoMcIbIRDHhHdxkG7QUHvzHuLGO9dactgJApYOX9EFQoP7uoSgAjw+K8YQ= X-Received: by 2002:a37:78c1:: with SMTP id t184mr16918735qkc.213.1587402108649; Mon, 20 Apr 2020 10:01:48 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 20 Apr 2020 19:01:37 +0200 Message-ID: To: Guilliam Xavier Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="000000000000cd5f5d05a3bbdab0" Subject: Re: [PHP-DEV] [RFC] Mixed type From: albertcasademont@gmail.com (Albert Casademont) --000000000000cd5f5d05a3bbdab0 Content-Type: text/plain; charset="UTF-8" As Larry was asking for an example. The ParameterBag::get() function from Symfony (and others) that allows you to fetch request params, for example. That's a mixed type that could return different values, depending on your request body. Yes, I can type for all possible scalar values + null + array, but that's a bit of a PITA and phpstan would complain nonetheless, as the return type of theParameterBag ::get() function is "mixed" and we can't change that. Right now we're annotating "mixed" with a docblock. So yes, a "mixed" type is greatly appreciated when dealing with user input. Thanks! On Mon, Apr 20, 2020 at 6:41 PM Guilliam Xavier wrote: > On Mon, Apr 20, 2020 at 5:17 PM Larry Garfield > wrote: > > > > With union types and stringable already on the way, I'm not sure what > other non-hypothetical use cases would still be that fugly that you'd now > need to fall back to `mixed`. > > For instance: > - the parameter of [a wrapper around] gettype() or an is_* function > - the return of [a generic implementation of] > ArrayAccess::offsetGet() or Iterator::current(), or of a userland > array_value_first() or array_value_last() function > > To me, especially the return type declaration can be useful to ensure > that [every code path of] the implementation returns a value. > > -- > Guilliam Xavier > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --000000000000cd5f5d05a3bbdab0--