Re: Mixed mode methods
| From: | Christian Schneider | Date: | Mon, 02 Sep 2019 16:02:44 +0000 |
| Subject: | Re: Mixed mode methods | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-106832@lists.php.net to get a copy of this message | ||
Am 02.09.2019 um 17:01 schrieb Dan Ackroyd <danack@basereality.com>:
> Also(, without checking to see if it's feasible,) to me a less
> surprising approach would be to allow static and instance methods to
> be declared separately with the same method name.
>
> class Foo {
> static function loadXml() {
> echo "I am static method\n";
> }
>
> function loadXml() {
> echo "I am instance method\n";
> }
> }
I was considering this approach but that is a special case of Ad hoc polymorphism
(https://en.wikipedia.org/wiki/Ad_hoc_polymorphism).
And that's a path I don't want to go down, I don't think that's a good fit for
PHP.
It felt more natural to model it similarly to nullable return types.
- Chris