php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #74963 Improve "ErrorException: Trying to get property of non-object" error
Submitted: 2017-07-21 11:26 UTC Modified: 2017-07-31 03:57 UTC
From: lito at eordes dot com Assigned: laruence (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
 [2017-07-21 11:26 UTC] lito at eordes dot com
Description:
------------
I think that is easy to add to core a more detailed debug about errors related with get properties on non objects.

Something like "ErrorException: Trying to get property of non-object" could be more useful with "ErrorException: Trying to get property 'name' of non-object".

Also, related with "Error: Calling function on non-object" as "Error: Calling function 'getName' on non-object".

This change will help to debug problems in conditionals when are using multiples conditions on multiples objects.

Test script:
---------------
<?php
$user = new stdClass;

echo $user->level->name;

// NOW: ErrorException: Trying to get property of non-object
// IMPROVEMENT: ErrorException: Trying to get property 'name' of non-object 'level'


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-31 03:57 UTC] laruence@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: laruence
 [2017-07-31 03:57 UTC] laruence@php.net
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC