Is it possible to write series of statements that repeatedly refer to a single object without having to write the object every time?
I came to this because I used to do this in Visual Basic:
With person
.setFullName(.firstName+" "+.lastName)
.addParent(parent)
.save()
End With
This is a shorthand for
person.setFullName(person.firstName+" "+person.lastName)
person.addParent(parent)
person.save()
Is it possible to achieve this in PHP?
To rewrite the following code without having to write $person
5 times?
$person->setFullName($person->firstName.' '.$person->lastName);
$person->addParent($parent);
$person->save();
Note: I'm not referring to methods chaining for 2 reasons:
1) I want to use public members as well
2) I don't work with classes I wrote, so I cannot add return $this;
to all the methods
Thanks