Re: [PHP-DEV] [RFC] [Discussion] Typed class constants

2023-02-21 Thread Máté Kocsis
Hi Claude, No, I didn't misunderstand you, I just didn't specify my answer enough: Enums can be assigned to their own class constants because of their special behavior, namely that enum cases are evaluated and then instantiated right away, during the compilation of the enum case. This is easily

Re: [PHP-DEV] Class Re-implementation Mechanism

2023-02-21 Thread Bruce Weirdan
On Tue, Feb 21, 2023 at 7:53 AM someniatko wrote: > We want to write some tests for the Service class, but we don't want > to use a real SomeDependency instance > during tests. A common approach is to either extract an interface > (JUST to make it testable), or to drop the > `final` keyword and

Re: [PHP-DEV] Class Re-implementation Mechanism

2023-02-21 Thread Alexandru Pătrănescu
On Tue, Feb 21, 2023 at 3:30 PM someniatko wrote: > > This sounds interesting but it breaks some expectations. > > > > Interesting because you can have any class act as an interface for other > classes with the interface being built up of any public properties or > method that exists on that

Re: [PHP-DEV] Class Re-implementation Mechanism

2023-02-21 Thread someniatko
> > >> So it's mostly a syntactic sugar that allows defining an interface for > the current class that is already implemented by the current class. > Yeah, while answering to you, I've actually came to the same conclusion. > > The interface name is the same as the class name and based on the

[PHP-DEV] Class Re-implementation Mechanism

2023-02-21 Thread someniatko
Hi again, internals My marathon of some crazy ideas continues :D, with less crazy one this time. ## Idea Allow "reimplementing" the non-static public API (that is public properties and methods, excluding constructor) of a class by other classes like this: ```php final class interface A {

Re: [PHP-DEV] Class Re-implementation Mechanism

2023-02-21 Thread Deleu
On Tue, Feb 21, 2023, 8:52 AM someniatko wrote: > Hi again, internals > > My marathon of some crazy ideas continues :D, with less crazy one this > time. > > > ## Idea > > Allow "reimplementing" the non-static public API (that is public > properties and methods, excluding constructor) of a class

Re: [PHP-DEV] Class Re-implementation Mechanism

2023-02-21 Thread Alexandru Pătrănescu
Hi Someniatko, On Tue, Feb 21, 2023 at 1:52 PM someniatko wrote: > Hi again, internals > > My marathon of some crazy ideas continues :D, with less crazy one this > time. > > > ## Idea > > Allow "reimplementing" the non-static public API (that is public > properties and methods, excluding

Re: [PHP-DEV] Class Re-implementation Mechanism

2023-02-21 Thread Stephen Reay
> On 21 Feb 2023, at 18:52, someniatko wrote: > > Hi again, internals > > My marathon of some crazy ideas continues :D, with less crazy one this time. > > > ## Idea > > Allow "reimplementing" the non-static public API (that is public > properties and methods, excluding constructor) of a

Re: [PHP-DEV] Class Re-implementation Mechanism

2023-02-21 Thread someniatko
> This sounds interesting but it breaks some expectations. > > Interesting because you can have any class act as an interface for other > classes with the interface being built up of any public properties or method > that exists on that class. In my original suggestion, it's not like any class,

Re: [PHP-DEV] Class Re-implementation Mechanism

2023-02-21 Thread Robert Landers
On Tue, Feb 21, 2023 at 12:52 PM someniatko wrote: > > Hi again, internals > > My marathon of some crazy ideas continues :D, with less crazy one this time. > > > ## Idea > > Allow "reimplementing" the non-static public API (that is public > properties and methods, excluding constructor) of a