Le 16/09/2015 14:54, Rowan Collins a écrit :
The problem is that you're assigning meaning to a state that is extremely hard to work with. For instance, you can't refactor code which relies on dynamic variable existence into multiple functions, because the input parameter of the new function will always exist:

...
unset($foo);
refactored_code($foo);
...

function refactored_code($bar)
{
    if exists($bar) // oops, this is always true
    ...
}

OK, but, as I already said, an exists() construct would probably be used mostly for arrays elements and properties. Can't we accept this as a more readable alternative to array_key_exists()/property_exists() ?

This is not the canonical way but it seems a lot of people already use isset() to check if an array element exists. Should we push them to array_key_exists() ? Whatever, you write in the docs, most won't do it, just because it is longer, less readable and requires to remember the args order. Providing an exists() construct has chances and would be cleaner. But this is a long term move, even if it will be quite easy to backport to PHP 5.

Regards

François

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to