Issues

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

Description

Replace all code like:

 
namespace 'Zend\Blabla';
...
$time = time();

...

echo PHP_EOL;

...

to this way

 
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:

 

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');

}

Comments

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"

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

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

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: https://github.com/zendframework/zf2/issues/2465