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

From: Date: Thu, 08 Sep 2016 15:10:07 +0000
Subject: Req #73049 [NEW]: Confusing namespace when calling missing function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-203883@lists.php.net to get a copy of this message
From:             david at grudl dot com
Operating system: 
PHP version:      Irrelevant
Package:          Scripting Engine problem
Bug Type:         Feature/Change Request
Bug description:Confusing namespace when calling missing function

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



Thread (3 messages)

« previous php.bugs (#203883) next »