Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP method return this, effect on performance? [closed]

Tags:

php

How does it affect performance by making sure that all my setters return $this? To allow for chain calls similar to jQuery coding standards.

E.g:

public function setEnabled(){
    $_enabled = true;
    return $this;
}

I found this other question with no reference to the performance side, surley there is a negative

like image 956
John Magnolia Avatar asked Sep 19 '26 13:09

John Magnolia


1 Answers

No significant performance impact. Objects are not cloned.

like image 94
Ven Avatar answered Sep 22 '26 06:09

Ven



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!