2
By my knowledge I can only call the method of a class only if I instantiate or if the method is static!
I can just do something myself class->metodo('var')
or class::metodo('var')
.
But I’ve seen in some codes something like class->metodo('var')->outrometodo('')
.
Drupal himself uses something similar. Ex:
db_select('node', 'n')->execute()->fetchCol();
How do you make that kind of call, and what would be the advantages?
@Virgilionovic even being in java the idea is the same?
– ivan veloso
Yes. It’s the same logic.
– novic
Yes, see working repl it.
– NoobSaibot
Really! I read the question and the answer here, and it worked! Recommends that I delete the question?
– ivan veloso
You can’t leave... you’re like a duplicate.
– novic
But a question has not been answered! How is the question! What would be the advantages? Does it represent any significant gain? Is there any recommendation for when to use or not?
– ivan veloso
https://answall.com/questions/105259/o-que%C3%A9-chaining-de-m%C3%a9todos/105433#105433 read
– novic