Re: [Discussion] Expand deprecation notice scope for partially supported callables
| From: | Claude Pache | Date: | Thu, 12 May 2022 21:30:26 +0000 |
| Subject: | Re: [Discussion] Expand deprecation notice scope for partially supported callables | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-117723@lists.php.net to get a copy of this message | ||
> Le 12 mai 2022 à 23:11, Larry Garfield <larry@garfieldtech.com> a écrit :
>
> For the
callable type declaration, I'm not opposed but is
> it redundant with the existing deprecation? When would you pass a callable to something and not end
> up calling it anyway, which would trigger the existing deprecation? (Meaning in practice you'd
> always get 2 deprecations, which are not necessarily better than one.)
Although such a callable is probably intended to be called at some point, it is not necessarily
called immediately, and it may be easier to track the source of it when you trigger the deprecation
earlier. Example:
```php
public function registerErrorHandler(callable $onerror) {
$this->onError[] = $onerror;
}
```
(Of course, this argument also holds for is_callable().)
—Claude