php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #74842 The use of "is set" in the definition of isset is vague.
Submitted: 2017-07-02 06:00 UTC Modified: 2019-03-24 20:08 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: dominic dot mayers at meditationstudies dot org Assigned: girgias (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dominic dot mayers at meditationstudies dot org
New email:
PHP Version: OS:

 

 [2017-07-02 06:00 UTC] dominic dot mayers at meditationstudies dot org
Description:
------------
---
From manual page: http://www.php.net/function.isset
---
The definition should not be using "is set". Personally, I say that a variable cannot be set to NULL. For me, saying otherwise would be a contradiction, because we assign NULL to a variable to unset it. Others feel it makes sense to say that we set a variable to NULL, why not, it's a value. The point here is that "is set" is not very helpful in a definition. The extra "... and is not Null" helps, but it's hard to think because we still have these two cases. 

I am aware that another 8 years old bug mentions that the current definition seems a contradiction because we add "... and is not NULL". However, it is not a contradiction. It's either a useful addition, if we can set a variable to NULL, or redundant otherwise, but never a contradiction. The issue is more with "is set", because having two possible cases brings confusion.  

My native language is not English, but I would think something like "to determine if a variable has been assigned a non NULL value" would be more informative. The page could further recall that a way to unset a variable is to assign NULL to it. I would also recall that is_null is the opposite of isset.


Patches

improved-isset-documentation (last revision 2018-12-30 03:11 UTC by girgias@php.net)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-02 16:46 UTC] dominic dot mayers at meditationstudies dot org
The fact that is_null throws an exception when we use it with a variable that has never been assigned a value, but not when we have assigned NULL to it, suggests that we should have a different function, say isset_strict, to determine if a variable has been assigned a NULL or non NULL value to it. In fact, a few have proposed such a function in the comments. I am not suggesting it should be a built in function. I am just pointing out that an alternative view on "is set" is in the air. 

However, I feel it is important to bring out clearly, that the current definitions of isset, is_null and NULL are very harmonious and logical. In particular isset is the opposite of is_null, we unset a variable if we assign NULL to it, we set a variable if we assign a non NULL value to it and the purpose of isset is to determine if a variable is set. It's clean and simple. 

Note that we did not need the extra "... and is not NULL", which refers to a different view.  However, it is perhaps better not to use "is set", because it might conflict with the way some people use it.
 [2017-07-02 17:13 UTC] dominic dot mayers at meditationstudies dot org
The fact that unset($v) undo the effect of $v = NULL, also reinforces this other view where $v is set after $v = NULL. Again, just pointing out that this other view is in the air, It almost feels as if phpers have adopted the concept that isset does not determine if a variable is set.
 [2017-08-22 12:19 UTC] trainingsurat007 at gmail dot com
http://www.training-surat.com/php-training-surat.php
 [2018-12-30 02:45 UTC] girgias@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: girgias
 [2018-12-30 03:11 UTC] girgias@php.net
The following patch has been added/updated:

Patch Name: improved-isset-documentation
Revision:   1546139507
URL:        https://bugs.php.net/patch-display.php?bug=74842&patch=improved-isset-documentation&revision=1546139507
 [2019-03-24 20:06 UTC] girgias@php.net
Automatic comment from SVN on behalf of girgias
Revision: http://svn.php.net/viewvc/?view=revision&revision=347047
Log: Fix Doc Bug #74842
 [2019-03-24 20:08 UTC] girgias@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Oct 23 02:01:31 2019 UTC