php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #29534 Resources should be scalars
Submitted: 2004-08-05 12:58 UTC Modified: 2006-03-07 01:21 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: tomas_matousek at hotmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5.0.0 OS: WinXP
Private report: No CVE-ID: None
 [2004-08-05 12:58 UTC] tomas_matousek at hotmail dot com
Description:
------------
A resource can be defined as a constant:
e.g. define("my_file",fopen(...)); or STDIN, STDOUT, STDERR in CLI mode.

In the "Constants" manual section constant values are constrained to scalars only.
"Only scalar data (boolean, integer, float and string) can be contained in constants."

However, a resource is not a scalar (is_scalar returns false).

Moreover, a NULL can be used as a value of a constant.

It's a mess, isn't it?

IMHO a resource should be a scalar. Such a change is acceptable since there is a notice in the is_scalar() function description which allows it: 

"Note: 
is_scalar() does not consider resource type values to be scalar as resources are abstract datatypes which are currently based on integers. This implementation detail should not be relied upon, as it may change." 

And there should be stated in the constants section of the manual that a NULL can be also a constant (don't forget to correct an error message which is reported if one tries to define a constant with a value being e.g. an array or object).




Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-07 16:02 UTC] nlopess@php.net
Andy said some time ago that we shouldn't define resources as constants.
 [2006-02-21 17:07 UTC] philip@php.net
Maybe we shouldn't, but we can. Shouldn't we document this in a similar way to the is_scalar() docs (that this behavior may change, do not rely upon it..." That would seem appropriate.
 [2006-03-07 01:21 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 21:01:26 2024 UTC