Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:113516 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 49765 invoked from network); 14 Mar 2021 16:08:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 Mar 2021 16:08:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 286821804C0 for ; Sun, 14 Mar 2021 09:01:56 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 14 Mar 2021 09:01:52 -0700 (PDT) Received: by mail-il1-f169.google.com with SMTP id e7so7129255ile.7 for ; Sun, 14 Mar 2021 09:01:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=OS5DnbGhHFiG6YArkhraOCHaxO9TEB4dTBsEqYAiwt0=; b=Gvxr/aMGTUJ2A3Qkj0xz0F2iGd21o6W/w+pqvXbZGlsitdrVw+ocemQLIS2Zysy+H4 bE2cQh7dQ8IMCWndGBoj07rayxFpVnoFfgcCYrh2/MyNOf6+RpZidmu7dJ/W3R1zvK3i 4DK/1s8Wfvt9wCQVjHChccX8eWbI99D9H1QVYL3oiKBe5PWcjrFWD2tWszIUKNeZ9Alw FL9CiM0gl99kmM7BVY2GoeYULgEMuWrCiaKnoEbLHxyFBNOy8KlxXa5qSupdvV8Bqr9h mMch62AkOFcc9iV25VBPk9FdBPbP36r0w+OKO1lIaT6ZMwlGz/4tqKTfGvE8OS7chkxn IsWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=OS5DnbGhHFiG6YArkhraOCHaxO9TEB4dTBsEqYAiwt0=; b=ZSTTBdb3oIMZw/cBrotgrOFar2tSgb999IwD4i3nZwMDEMijF0Cv/hGEmU85q1oMnl sxRYuRIAhYkxz096rKh/0T46vR2iHlaPwPrrqnxhSOHywM4w5t8d3lafPObKxGGy2cQh HriwIH/Y+4R3SVsWDc2ZDOvHMFHH3TNq2/bS68i/Ap+9L1/luahYSvKmQ1baAgZauXoj y72OD4aBXbN9kdDw5Q9/+PpJ1Im6Eo3APOzFuyb4LjbJpIpz6xDSdBZFWUXso2upo/Yp bpCRKcKxqTy/3ceNUbUsaREyEkzfhW3GwQgCbxyy3Rx2rSEjl2KSxghClA2b3z7HE5SG L9Tw== X-Gm-Message-State: AOAM530KcokBb3OjjS7AhJo6ksdtREP2sseP2bGZxNrpom8ExkmeRp9M 4h2FBnIYvR/w/gg3LGA45ukGl+iifOnsouR4Q2fBFG4BPbnKoA== X-Google-Smtp-Source: ABdhPJxxaX6kwRSkuJs+icpSZ1wPboWX8Twg3nqlNNUBZNye9451B0VCcGjo5fkkmDZBdTVOp21InReuqS88Xq7ig7o= X-Received: by 2002:a05:6e02:188a:: with SMTP id o10mr7080150ilu.12.1615737711743; Sun, 14 Mar 2021 09:01:51 -0700 (PDT) MIME-Version: 1.0 Date: Sun, 14 Mar 2021 17:01:41 +0100 Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: [RFC Proposal] Allow methods to 'become' static From: gertp93@gmail.com (Gert de Pagter) Hey Internals, Recently i've been working on an older code base, where we have a lot of classes with all static methods. We've been moving to injecting the classes, and calling the methods as if they were not static. I wanted to add interfaces to these classes, with non static methods, so we can pretend in our implementation they are not static, and allow us to easier switch to non static methods in the future. This is (currently) not allowed by the language: https://3v4l.org/WKdvM Is there any chance of this being possible in future versions of PHP? This would only allow 'normal' methods to become static. Making static methods non static would break Liskov substitution principle in PHP as you may not be able to call the method in the same way. This means you can't have a 'normal' method become static in an inherited class, and then become 'normal' again in another inherited class. This works the same way with co/contra-variance in return/parameter types: (https://3v4l.org/j1SO9)