Open wernerkrauss opened 9 years ago
If likes of this in MapAPI
public function setZoom( $zoom ) {
$this->zoom = $zoom;
}
was changed to
public function setZoom( $zoom ) {
$this->zoom = $zoom;
return $this;
}
would it allow the chain-ability whilst maintaining backwards compatibility?
For a given time sure, but like e.g. form fields handle it with returning a new, cloned object it just reduces side effects. Maybe not use "set" method names for that? How do other modules handle this?
In PHP5, return $this appears to return a reference, as such my suggested method appears correct. See http://stackoverflow.com/questions/3724112/php-method-chaining and http://stackoverflow.com/questions/7549423/how-do-i-chain-methods-in-php
I've pushed this change to the ISSUE6 branch and it appears to work as expected
Will break BC but allow us to do something like
$map = $myList->getRenderableMap()->setZoom(4)->setClusterer(true);