Re: Strict type declarations not enforced for ReflectionAPI invocation

From: Date: Sun, 22 Oct 2017 19:13:55 +0000
Subject: Re: Strict type declarations not enforced for ReflectionAPI invocation
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-100914@lists.php.net to get a copy of this message
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/

« previous php.internals (#100914) next »