hamcrest / hamcrest-php

PHP Hamcrest implementation [Official]

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consider adding namespaced standalone functions

kostislav opened this issue · comments

The recommended way to use the assertion functions is by calling the static methods of Hamcrest_MatcherAssert and Hamcrest_Matchers. For people that would like to use "standalone" functions, there is the option to call Util::registerGlobalFunctions and let it create functions in the global namespace.

But since PHP 5.6 it is possible to import functions from namespaces using use function. Would it make sense to define the functions in a namespace and make them accessible by default? They should not conflict with any existing functions and can be used exactly like the global functions just by adding a use statement at the top of the file.

The global ones would probably have to be kept as well so as to not break backwards compatibility.

I can try to do a PR if there is a chance of this being accepted.