|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2016-08-06 02:31 UTC] kalle@php.net
 
-Status:      Open
+Status:      Closed
-Assigned To:
+Assigned To: kalle
  [2016-08-06 02:31 UTC] kalle@php.net
  [2016-08-06 09:36 UTC] nikic@php.net
 
-Status: Closed
+Status: Suspended
  [2016-08-07 04:54 UTC] kalle@php.net
 
-Assigned To: kalle
+Assigned To:
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 04:00:01 2025 UTC | 
Description: ------------ Analog to __toString() a __toInt() method. Additionally allow NULL as a valid return value for casting methods. Test script: --------------- class test { private $value; function __construct($value = null) { $this->value = $value; } function __toString() { return $this->value ? (string) $this->value : $this->value; } function __toInt() { return $this->value ? (int) $this->value : $this->value; } } (string)(new test()) === null; (string)(new test('1')) === '1'; (string)(new test(1)) === '1'; (int)(new test()) === null; (int)(new test('1') === 1; (int)(new test(1) === 1; Expected result: ---------------- 6 x true Actual result: -------------- * Catchable fatal error: Method test::__toString() must return a string value in php shell code on line 1 *__toInt is never called