Skip to content

Conversation

@laruence
Copy link
Member

@laruence laruence commented Jul 26, 2017

Change error message

Trying to get property of non-object

to

Trying to get property 'name' of non-object

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

And I think this could also goes into 7.2

@krakjoe
Copy link
Member

krakjoe commented Jul 26, 2017

@sgolemon @remicollet is this okay in 7.2 ?

@sgolemon
Copy link
Member

Sure. This is a low-impact change and only shows up in the error path. I'll merge to 7.2 and bring forward.

@sgolemon
Copy link
Member

Actually, a quick scan shows ext/pdo_mysql/tests/bug44327.phpt still has the old error message.
Also, a quick scan of the PR shows @laruence can push the change himself. :D

Go ahead and merge to 7.2/master once you've addressed the remaining test.

@php-pulls php-pulls merged commit dbd729e into php:master Jul 31, 2017
@eusonlito
Copy link

I'm the original request owner :)

What about extend this improvement to function calls on objects?

"Error: Calling function on non-object" as "Error: Calling function 'getName' on non-object".

Detailed request at https://bugs.php.net/bug.php?id=74963

Thanks a lot :)

@laruence
Copy link
Member Author

I am not sure what do you mean, it should already act like that now:

$non_obj = NULL;
$non_obj->func();

output:

Fatal error: Uncaught Error: Call to a member function func() on null

@eusonlito
Copy link

Same as property example:

<?php
$user = new stdClass;

echo $user->getName();

NOW: Fatal error: Uncaught Error: Call to undefined method stdClass::getName()
IMPROVEMENT: Fatal error: Uncaught Error: Call to undefined method stdClass::getName() on object 'user'

Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants