Re: [VOTE] declare(function_and_const_lookup='global')
| From: | Claude Pache | Date: | Wed, 29 Jan 2020 20:12:17 +0000 |
| Subject: | Re: [VOTE] declare(function_and_const_lookup='global') | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108323@lists.php.net to get a copy of this message | ||
> Le 29 janv. 2020 à 19:42, Bishop Bettini <bishop@php.net> a écrit :
>
> Cons... have to enumerate everything, potentially lots of work to do that
> to update old code to use; edge cases I'm not thinking about.
Not only it is much work (although it could be partially automated), but it does not make much
sense.
I’ve taken a random file (~650 LoC) in the codebase I’m working on. With
declare(strict_qualify=1), I would have to add:
use function
array_filter
, array_flip
, array_key_exists
, array_keys
, array_push
, array_unshift
, compact
, ctype_digit
, idate
, in_array
, is_int
, is_string
, ksort
, ob_get_clean
, ob_start
, preg_match
, sprintf
, strlen
, strncmp
, substr_count
, trim
, usort;
I don’t see a clear advantage in declaring more than 20 global functions in each and every of the
hundreds of files of the codebase—where it is evident that they are all global function (no, I
don’t have a namespaced version of is_int()). Also, I think that there are better
ways to discover if my colleague introduced surreptitiously a system() call in the
codebase.
Some time ago, I’ve tried the alternative approach in two files: adding a backslash before each
and every global function (carefully avoiding non-functions such as isset(),
empty() and list()). Well, it reminded me of the good old days when I used
TeX intensively, but objectively, it didn’t make the code more clear or more secure (I’ve not
tested its velocity, though).
—Claude