From:             mgraham at etsy dot com
Operating system: Linux
PHP version:      5.4.14
Package:          Class/Object related
Bug Type:         Feature/Change Request
Bug description:Differentiate between member function call on a null and 
non-null, non-objects

Description:
------------
The error message for "Call to a member function on a non-object" is not as
helpful as it could be. It would be really great if it would distinguish
when the variable is null instead of another type of actual data such as an
integer, string or array.

This is helpful so that when fixing this issues, one can tell from the logs
if a null check is sufficient or if I need to find out where the wrong type
of data is being created.

Test script:
---------------
<?php
$x = (isset($argv[1]) && $argv[1] == 'null') ? null :
'non-null-non-object';
$x->fail();


Expected result:
----------------
Null is a special kind of non-object, so if the variable is null, the error
message should be different to indicate that it's null.


mgraham@vm:~/development/tmp$ php bug.php null

Fatal error: Call to a member function fail() on null in
/home/mgraham/development/tmp/bug.php on line 3
mgraham@vm:~/development/tmp$ php bug.php 

Fatal error: Call to a member function fail() on a non-object in
/home/mgraham/development/tmp/bug.php on line 3
mgraham@vm:~/development/tmp$ 


Even better would be to say in the error message what the type of the
variable is for, integer, array, string, whatever.

Actual result:
--------------
When running this script, there is no information about what type of
non-object it was.


mgraham@vm:~/development/tmp$ php bug.php null

Fatal error: Call to a member function fail() on a non-object in
/home/mgraham/development/tmp/bug.php on line 3
mgraham@vm:~/development/tmp$ php bug.php 

Fatal error: Call to a member function fail() on a non-object in
/home/mgraham/development/tmp/bug.php on line 3
mgraham@vm:~/development/tmp$ 


-- 
Edit bug report at https://bugs.php.net/bug.php?id=64744&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64744&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64744&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64744&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64744&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64744&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64744&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64744&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64744&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64744&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64744&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64744&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64744&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64744&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64744&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64744&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64744&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64744&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64744&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64744&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64744&r=mysqlcfg

Reply via email to