We use method chaining in several of our core systems. We’re trying to namespace some of those systems away from our modules. However I’m having trouble getting any kind of namespace resolution with chaining to work.
So while this works (as usual):
$GLOBALS['model']->User()->User_Friends()->getAll();
this, on the other hand:
$GLOBALS['model']->Core\User()->User_Friends()->getAll();
throws the error:
Parse error: syntax error, unexpected T_NS_SEPARATOR
Is there any way around this?
I’m almost already assuming this is a no-go. But asking to make sure I’m not missing something.
Depending on your point-of-view (definitely mine), it is a bug.
The resolution of the namespace can occur within the method
User, not as a property of the method itself.In code:
Thus, the return of the method
Useris theUserclass from the namespaceCore, of which the methodUser_Friends()is a part.EDIT
I suggest you take another look at the docs as well as the “Basics” article.
EDIT 2
Using
__NAMESPACE__to determine which namespace to operate in, from within an overloaded method: