echo
is not a function, it's a language construct. I don't have anything for that.
But function calls like time()
can be overridden since PHP-5.3's namespace fallback policy:
For functions […], PHP will fall back to global functions […] if a namespaced function […] does not exist.
E.g. for the unqualified function call time()
in the non global namespace foo
you can provide foo\time()
.
Personally I'm using this to mock e.g. time()
for unit test. I published those mocks in the library PHP-Mock:
namespace foo;
use phpmock\phpunit\PHPMock;
class FooTest extends \PHPUnit_Framework_TestCase
{
use PHPMock;
public function testBar()
{
$time = $this->getFunctionMock(__NAMESPACE__, "time");
$time->expects($this->once())->willReturn(3);
$this->assertEquals(3, time());
}
}