Re: [Concept] Extension methods

From: Date: Thu, 11 Aug 2022 14:25:57 +0000
Subject: Re: [Concept] Extension methods
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-118413@lists.php.net to get a copy of this message
Am 11.08.2022 um 11:03 schrieb Alex Wells <autaut03@gmail.com>: > That’s just a concept. I’d love to bring a lot more examples in an RFC if there’s more > positive than negative feedback. Again, I’m more looking for feedback than trying to convince > someone, but I’ll showcase a couple real comparisons for some context: > > Compere these (copied from real world project/public composer packages): > ```php > $className = Str::studly(implode('_', array_slice(explode('_', > $file->getName()), 4))); > // vs > $className = > $file->getName()->explode(‘_’)->slice(4)->implode(‘_’)->studly(); This reminds me of the proposed (but declined) pipe operator https://wiki.php.net/rfc/pipe-operator-v2 but I'd still prefer to have it as a generic operator instead of using a pseudo-OO approach for this. I say pseudo-OO because not everything in PHP is an object plus using the -> syntax IMHO muddies the water. Regards, - Chris

« previous php.internals (#118413) next »