Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:107304 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 62901 invoked from network); 23 Sep 2019 22:36:05 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 23 Sep 2019 22:36:05 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 8CEEE2CC1C2 for ; Mon, 23 Sep 2019 13:14:48 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Mon, 23 Sep 2019 13:14:48 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id u8so15366138iom.5 for ; Mon, 23 Sep 2019 13:14:48 -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=8g5WFmBE0FZ6zW2rGXbgDz0Wb1JQssnT53zo1Ckmn4k=; b=OiCzF7yOyCh8sLl5xpXfvUUv4IV/6VAFteulxgbIn/+n2KPJsOnzBSKTtY5nNJ6wnD dzRAP7ucPmfI16Bwgmjfb1R/0VxfDesroHyf5ijkI9yHxh6KZolZl/lIo5SUDvq/1s4B 11b9kabAemQBzXKf7WUaZVafUANuFD+lAl4zLER9DYDUEgDBwF27oD3VtBKvSAn3ED4C /Xms7XArWTjFlROp+X+RGMIW1Ivey7pgQcZlHIciVsUyDr/mg/bkVbQHCw4nx19ALfiN pshSeDAIaZf2tbLuFIOu00YwoPIuhtsVIfg0jMMMcTK84NHnFaBwMRrG700JbMPTrnyY fuhA== 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=8g5WFmBE0FZ6zW2rGXbgDz0Wb1JQssnT53zo1Ckmn4k=; b=JSBWrWRfOufF+dxDPhZgFaD6ee4cBAGVWevsfkgkCqYAmGI4f6N84LRg0sHR07IXPa EgTkx1z6t5kTetdb5SoAe4sshlH5wCczuj+A9q8xU3ZZgrpJPoo9Sw0Nwtoe3oFxLGwb dZ7YDuoPbAw8wAewDFP8ngtsa58a1knQvbuDu8ZoDWBgE4NTE1Q3YVb6HtTw4/fPuhOz 5lPUaHsxK4FC6VvMyh5OZds4WMRX7LiNBPgTtKMK1eDPSeVt3BmWphlAaS9YHvivHgiz iOm4sIrv2xjhA9e0dovKLg52br8u1nPumtk3J0s1WRsOwNf7zsnZHGuAwLSds+AR735X UlQA== X-Gm-Message-State: APjAAAW3C27dumRzJ5Qtc+jdIC7W0B6tDPp9JenLnrhFHz6+pOVWHWQZ I840jZviH0RLDfyRoMJw1el/m3BJlKA505BB/Tk= X-Google-Smtp-Source: APXvYqy0DjE+hsPzZOwpVKJxWeFHB6fYPCubJsni/LhnRbhXc/7uVWClgRA4PcdbSQs4uVtiMvCV3CbhqeOTbvYkihw= X-Received: by 2002:a6b:740c:: with SMTP id s12mr1242963iog.301.1569269687453; Mon, 23 Sep 2019 13:14:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 23 Sep 2019 22:14:36 +0200 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000470a5705933e121a" X-Envelope-From: Subject: Re: [PHP-DEV] Re: [RFC] Union Types v2 From: benjamin.morel@gmail.com (Benjamin Morel) --000000000000470a5705933e121a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Nikita, Thank you for your work on this, I look forward to being able to use union types! The one thing that bothers me a bit is introducing yet another inconsistency by supporting false and not true as a type. Sure, I do get the need for false as a valid type for historical reasons, but at the same time I thought it would be interesting to see if true was being used as well in the wild, before closing the door on it. Therefore I reviewed all Composer packages with > 1 million downloads (1211 packages total), and here are the results: *31 packages use at least one @var, @param or @return containing true as a type.* - there are many illegitimate use cases, such as @return true , @return bool|true , @return true|false , or even @return bool|true|false - there are, however, quite a few potentially legitimate use cases. Among others: - @return true|WP_Error (*johnpbloch/wordpress-core*) : "True if the JSON data was passed or no JSON data was provided, WP_Error if invalid JSON was passed." - @return true|string (*johnpbloch/wordpress-core*) : "Returns true on success, or drop-in file to include." - @return string|true (*php/di*) : True if compilable, string explaining why if not - @return string|true (*zendframework/zend-authentication*) : True if successfull, error message if not - @param int|true (*yiisoft/yii2*) : "Use 0 to indicate that..., Use a negative number to indicate that..., Use boolean `true` to indicate that ..." - @param callable|resource|string|true|null (*symfony/symfony*) : "A line dumper callable, an opened stream, an output path or true to return the dump" Full list here . So although true as a type does not have the same historical background as false, it does seem that it's being used by enough packages to be worth considering; what do you think? =E2=80=94 Benjamin --000000000000470a5705933e121a--