Re: Remove LSP checks on static methods?

From: Date: Tue, 16 Jun 2020 07:37:01 +0000
Subject: Re: Remove LSP checks on static methods?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-110563@lists.php.net to get a copy of this message
Hi Mike, wt., 16 cze 2020 o 08:59 Mike Schinkel <mike@newclarity.net> napisał(a): > Hi internals, > > Given that there appears to be some appetite to reduce checks for > inappropriate signatures[1] I am wondering if anyone has strong opinions — > pro or con — on removing checks for static methods? > > My primary use-case where I would like to see checked relaxed is for > static methods used as factory methods[2]. > > Per [3] it seems that all but the least upvoted answer argues that LSP > applies to instances, not static methods. > > Per [4] it seems that all upvoted answers agree that constructors should > not be constrained by LSP, and since a factory method is a form of a > constructor it would seem that if constructors do not require LSP then > factory methods would not either. > > Does anyone see any issues with relaxing these checks for static methods > that would have them downvote an RFC on the topic? > I can only see a one huge BC break. What you suggest would require the deprecation of static methods on interfaces. Currently, you can declare a static method on an interface, like this: interface Foo { public static function create(): self; } class Bar implements Foo { public static function create(): self { return new self(); } } var_dump(Bar::create()); Hence it'll be a huge BC break and the first reason downvote to the RFC I guess. Cheers, Michał Marcin Brzuchalski

« previous php.internals (#110563) next »