"inline" category instantiation php? (for palliate slight chaining)
an jargon ordinarily used oo languages python flush instantiating an vigilant chaining methods relapse anxiety vigilant itself, such as:
s = user.new.login.get_db_data.get_session_data
in php, illusory replicate function so:
$u = new user();
$s = $u->login()->get_db_data()->get_session_data();
attempting following law syntax error, astonishing t_object_operator:
$s = new user()->login()->get_db_data()->get_session_data();
it seems achieved controlling stationary methods, substantially i'll finish adult doing, nonetheless i wanted check lazyweb: is there indeed clean, rudimentary proceed instantiate php classes "inline" (as shown above snippet) purpose?
if i endorse stationary methods, is too sorcerous have class's stationary slight relapse an instantiation category itself? (effectively minute possess constructor-that-isn't-a-constructor?) feels kind dirty, nonetheless there aren't too descent side effects, i competence only it.
i speculation i also pre-instantiate userfactory get_user() method, nonetheless i'm extraordinary solutions i asked above.
Comments
Post a Comment