Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103530 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 87956 invoked from network); 29 Nov 2018 09:19:12 -0000 Received: from unknown (HELO mail-pf1-f169.google.com) (209.85.210.169) by pb1.pair.com with SMTP; 29 Nov 2018 09:19:12 -0000 Received: by mail-pf1-f169.google.com with SMTP id 64so456514pfr.9 for ; Wed, 28 Nov 2018 21:43:15 -0800 (PST) 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=9THIU3tVVjGczngt5rQLSOk3TSMcuoiDnnGVvesnGLE=; b=og+feHLoQ9uuI39k1muun2SoOl6PtzJjjI9Di0J3hFShqpI+qfBrwhVkOFYKZfuwbb DypkkrlxJoI46LYfFLfTM+GYS8u9wOUXpG9i9Hkpi89nMPTVHSMYygpFDd2NwFzb3M7Q SnSgLtH3qc/xUj4fUJksunmDjfYMrxbmQqLV6qxjpRKC1T189U9cSAQ/26SQHbxgOeMs DQw7URMJMbhqcZdrxh3FVCgkt51Hy1ZqddhzM2THZUEtd+l/i7JZH3cnOhF7jv3VjPHc 8sPdGGG/Cy27aIWv0PSIYCY3JSiJy09mtY5Nph5fvGbomJYPTHdorHJ1BMjxYAu/p5IK 2Q9w== 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=9THIU3tVVjGczngt5rQLSOk3TSMcuoiDnnGVvesnGLE=; b=cO0x+l2EWjRpgIk9vDJA+s83ZkEUJC6CMVGkMD8EGnrrxwDe2oi5c3NciBvDatp7kQ 8iAeos5//un20cNs8kp/JxLtGcs0L1CuGwBJKNLTbCVd1WyyBuDFWvsc9nE+Bg8aLaHg vorWuMCllaOBDoKuZp4FfUfMjxGcR03JL/tbwmqfY+yOQjLOkPdcsGpcxFnXqRr3SLoK Ufgo1fyTOFowgn5Qiuv3Ibk/CbO8K6Qp3TxtCR+MWve7SiC4H4HR/wsput7eK50L3baM 88Fcq5FdBr9XbBiinmA9ITd1qtTqbmltRIXr31xoVuIdBTq8Ppj/oNUh64L51GavOBNZ yFsg== X-Gm-Message-State: AA+aEWYpSvVBo/oBhjUodzL/CzHJzq95fSrljq1mVY8qJN/HVelyEd/c MYhmVbcrW6ovoSjdeJbiT3ivTHJiXrgYRjI5xSDkMA== X-Google-Smtp-Source: AFSGD/XVHVPx8G2DoyO7rAwZk/+9X7P1dU/48d7dCkpENaxZp8nAWsqFv4XvrA/GfesSmImK4LpPQ65QcqFigJMXqR8= X-Received: by 2002:a63:3204:: with SMTP id y4mr126609pgy.41.1543470195252; Wed, 28 Nov 2018 21:43:15 -0800 (PST) MIME-Version: 1.0 References: <2701692.XuXcyRlYA4@vulcan> <1729885.aYpoBY8SBC@vulcan> In-Reply-To: <1729885.aYpoBY8SBC@vulcan> Date: Thu, 29 Nov 2018 05:43:04 +0000 Message-ID: To: Larry Garfield , marcospassos.com@gmail.com Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC][Discuss] Covariant return- and contravariant parameter- types From: Danack@basereality.com (Dan Ackroyd) Marcos Passos wrote: > Supporting `static` return would come in handy to define interfaces for > immutable objects. But it's not a requirement, right? With this RFC, the following code will work: class ParentImmutable { function modify() : ParentImmutable { ... } } class ChidImmutable extends ParentImmutable { function modify() : ChidImmutable { ... } } Why should the RFC be expanded in scope to enforcing that child classes use more specific types? On Tue, 27 Nov 2018 at 21:16, Larry Garfield wrote: > Levi, is that something that could be reasonably added to this RFC > I don't know that a static/self parameter declaration is even a thing Currently, static, self and parent are really more syntactic sugar that only apply in specific contexts, rather than actual types. This is a great source of sadness when it comes to their use in 'callable': https://wiki.php.net/rfc/consistent_callables . If I (or some other brave soul) finds enough fortitude to pickup that RFC, their use in the language might decrease. But more importantly, expanding the RFC from 'allowing variance to happen' to 'enforcing that child classes use variance' seems quite a big step, and would really need a separate strong rational of why it is needed, and why the added complexity is a good trade-off when it doesn't seem to be required for the use-case that it is being suggested for. It definitely needs a stronger argument for it, other than just saying it would be possible. cheers Dan Ack