Req #73049 [Opn]: Confusing namespace when calling missing function

From: Date: Thu, 08 Sep 2016 16:57:40 +0000
Subject: Req #73049 [Opn]: Confusing namespace when calling missing function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203884@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73049&edit=1 ID: 73049 Updated by: cmb@php.net Reported by: david at grudl dot com Summary: Confusing namespace when calling missing function Status: Open Type: Feature/Change Request Package: Scripting Engine problem PHP Version: Irrelevant Block user comment: N Private report: N New Comment: In my opinion the current error message is preferable over your suggestion, because looking for a global function (or constant for that matter) is only a *fallback*. Previous Comments: ------------------------------------------------------------------------ [2016-09-08 15:10:02] david at grudl dot com Description: ------------ When you call undefined global function inside namespace, the error message contains namespace, which is usually confusing. Example: Suppose that I have not enabled extension 'json' by mistake. Now this code <?php namespace Nette; echo json_encode($x); ?> leads to error "Call to undefined function Nette\json_encode()". The better message should be "Call to undefined function json_encode()". I know how works function name resolution, but consider these points: 1) functions are used in namespaces only rarely 2) functions are usually called without leading slash, i.e. not fully qualified 3) both error messages are correct, none is more correct than the other So it is much more likely that I call a global function, so it would be preferable to use message WITHOUT namespace. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73049&edit=1

« previous php.bugs (#203884) next »