Edit report at https://bugs.php.net/bug.php?id=26789&edit=1

 ID:                 26789
 Comment by:         me at joshsera dot com
 Reported by:        davidc at blesys dot com
 Summary:            NullPointerException desired
 Status:             Wont fix
 Type:               Feature/Change Request
 Package:            Feature/Change Request
 Operating System:   (doesn't apply)
 PHP Version:        5.0.0b3 (beta3)
 Block user comment: N
 Private report:     N

 New Comment:

The point of an NPE is so you can enclose code in a try/catch block instead of 
wrapping every statement in an if that tests for null. It makes for more 
readable 
code.


Previous Comments:
------------------------------------------------------------------------
[2004-01-05 03:00:01] der...@php.net

If you want to have "NULL" objects, test if an object is NULL before you call 
methods on it. There is no chance this will be implemented. 

------------------------------------------------------------------------
[2004-01-04 18:23:05] davidc at blesys dot com

Description:
------------
I desire a NullPointerException to be thrown, like in Java.
Currently, a fatal error triggers, stopping my entire application.

Many times an object may be null, but the application can continue. In 
addition, if an exception were thrown, I could trace it to see why the 
exception occured.



Reproduce code:
---------------
$j=null;
$j->someMethod();

Expected result:
----------------
Fatal error: Call to a member function someMethod() on a non-object in file.php 
on line 2



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=26789&edit=1

Reply via email to