Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123831 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 5EFD91A009C for ; Tue, 25 Jun 2024 17:53:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719338114; bh=50WeiaOVmGC2/gBlprEBe/6ZgzKStfQKVLSiRvYu4yk=; h=References:In-Reply-To:From:Date:Subject:To:From; b=PC6SuHVZW9zxKcMjOg4cwEW4sflEEd4xMOIgneQ5PDbeTeZpjfYIfnWR4hTdQw5LZ kuJlaWADWNXDTO3mDlzofJ2wAUExoXwJMUmK4qDY3UYKQ7d1rIavsOGNx/g9iFolpe y40qSK75giFp/vtDe4zmOgLmb30eWO5C93WrfV7TBYA8RdDEI6fiVFwgXdf3q/petU LYTyBsV2sy+mie4Dk6Vi4MLLZfas0emOeE8Z/f1DtI6toeMolCN/Lpkj0Uq6khC/vM TdQpJ+pvDXBfJTkjrywLKBnKG9PChGgSDfbo9Uxnt6y1uysDxJRh/z45hopgewRwQJ myyXO5glUTx1w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7EDBC180595 for ; Tue, 25 Jun 2024 17:55:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 25 Jun 2024 17:55:13 +0000 (UTC) Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-57d1012e52fso6750876a12.3 for ; Tue, 25 Jun 2024 10:53:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719338034; x=1719942834; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=RXJhmvMGO4OgoufJF8G3WDLdZ0BkB/oBjSu0It2/kfs=; b=dm8lEvGGJX4MfDttsKp8unfYNeeuJD+Bl/Ej7qTKuPtUQj9ksTS39SpsQWeXpuwC88 M6RLtIdI2oqu0tG6+m7DLd3kAVIblobPkWGwUXTiEaFXXOw2cKO0Bd8sNKZTlt/7vNtm obJVkyeOEC5fOpppxoQrbJzbxUMYGqEbXjPQVnPtsPr9b8FPgmJH2q4eza2sczmR0f+t /ium6bpZoRC4viKx7uxteE+XouVDVA3ALRfbREUlHFlIYhARagoIu6mOsVA7p/F2r382 6mK7XefbDHZhGUZAVkp5skr7L68NJXdyzGn2nHg47AsB+dItlSYMTXshL9bkzvm3Swli rPTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719338034; x=1719942834; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RXJhmvMGO4OgoufJF8G3WDLdZ0BkB/oBjSu0It2/kfs=; b=CBnlfIydJYf5SV+L/GqJm8dxa+ykMgQ62pMtyQkOf+mU5E8Jmm/GSU/37Db1QTDBa7 /2udWAa+A153YgRJ5hAzPTzi8kiVD/aHpycowWm+LJs7CVRW+XulVmgUidM0RFsGLek3 tJdEy5Dclv9JhXihD98EMTRf33GWi25kCPNl7CWiShNubvFqboCjJi4qcCAyj+L8nRXQ esRBLxMNelXW4nOW9/FanFzwXsM2dn8Xm8/+pwn5TQwe6R1xb2AzRVS4+eSm+QNI+YZe ZfWy7Cqk1TbdQPX6CRVtc7guq2y1E5wKpGfZiA3AYElw4RdF8XxyOJbBBF04c5KaBufT +EmA== X-Gm-Message-State: AOJu0Yzl1x6CXruwLIg2xCZ+Y8N9OYo3yXspcEtDfwmrF+2nF06lVoJ3 vUg/2hO/OI9qfI1AyHOn2zOVgm9vsCcQ18ILJ0OIN2iznD/pfjrVYACMFEtwwcmvmehYiQitWXI bVBhJpqOpLFr1Jn9qFGmyHnoBYNCjV/nr X-Google-Smtp-Source: AGHT+IHCYPpIgVNksN3laIQaHKUBp6S/+kZbFmf19GSHSEUzfTmtzEVSFyELQbOP3ifZRe0Amo2AVtwJsOJ/VRW+ICk= X-Received: by 2002:a17:907:8dc6:b0:a6f:e25d:f6a4 with SMTP id a640c23a62f3a-a7245c642e5mr575767466b.76.1719338034047; Tue, 25 Jun 2024 10:53:54 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 25 Jun 2024 11:53:42 -0600 Message-ID: Subject: Re: [PHP-DEV] Add $this return type To: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" From: radar3301@gmail.com (radar3301) @Alexandru: > Worth reading: Ah shoot, my search-fu failed me (it's not listed on the RFC page, and I suppose I was not using the right search terms). I'm glad to find out this rfc previously existed, and in that case, I guess I'd like to revive that discussion. :) @Luigi: > The part that I do not like is the implicit return: it may confuse developers and static analysis > tools. I understand the implicit return may be somewhat confusing, but one of the secondary driving factors, aside from a much clearer API signature (without requiring a docblock comment), and engine enforced object safety, was the benefit of reduced "boilerplate" code. However, I suppose I can accept that this may not be possible, but I would like to discuss it as a potential option. However, I disagree with you about the static analysis tools. > Is it possible to replace "$this" with "this"? Cleaner and coherent with "self". I actually thought about this a bit before posting, and I came to the same conclusion as Nicolas, i.e.: /** * @return $this */ To quote Nicolas: > About the syntax, I think the one proposed in the RFC is crystal clear. I've been used to seeing > the "$" symbol [snip] More on this below. @previous commenters on the old thread Andreas Heigl said: > If we allow a $this [snip] as a returntype to clarify that it has to be the same instance that is > returned, I would also either expect that the returntype 'self' does explicitly not allow the > same instance to be returned. As that would be a huge BC break [snip] we should implement a > returntype "!$this" to explicitly state that the contract here returns not the current instance > but a new one. Strongly disagree. This would be too much of a BC, and I don't really see the benefit, even allowing for a "!$this"-style returntype. I'm not opposed to a separate RFC or discussion regarding this, but I don't feel it's appropriate here. Sebastian Bergmann said: > [snip] please not "$this" as the name for a type. > Off the top of my head, I think that "same" could make sense. My primary vote would still be for "$this" as explained above, but I could potentially be persuaded to switch to "this" or "same" as alternatives if the dollar-sign is too much of a hang-up. Regards, radar3301