On 8/10/2022 7:17 AM, Alex Wells wrote:
This solution works, but in practice is rarely used. The reasons are:
- there's no IDE completion: `$collection-> ` <- here I want IDE to
auto-complete the `map` method somehow, but since it's a function this is
impossible
This isn't impossible. There's n
On Wed, Aug 10, 2022, at 5:23 PM, Deleu wrote:
> On Wed, Aug 10, 2022, 11:30 PM Rowan Tommins
> wrote:
>
>>
>> To be honest, I put them in that order more for "purity" reasons: if they
>> come before __call, they can change the existing behaviour of the class, by
>> defining an extension method wi
On Wed, Aug 10, 2022, 11:30 PM Rowan Tommins
wrote:
>
> To be honest, I put them in that order more for "purity" reasons: if they
> come before __call, they can change the existing behaviour of the class, by
> defining an extension method with the same name as a "virtual" method
> implemented wit
> On 11 Aug 2022, at 00:30, Rowan Tommins wrote:
>
> a class implementing __call is assumed to reserve *all* method names.
This does make sense. Either an extension has precedence over class methods or
it does not; having extension methods in the middle of statically defined
methods and __cal
On 10 August 2022 18:52:58 BST, Alex Wells wrote:
>Thanks for explaining it better than I did.
>
>Regarding the implementation, that was roughly what I was thinking.
>
>But can't we put extension methods second, after real methods but before
>__call? As far as I understand, the reason to put it af
Hi Rowan,
śr., 10 sie 2022 o 19:32 Rowan Tommins napisał(a):
> On Wed, 10 Aug 2022 at 17:18, Ben Ramsey wrote:
>
> > I believe this is also called "monkey patching" in some places, and
> > Ruby, Python, and JavaScript all offer some form of object extension
> > similar to this.
> >
> > There is
Thanks for explaining it better than I did.
Regarding the implementation, that was roughly what I was thinking.
But can't we put extension methods second, after real methods but before
__call? As far as I understand, the reason to put it after __call is to
avoid a performance penalty on __call ca
On Wed, 10 Aug 2022 at 17:18, Ben Ramsey wrote:
> I believe this is also called "monkey patching" in some places, and
> Ruby, Python, and JavaScript all offer some form of object extension
> similar to this.
>
> There is also the PHP runkit extension that provides some of the
> functionality you'
Sorry, replying to all this time :)
I've missed to pinpoint an important fact: extensions don't add methods to
types per-say, rather they allow using them when imported. Extension's
methods would never be called if the extension isn't imported, which is
different from monkey-patching and runkit, w
On 8/10/22 09:17, Alex Wells wrote:
The idea is to introduce extension methods, similar to those in Kotlin, C#,
Dart. For those unfamiliar, those are just regular functions with fancy
syntax. However, I think having those will not only improve readability,
but also cover some of the previously r
I believe disallowing multiple extensions on one type defeats one of
the purposes of the feature - extending from outside. Let's say you have a
vendor package for manipulating strings which defines an extension on
`string` type. It works, but then you need one more custom extensions -
some kind of
On Wed, Aug 10, 2022 at 5:16 PM Levi Morrison via internals <
internals@lists.php.net> wrote:
> > What are your thoughts?
>
> It's a fantastic feature that I've used in Rust, although there are
> some differences. First, it doesn't work for regular methods -- they
> have to be part of a trait. Sec
> What are your thoughts?
It's a fantastic feature that I've used in Rust, although there are
some differences. First, it doesn't work for regular methods -- they
have to be part of a trait. Secondly, in general a trait can only be
implemented for a given type if it is in the package which defines
Hey internals.
The idea is to introduce extension methods, similar to those in Kotlin, C#,
Dart. For those unfamiliar, those are just regular functions with fancy
syntax. However, I think having those will not only improve readability,
but also cover some of the previously requested features.
Say
14 matches
Mail list logo