I was wondering, considering this code:
namespace A\B;
use A\B as AB;
use \Z\V as ZV; // another used namespace
class Merry {
public static function Christmas{}
}
My pro doing this is that, since in the whole application I refer to Merry::Christmas() as AB\Merry::Christmas(), I don’t have to remember where I am when I’m coding and I just use AB\Merry::Christmas() everywhere. No confusion, no stupid PHP errors. Also it seems a little bit cleaner to me.
Is it good practice to define the use of a namespace inside the namespace declaration?
Maybe I’m missing something but I don’t see it as something to get excited about. As much as it lets you type
AB\Merry::Christmas();everywhere, nothing ever stops you from just using:\A\B\Merry::Christmas();, which is only two more characters and doesn’t need theusestatement(s). That said, the extrausestatement isn’t harmful, so whatever floats your boat and works best with the particular application’s namespace layout, do that.