Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106831 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71834 invoked from network); 2 Sep 2019 17:28:29 -0000 Received: from unknown (HELO mail-pl1-f182.google.com) (209.85.214.182) by pb1.pair.com with SMTP; 2 Sep 2019 17:28:29 -0000 Received: by mail-pl1-f182.google.com with SMTP id m9so6689823pls.8 for ; Mon, 02 Sep 2019 08:01:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=lcKr967C39JSADjOwcXXUbUnN/K8Bcxv1WZrZfcvIbQ=; b=GbdBVbblBcZgR8LMs7m4r2xFXqX+mxPrdlkAwdLMxS3heNQl128pwU2WnyWHp9TpOH FCqmLXwpxjYOYT7D+7xrv64RGV2bB5HjWlk76+hMYYJMbY5pGrb+4UmwedeCfTxAhPSk tZ0OEkuig8GENmheEf8iwpAHej5xV4U7vu7SNmebb/Gz2s+qqqG/tEusr2V9KSgegC1C 5bmTkvfCtJZ6IvXJka3cK4tI6MblTdav3uaPNudlJxzbJr0GGXsg8B0KdtzOMaBhDL+j iG0fdzpHxtpiYl23T/8by32KE7lxUTwjthu1o1zu+bOhQ0oi14CxIj9ONza6aWghJHJ5 6+Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=lcKr967C39JSADjOwcXXUbUnN/K8Bcxv1WZrZfcvIbQ=; b=acxxnbqtvYuL1W4uQ5K6dIC23FoaslLmwbP578F+yEIju9D9N8JGvpyckH4pSiF65a bDuTDhvwCpg/UmpXqm/FqNM5JDrBUC5mJ2XwVtL3Pym/USEBhebHH5AiLf6m5VRo39H6 lieD7sB6ALUZpo6qChjOL4QGoBc3c3oNwyjAxCfKyQrUpUsud+nE7KAZ/pnw4KGYrDOB V2f/YR+g5Ts4Erj6UlwBMuXgZggBehIWwbLTYYcOSFXB3Wsn9afRqmXfXdyIrHnRX3R6 wmOsB2LDU7+a/p/zYBJQvvpmeFnh9TlHkdOoXDPSUC3Z6TAWFuVO2IkQlNCKAaoitjq/ d2HA== X-Gm-Message-State: APjAAAXlXMH9I0TuCWRzCMIZySTTiYREZz4xeph2WH1XTdTax8yiWaWM IrHvANC2fbVelGyhIZeYLu9JX8VchU3E2zujC6yeVsFmC4A= X-Google-Smtp-Source: APXvYqxlqWwvw9uZT6wDNxfsPdUgEXugXT8gJxLO1eP7NZUeNsY0pqYKBHZfZwDH505GNpQRgWT/fYA5mJ83rqm5NJ0= X-Received: by 2002:a17:902:bcc2:: with SMTP id o2mr30381566pls.127.1567436514302; Mon, 02 Sep 2019 08:01:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 2 Sep 2019 16:01:43 +0100 Message-ID: To: Christian Schneider Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Mixed mode methods From: Danack@basereality.com (Dan Ackroyd) On Mon, 2 Sep 2019 at 15:03, Christian Schneider wrote: > > Please don't shoot this down just because you are not the target audience of such a feature That is always good advice. When you draft the RFC, I strongly recommend coming up with a line of reasoning of why creating static versions of functions like this: class Foo { static function createFromXml($html) { $instance = new static(); $instance>loadXml(); return $instance; } function loadXml($html) { //... } } Are such a terrible burden, that keeping the mixed mode calling is a desirable thing. I say that as I think it would need a strong justification rather than just "it's something that could be done". In particular, there are tools like https://github.com/rectorphp/rector that I understand could be used to do this automatically, at least for userland code. 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"; } } Foo::loadXml(); (new Foo())->loadXml(); // output is // I am static method // I am instance method Although that doesn't meet your goal of allowing seamless upgrades, it seems like a better approach to allowing that sort of thing in general. At least in the sense of, if I had to explain this capability to a junior programmer, explaining that the static method is used when called statically, and the instance method is used when called on an instance, would be easier to explain that '$this' might or not be there. cheers Dan Ack