Re: [PHP-DEV] [VOTE] declare(function_and_const_lookup='global')

This is only part of a thread. view whole thread
  108312
January 29, 2020 09:45 kjarli@gmail.com (Lynn)
On Wed, Jan 29, 2020 at 9:55 AM Bishop Bettini <bishop@php.net> wrote:

> Notwithstanding the excellent work done in the PR, I lean toward a No vote. > > Suppose I'm presented with this diff (and only this diff): > > $a = array_diff($x, $y); > + if (count($a)) die('Unexpected differences'); > > Where does count come from? I can't tell from this diff. It could be local > to this namespace, or it could be global. In the current implementation, I > have to scroll to the top of the file, check for what namespace I am in, > and what use are made. In the proposed implementation, I have also to check > the top of the file, but now its for > "declare(function_and_cost_lookup='global')" and the presence (or not) of > "use function count". > > It's not clear to me this is an improvement over status quo. > > [...] > > What do you think? >
Hi, I think that when we're at a point where developers start using existing core function names for custom functions and they start 'overriding' things, you already have this problem, regardless of this RFC. You already have to check whether or not the function was defined via a `use` statement on top. I don't think your example of the diff would have a difference between `use` and `declare` when it comes to reviewing. I would advice developers to avoid using core function names in namespaces for custom functions, as doing this would open up a whole different can of worms when it comes to developer experience. Regards, Lynn