Re: [PHP-DEV] Methods which auto-return the class instance

2022-12-24 Thread Stephen Reay
> On 25 Dec 2022, at 12:59, Ilija Tovilo wrote: > > Hi Daniele > >> On Fri, Dec 23, 2022 at 1:09 AM joke2k wrote: >> >> Hi folks, >> >> What do you think about having a method which returns the class instance >> `$this` by default only IF its return type is set as `self`? >> >> It is very

Re: [PHP-DEV] Methods which auto-return the class instance

2022-12-24 Thread Ilija Tovilo
Hi Daniele On Fri, Dec 23, 2022 at 1:09 AM joke2k wrote: > > Hi folks, > > What do you think about having a method which returns the class instance > `$this` by default only IF its return type is set as `self`? > > It is very common for fluent class methods to have a verbose `return > $this;` end

Re: [PHP-DEV] Methods which auto-return the class instance

2022-12-24 Thread Rowan Tommins
On 23 December 2022 13:29:07 GMT, Claude Pache wrote: >> Yes but declaring `self` is more strict than `object`. >> And talking about the word itself... Declaring to return (your-)`self` but >> you could return someone-else of the same type as you. >> But it is ok, it refers to the class name no