Re: [PHP-DEV] [RFC][Discussion] Why can constructors violate LSP?

2023-11-24 Thread Robert Landers
On Fri, Nov 24, 2023 at 2:30 PM Deleu wrote: >> >> Hey Mike, >> >> Using a static method to enforce LSP when it should have been enforced >> in the first place, merely proves my point that it violates LSP. I >> don't know how else to spell it out, I guess we can try this one next: >> >> class A {

Re: [PHP-DEV] [RFC][Discussion] Why can constructors violate LSP?

2023-11-24 Thread Deleu
> > Hey Mike, > > Using a static method to enforce LSP when it should have been enforced > in the first place, merely proves my point that it violates LSP. I > don't know how else to spell it out, I guess we can try this one next: > > class A { > final public static function foo() { >

Re: [PHP-DEV] [RFC][Discussion] Why can constructors violate LSP?

2023-11-24 Thread Dennis Birkholz
Hi Robert, Am 23.11.23 um 21:31 schrieb Robert Landers: However, we can make certain methods private anyway, namely, constructors (I haven't gone hunting for other built-in methods yet). This is perfectly allowed: class P { public function __construct($name = 'waldo') { echo

Re: [PHP-DEV] [RFC][Discussion] Why can constructors violate LSP?

2023-11-24 Thread Robert Landers
On Fri, Nov 24, 2023 at 12:46 PM Mark Trapp wrote: > > On Thu, Nov 23, 2023 at 12:31 Robert Landers wrote: > > > > Hello Internals, > > > > As you may know, an inherited method cannot reduce the visibility of > > an overridden method. For example, this results in a fatal error > > during

Re: [PHP-DEV] [RFC][Discussion] Why can constructors violate LSP?

2023-11-24 Thread Mark Trapp
On Thu, Nov 23, 2023 at 12:31 Robert Landers wrote: > > Hello Internals, > > As you may know, an inherited method cannot reduce the visibility of > an overridden method. For example, this results in a fatal error > during compilation: > > class P { > public function hello($name =3D 'world') {

Re: [PHP-DEV] [RFC][Discussion] Why can constructors violate LSP?

2023-11-24 Thread Mark Trapp
On Thu, Nov 23, 2023 at 12:31 PM Robert Landers wrote: > > Hello Internals, > > As you may know, an inherited method cannot reduce the visibility of > an overridden method. For example, this results in a fatal error > during compilation: > > class P { > public function hello($name = 'world')

Re: [PHP-DEV] [RFC][Discussion] Why can constructors violate LSP?

2023-11-24 Thread Robert Landers
On Fri, Nov 24, 2023 at 5:06 AM Mike Schinkel wrote: > > > > On Nov 23, 2023, at 4:50 PM, Robert Landers wrote: > > On Thu, Nov 23, 2023 at 10:30 PM Deleu wrote: > > > Constructors are an implementation detail of a specialized class and as such > they're not subject to LSP because the goal of

Re: [PHP-DEV] [RFC][Discussion] Why can constructors violate LSP?

2023-11-23 Thread Mike Schinkel
> On Nov 23, 2023, at 4:50 PM, Robert Landers wrote: > > On Thu, Nov 23, 2023 at 10:30 PM Deleu wrote: >> >> Constructors are an implementation detail of a specialized class and as such >> they're not subject to LSP because the goal of LSP is to be able to make >> sure that any object of a

Re: [PHP-DEV] [RFC][Discussion] Why can constructors violate LSP?

2023-11-23 Thread Robert Landers
On Thu, Nov 23, 2023 at 10:30 PM Deleu wrote: > > > > On Thu, Nov 23, 2023 at 5:31 PM Robert Landers > wrote: >> >> Hello Internals, >> >> As you may know, an inherited method cannot reduce the visibility of >> an overridden method. For example, this results in a fatal error >> during

Re: [PHP-DEV] [RFC][Discussion] Why can constructors violate LSP?

2023-11-23 Thread Deleu
On Thu, Nov 23, 2023 at 5:31 PM Robert Landers wrote: > Hello Internals, > > As you may know, an inherited method cannot reduce the visibility of > an overridden method. For example, this results in a fatal error > during compilation: > > class P { > public function hello($name = 'world') {

Re: [PHP-DEV] [RFC][Discussion] Why can constructors violate LSP?

2023-11-23 Thread Rowan Tommins
On 23 November 2023 20:31:09 GMT, Robert Landers wrote: >I'd like to propose an RFC to enforce the covariance of constructors >(just like is done for other methods), to take effect in PHP 9, with a >deprecation notice in 8.3.x. There's a lot more than visibility that is enforced on normal

[PHP-DEV] [RFC][Discussion] Why can constructors violate LSP?

2023-11-23 Thread Robert Landers
Hello Internals, As you may know, an inherited method cannot reduce the visibility of an overridden method. For example, this results in a fatal error during compilation: class P { public function hello($name = 'world') { echo "hello $name\n"; } } class C extends P { private