ZF2-227: Add Backslashes to core function and constants calls

Issue Type: Performance Improvement Created: 2012-03-18T16:38:24.000+0000 Last Updated: 2012-10-08T20:15:23.000+0000 Status: Closed Fix version(s): Reporter: Maksym Sliesarenko (sm) Assignee: Ralph Schindler (ralph) Tags: Related issues: Attachments:


Replace all code like:

<pre class="literal"> 
namespace 'Zend\Blabla';
$time = time();


echo PHP_EOL;


to this way

<pre class="literal"> 
namespace 'Zend\Blabla';
$time = \time();


echo \PHP_EOL;


It will increase the performance and security. Because php first looks for function in current namespace.

Function overloading example:

<pre class="literal"> 

namespace Zend\Date {
    function is_object($date) {
        echo "Zend Date constructor is called with param {$date}";exit;

namespace Foo {

require_once 'zf2/library/Zend/Loader/AutoloaderFactory.php';
\Zend\Loader\AutoloaderFactory::factory(array('Zend\Loader\StandardAutoloader' => array()));

$date = new \Zend\Date\Date('2012-03-18');



Posted by Denis Portnov (denix) on 2012-03-20T00:59:14.000+0000

h6.on performance I did simple benchmark, and it shows up to 8% improvement when calling global functions with slash whether it's a significant improvement is up to discussion

h6.on security Not sure it's a framework responsibility to address such "hacks"

Posted by Sascha-Oliver Prolic (prolic) on 2012-07-09T10:06:48.000+0000

I would close this issue. This is on the todo-list of the php-dev-team. We should not change the code here.

Posted by Marc Bennewitz (private) (mabe) on 2012-07-09T11:04:56.000+0000

This could be done by a script as we don't define functions or global constants in ZF

Posted by Ralph Schindler (ralph) on 2012-10-08T20:15:23.000+0000

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit:

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.