Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100914 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90774 invoked from network); 22 Oct 2017 19:14:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Oct 2017 19:14:00 -0000 X-Host-Fingerprint: 95.150.123.203 unknown Received: from [95.150.123.203] ([95.150.123.203:26018] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/B7-58908-7FDECE95 for ; Sun, 22 Oct 2017 15:14:00 -0400 Message-ID: To: internals@lists.php.net References: <9a3f15dd-5dfc-144b-cc5f-66f689c33f53@php.net> Date: Sun, 22 Oct 2017 20:13:55 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:49.0) Gecko/20100101 Firefox/49.0 SeaMonkey/2.46 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 95.150.123.203 Subject: Re: [PHP-DEV] Strict type declarations not enforced for ReflectionAPI invocation From: ajf@ajf.me (Andrea Faulds) Hi Nikita, Nikita Popov wrote: > I believe that the proper way to fix this is to handle dynamic function > invocations differently from direct invocations. Direct invocations should > use the strictness level of the call-site, while dynamic invocations should > use the strictness level of the declaration-site. This means that the > internal array_map and a userland reimplementation will behave consistent. > It also means that PHPUnit will be able to respect the strictness level of > file defining the data provider, etc. I've seen a number of complaints > about our handling of callbacks wrt strict_types, so I think it's > worthwhile to at least consider making such a change. I agree that callbacks are one of the rough edges of strict_types. I've always been hoping we'd get some type of callable typing as a means of solving that, but it hasn't happened yet. As for your specific suggestion, I don't see the benefit of it. If anything, it could make one particular problem worse, namely that of libraries not written with type-hinted callbacks in mind. Calls to such libraries are more likely to blow up if suddenly those calls are made with strict types because the callbacks were declared in a strict_types file. I also dislike the inconsistency of making dynamic calls work differently. Thanks. -- Andrea Faulds https://ajf.me/