Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110599 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 54959 invoked from network); 16 Jun 2020 15:58:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 16 Jun 2020 15:58:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 550EF18055C for ; Tue, 16 Jun 2020 07:43:58 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) (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 ; Tue, 16 Jun 2020 07:43:57 -0700 (PDT) Received: by mail-il1-f179.google.com with SMTP id b5so19084181iln.5 for ; Tue, 16 Jun 2020 07:43:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=slehPWMZraBE0VNagAROkxVTQMFdeQZ3/3FHvt2d4+4=; b=Owd7bQAXsnZEQYf5vfTD+ltbWWXdWj4llL9/mDeg1rKXB+VA/dOtc1ye8xkn5cEpqo 8LaqUZMqehoatJ47ntnTb/dFQN24LjL80xZqIl6Rnq8EiyBCzlUb4gi87CjBAAMDoJHI D/MhUtM/qaLQo7hfvIFgwNnVsgCgi3ii5jf5zZMZeVlUMcjr+9zaadMSMiM8uizEZQS/ OHlWydNB9db1l+6U9xM3/eJgeFUpVTdxPHIArTJtsIm/L4J5czl0AkcYMgkELoMf0ioX pUO3U9a3b2KV7qaNc19XPzqjPyfuwlbzfosIIA7FC74Gu2/cm1m+8WTVQiMrkQCiwQLI P4bg== 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; bh=slehPWMZraBE0VNagAROkxVTQMFdeQZ3/3FHvt2d4+4=; b=FNBxrjBaFhVOKt5v4/acVkvdgTh8OB9syKebmEE4szs44WLFm/GGWVxBpPh+SQtO4p hl19uAh7quJNH+1bhjeI1NiK5gsI3ehV/+GB/v36ELQV4pVBBa4Xs5wPUb3/t2Ae6I6a DOFybjgGlaovcw+XIszgYyFFdD/Ix4BCBecV6UyOiw41LaLzqUMVuEg4yOWQ9QHiWV5o gf0kjLPl64ejrhbVYnRKGY0iD2up+MrsvfqaZRNPbAMqDYAvSr5hU5isU+I592AeDGPU pC4tMEU3AZbF/mcki0zDa1C9EnLAnEgTVOLd2fd1edkudXSa8BYqlLO5IodMsPpDtu9q xHPQ== X-Gm-Message-State: AOAM533NQ/Oi/6Ar8Z5HC/2Om1xk7G78iP/gTFkyVGZqUZki9n7y2cKE sy2wCufBrmsMjoWKOIA3oc02hw8BjPpkJyQDyouWaw== X-Google-Smtp-Source: ABdhPJwIIVGLUUIo0iZrZs6GvOiiiBBwDLt7oojQv7/BL2lOAqmWME/Mky9ykM2/bfz6Eegu3VXDEW/Fjt5dggfqElM= X-Received: by 2002:a05:6e02:49:: with SMTP id i9mr3554771ilr.236.1592318634798; Tue, 16 Jun 2020 07:43:54 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 16 Jun 2020 15:43:42 +0100 Message-ID: To: PHP Internals List Content-Type: multipart/alternative; boundary="00000000000098b2b905a8349258" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Allow void return type for constructors/destructors From: rowan.collins@gmail.com (Rowan Tommins) --00000000000098b2b905a8349258 Content-Type: text/plain; charset="UTF-8" On Tue, 16 Jun 2020 at 13:59, Dan Ackroyd wrote: > To be clear, I'm not sure if I am in favour or against the RFC. The > real problem is that constructors just don't fit into how we think > about normal functions is PHP, because of the magic that goes on > around them and so both void and null as return types would be a > little bit incorrect. > I'm not clear what you mean by this. The definition of ": void" is currently that the function must either use "return;" without a value, or conclude without an explicit "return"; a correctly written constructor would meet that constraint. The language doesn't currently prevent void functions from being used in expression context, but even if it did, that would be consistent with how constructors are actually called internally, which is roughly equivalent to this: $newInstance = initialise_object($classDefinition); $newInstance->__construct(...$args); return $newInstance; If a constructor returns a value, it is simply discarded, so a signature of void would be completely appropriate. Regards, -- Rowan Tommins [IMSoP] --00000000000098b2b905a8349258--