Robert Williams wrote on 18/09/2015 18:40:
Exactly, there’s clearly a gap here. Further, enough people want it that a few have shown up on this list, which means there are probably many, many thousands, or even millions, of people out in the wild that want it.

The problem is that a lot of the people that think they want it, don't actually have a use for it, they just feel like it "should" exist.

There are a couple of small edge cases that people have come up with during this thread where it's valid, but the vast majority of examples I've seen are simply misunderstanding what isset() does and why, or not realising that array_key_exists() and property_exists() already do the job they need.

The use cases Lester and yourself have come up with are NOT evidence that isset() is broken, as many people claim. They are things which the majority of people will never need to (arguably nobody "needs" to do them, but you want to do them, so I guess that's kind of the same thing).


I’m not familiar enough with PHP’s internals to say for sure, but I suspect it’s not terribly hard to implement (it’s just isset() without the extra null check). So… why not? Like anything else in the language, people don’t have to use it if they don’t want to, but it’s good to have tools. Yes, even tools that can be abused.

Sure, I'm happy with that argument - IF we come up with a name and documentation that doesn't imply this is a replacement for isset(), or validate the incorrect conception that isset() is "broken".

The title of this thread refers to one such misunderstanding - the article at http://www.phpsadness.com/sad/28 waffles on a lot about empty() being a bad name, doesn't even mention isset(), and scares the user with a blob of C code, but doesn't really explain why any of this is a problem. It even says:

> Some languages circumvent this issue by requiring variable declaration or giving undefined variables explicit values.

Neatly, PHP does both: if you take Notices seriously, variable declaration (or at least initialisation-before-reading) is required; if you ignore them, or use isset()/empty(), it gives the undefined variable a value of Null. :)


So, by all means, propose a function which searches the symbol table for a variable, but please don't call it something as generic as exists(), and please don't edit the isset() documentation to recommend its usage in any but the most unusual cases.

Regards,
--
Rowan Collins
[IMSoP]

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

Reply via email to