Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101421 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 22824 invoked from network); 26 Dec 2017 15:59:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Dec 2017 15:59:16 -0000 Authentication-Results: pb1.pair.com header.from=andreas@heigl.org; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=andreas@heigl.org; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain heigl.org designates 195.191.240.18 as permitted sender) X-PHP-List-Original-Sender: andreas@heigl.org X-Host-Fingerprint: 195.191.240.18 hos109.unaxus.net Received: from [195.191.240.18] ([195.191.240.18:35794] helo=hos109.unaxus.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8E/24-58518-1D1724A5 for ; Tue, 26 Dec 2017 10:59:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=heigl.org; s=default; h=To:In-Reply-To:References:Message-Id:Subject:Date:Mime-Version: Content-Transfer-Encoding:Content-Type:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=QOSpZZ2V0oY8epZDMqxX4ckHHeT7TerbL9BvmHCDJYM=; b=iTw8tglih/DxfvC/N8AZ4Dd+/0 0RsaX86HQ+Pn6hzBx/UxyAF6PG3Y3O3s2TxWlh3VaSHJ1UzfLGj6p70V11XGEg2FIskMOIz0DOAkm KA1pJ+H+dUtONeMR0xr3XnEHj0d3lD7PUbTriwaepFONEeViQJXWZ8IyQEPpaM/oEhqzYzZMBtEl+ uy4rrNHvJ1Kl2a9xF01RGm6kZ2AolTIqku2WjlpGbcqGQ+GQMqagZKoq+U7s+5UaILBN6fT5RBVZi Yq3Kq6dK5vU/F2haCQmwGtCUr4kcoOaNgYvgfH9idrwcf1BjS29fo2rzC2lNi8GDtUFUpGy8zA4Ou 3SoM1/ig==; Received: from heigl.gw.tgnet.de ([80.72.250.242]:50453 helo=[172.16.1.133]) by hos109.unaxus.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1eTrdG-003fmS-BA for internals@lists.php.net; Tue, 26 Dec 2017 16:59:10 +0100 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (1.0) Date: Tue, 26 Dec 2017 16:59:08 +0100 Message-ID: <88921EA7-EB68-4630-AA9E-DE0C04342F0B@heigl.org> References: <72392123-d37b-26df-6886-218f48205f8a@fleshgrinder.com> <5171148a-3554-35a3-ab72-370e1aac4a3f@php.net> In-Reply-To: <5171148a-3554-35a3-ab72-370e1aac4a3f@php.net> To: internals@lists.php.net X-Mailer: iPhone Mail (15C153) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hos109.unaxus.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - heigl.org X-Get-Message-Sender-Via: hos109.unaxus.net: authenticated_id: a.heigl+heigl.org/only user confirmed/virtual account not confirmed X-Authenticated-Sender: hos109.unaxus.net: a.heigl@heigl.org Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Scalar Pseudo-type From: andreas@heigl.org (Andreas Heigl) Hey All.=20 > Am 26.12.2017 um 14:38 schrieb Sebastian Bergmann : >=20 >> Am 24.12.2017 um 15:34 schrieb Fleshgrinder: >> I prepared a PR to add the `scalar` pseudo-type to PHP after the >> discussions around adding a `mixed` pseudo-type. I strongly believe that >> it makes sense to provide the most common primitive union types with >> handy aliases even if we are going to add union types in the future to PH= P. >=20 > Thank you, Richard, for working on this. >=20 > I spent a lot of time this year introducing scalar type declarations into > existing code bases. In quite a few cases I was not able to do so because > the existing code works with parameters that can be of two or more scalar > types. With PHP 7.2, I can only document this outside of the code using > @param annotations (until the code has been refactored to work with only > one parameter type). >=20 > With a "scalar" type declaration I would not have to fall back to @param > annotations and could express the type in actual syntax. Just a stupid question from someone that isn't following all the discussions= here. So forgive me if the question was already asked and answered.=20 What would be wrong with a "composed type hint"? Something like int|float|do= uble $numeric. Or array|Traversable $iterator?=20 It would allow people to add "mixed" typehints without having to introduce m= ultiple typehints that combine different scalar typehints. And it could even= allow typehinting different Objects in one function.=20 Yes, it allows people to shoot themselfes into their own feet.=20 And I'd only allow that for parameter types and never ever for return types.= =20 But it might be an idea.=20 Cheers Andreas=20