Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101428 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45866 invoked from network); 26 Dec 2017 22:50:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Dec 2017 22:50:57 -0000 Authentication-Results: pb1.pair.com header.from=lists@rhsoft.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=lists@rhsoft.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain rhsoft.net designates 91.118.73.15 as permitted sender) X-PHP-List-Original-Sender: lists@rhsoft.net X-Host-Fingerprint: 91.118.73.15 mail.thelounge.net Received: from [91.118.73.15] ([91.118.73.15:40065] helo=mail.thelounge.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7B/57-58518-F42D24A5 for ; Tue, 26 Dec 2017 17:50:57 -0500 Received: from srv-rhsoft.rhsoft.net (Authenticated sender: h.reindl@thelounge.net) by mail.thelounge.net (THELOUNGE MTA) with ESMTPSA id 3z5rmq75S3zXMP; Tue, 26 Dec 2017 23:50:51 +0100 (CET) To: internals@lists.php.net References: <72392123-d37b-26df-6886-218f48205f8a@fleshgrinder.com> <5171148a-3554-35a3-ab72-370e1aac4a3f@php.net> <6894aa94-0400-7a9a-f00c-47f1f556a4d0@php.net> Message-ID: Date: Tue, 26 Dec 2017 23:50:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-CH Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Scalar Pseudo-type From: lists@rhsoft.net ("lists@rhsoft.net") Am 26.12.2017 um 20:15 schrieb Sara Golemon: > On Tue, Dec 26, 2017 at 10:56 AM, Sebastian Bergmann wrote: >> Am 26.12.2017 um 16:46 schrieb lists@rhsoft.net: >>> would you mind to explain this? >> >> "Foo|Bar", "array|string", etc. (still) make no sense to me. >> >> "scalar" makes sense to me although it is but an alias for >> "bool|float|int|string". >> > Would you feel differently if we combined union types with type aliasing? > > use Numeric = int | float; > > function foo(Numeric $bar) { ... } looks also good for me (while directed to someone else) but i would still prefer function foo(int|float $bar) because it's more native and hence works finally the same way for every code which targets the minimum PHP version where it's available at the first look "use Numeric = int | float" looks gut, but you need namespaces to avoid collisions and the same thing could have a different meaning in different namespaces while "int|float" is very clear and could also be "myClassA|myClassB" without explicit declaration what could also be a problem with "use Numeric = int | float" is what happens with existing code if someone changes that line by add another type while functions don#t expect that one as input at the time they where written - that can't happen with "int|float" in the function declaration because it's a case-by-case decision anyways, it would be a good progress if PHP programmers would be able to declare type-hints for everything in hwatever way it is implemented phpdoc even warns when documentation block and type hints differ and it's something to enhance code quality compared to "i can't declare a typehint at all or need 3 different functions"