php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52360 Strval documentation is unclear on whether it works on objects
Submitted: 2010-07-16 14:01 UTC Modified: 2010-07-20 15:56 UTC
From: sjoerd-php at linuxonly dot nl Assigned: rquadling (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2010-07-16 14:01 UTC] sjoerd-php at linuxonly dot nl
Description:
------------
Strval documentation is unclear on whether it works on objects.

Parameter documentation for val:
var may be any scalar type. You cannot use strval() on arrays or objects.

Example #1:
echo strval(new StrValTest);

Does not compute. 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-07-16 14:16 UTC] rquadling@php.net
-Status: Open +Status: Bogus
 [2010-07-16 14:16 UTC] rquadling@php.net
Please explain what else needs to be said in the Parameters section regarding the $var parameter which currently reads:

"The variable that is being converted to a string.

var may be any scalar type. You cannot use strval() on arrays or objects."

Clearly, new StrValTest which returns an object of class StrValTest, is an object and can't be used by strval().
 [2010-07-16 14:21 UTC] degeberg@php.net
-Status: Bogus +Status: Verified
 [2010-07-16 14:21 UTC] degeberg@php.net
It isn't bogus. The example contradicts the parameter description. It can take objects iff they implement the __toString() method.
 [2010-07-16 14:41 UTC] rquadling@php.net
-Assigned To: +Assigned To: rquadling
 [2010-07-20 15:56 UTC] rquadling@php.net
Automatic comment from SVN on behalf of rquadling
Revision: http://svn.php.net/viewvc/?view=revision&revision=301421
Log: Strval var parameter updated to include objects implmenting a __toString() method.
Fixes bug #52360
 [2010-07-20 15:56 UTC] rquadling@php.net
-Status: Verified +Status: Closed
 [2010-07-20 15:56 UTC] rquadling@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: Fri May 10 11:01:32 2024 UTC