php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #78262 Wrong error line (line 0) of errors printed in __toString
Submitted: 2019-07-08 06:07 UTC Modified: 2019-07-10 07:26 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: e dot grinec at gmail dot com Assigned: sjon (profile)
Status: Closed Package: Class/Object related
PHP Version: 7.3.7 OS: Windows 10 x64
Private report: No CVE-ID: None
 [2019-07-08 06:07 UTC] e dot grinec at gmail dot com
Description:
------------
PHP Version 7.3.2

<?php

class Test {
	public function __toString()
	{
		return NotExistsClass::notExistsMethod(); // make here any type of error
	}
}

print new Test(); // Fatal error: Method Test::__toString() must not throw an exception, caught Error: Class 'NotExistsClass' not found in D:\Portable\OSPanel\domains\test.test\test.php on line 0

Test script:
---------------
<?php

class Test {
	public function __toString()
	{
		return NotExistsClass::notExistsMethod(); // make here any type of error
	}
}

print new Test();

Expected result:
----------------
Fatal error: Method Test::__toString() must not throw an exception, caught Error: Class 'NotExistsClass' not found in D:\Portable\OSPanel\domains\test.test\test.php on line 6

Actual result:
--------------
Fatal error: Method Test::__toString() must not throw an exception, caught Error: Class 'NotExistsClass' not found in D:\Portable\OSPanel\domains\test.test\test.php on line 0

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-07-08 06:39 UTC] e dot grinec at gmail dot com
-Package: *General Issues +Package: Class/Object related
 [2019-07-08 06:39 UTC] e dot grinec at gmail dot com
changed Package from the "General issues" to the "Class/Object related"
 [2019-07-08 11:09 UTC] sjon@php.net
FYI - this works fine in the upcoming 7.4 version, see https://3v4l.org/FtDLp
 [2019-07-08 12:39 UTC] e dot grinec at gmail dot com
thank you
 [2019-07-10 07:26 UTC] sjon@php.net
-Status: Open +Status: Closed -Type: Bug +Type: Feature/Change Request -Assigned To: +Assigned To: sjon
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 04 01:01:30 2024 UTC