Doc #77034 [Nab->ReO]: Casting null to int undefined
| From: | cmb@php.net | Date: | Fri, 19 Oct 2018 12:42:09 +0000 |
| Subject: | Doc #77034 [Nab->ReO]: Casting null to int undefined | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-16093@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77034&edit=1
ID: 77034
Updated by: cmb@php.net
Reported by: casey dot mcginty at gmail dot com
Summary: Casting null to int undefined
-Status: Not a bug
+Status: Re-Opened
Type: Documentation Problem
-Package: Variables related
+Package: Documentation problem
PHP Version: 7.2.11
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> But is casting null to integer really supposed to be undefined,
> or is it just that the doc doesn't mention null?
IMO, the latter. Converting to string[1] explicitly mentions
the behavior of (string)NULL.
[1] <http://php.net/manual/en/language.types.string.php#language.types.string.casting>
Previous Comments:
------------------------------------------------------------------------
[2018-10-18 20:43:24] requinix@php.net
But is casting null to integer really supposed to be undefined, or is it just that the doc
doesn't mention null? The spec says it should be 0, which is the common sense answer.
https://github.com/php/php-langspec/blob/master/spec/08-conversions.md#user-content-converting-to-integer-type
------------------------------------------------------------------------
[2018-10-18 20:22:22] salathe@php.net
See the section "Converting to integer" on the page you linked, particularly under the
"From other types" subheading.
------------------------------------------------------------------------
[2018-10-18 17:44:01] requinix@php.net
Are you actually asking that question or just implying you'd like the docs to say it?
------------------------------------------------------------------------
[2018-10-18 17:36:16] casey dot mcginty at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/language.types.integer
---
I do not see any documentation regarding a null cast to an int. What is the official behavior?
Test script:
---------------
$myInt = (int)null;
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77034&edit=1