Bug #69476 [Nab]: is_null() must not throw warnings
| From: | spam2 at rhsoft dot net | Date: | Fri, 17 Apr 2015 18:20:11 +0000 |
| Subject: | Bug #69476 [Nab]: is_null() must not throw warnings | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-192168@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=69476&edit=1
ID: 69476
User updated by: spam2 at rhsoft dot net
Reported by: spam2 at rhsoft dot net
Summary: is_null() must not throw warnings
Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: Linux
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
and BTW you at your own did not understand the PHP behavior, otherwise you would not have reommended
"isset($var) && !is_null($var)" while "isset() && is_null()" is
just impossible and so the && construct makes no sense
Previous Comments:
------------------------------------------------------------------------
[2015-04-17 18:18:02] spam2 at rhsoft dot net
well, you can't seriously claim wrong behavior correct just beause millions of programmers
learned to deal with the inconsistent und unexpected behavior left and right all over the
programming language
------------------------------------------------------------------------
[2015-04-17 18:15:15] cmb@php.net
Harald, please reconsider your attitude. Claiming that the behavior
of isset is braindead, while it obviously works well for millions
of programmers, and even ranting and cursing, is certainly
unrewarding. :)
If you really consider it necessary to change the behavior or, more
realistically, introduce a new language construct, feel free to
propose a respective RFC; see the instructions in the Wiki on how
to do so[1].
[1] <https://wiki.php.net/rfc/howto>
------------------------------------------------------------------------
[2015-04-17 17:45:30] spam2 at rhsoft dot net
> If this does not satisfy your use-case
you refuse to understand that such pervert behavior is not a matter of a use-case - it's a
matter of a clean and expectable language behavior
i don't have a usecase, i was just asked today what isset() in case of NULL gives back and i
answered true just because of logical thinking that the variable is defined and so set
> The behavior of is_null() can not change either,
> as it is an ordinary function, not a language construct
and how does that matter in the context of not idiotically throw warnings in case of a undefined
variable instead just return false since it don't have the value NULL and so make it at least
*possible* to distinct between a undefined variable or NULL as value
------------------------------------------------------------------------
[2015-04-17 17:37:26] nikic@php.net
Indeed, isset() behaves the same for array keys and object properties. I was merely pointing out
that for these usages there are alternatives like array_key_exists(), which will return true even if
the value is null.
If this does not satisfy your use-case, you're out of luck. The behavior of isset() will not
change. The behavior of is_null() can not change either, as it is an ordinary function, not a
language construct.
------------------------------------------------------------------------
[2015-04-17 17:28:29] spam2 at rhsoft dot net
> it exists so you can write isset($array['key'])
but it don't work relieable because in case of the key existing but NULL as value it gives back
false which is pure bullshit - frankly speaking my breath was away as your answers implied isset()
in case of a array-key and a simple variable again behaves different, at least that is not the case
- it's the same way wrong
[harry@srv-rhsoft:~]$ cat test.php
<?php
$x = array();
$x['a'] = NULL;
if(isset($x['a']))
{
echo "DEFINED\n";
}
else
{
echo "UNDEFINED\n";
}
$y = NULL;
if(isset($y))
{
echo "DEFNINED\n";
}
else
{
echo "UNDEFINED\n";
}
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=69476
--
Edit this bug report at https://bugs.php.net/bug.php?id=69476&edit=1