Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110630 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40323 invoked from network); 17 Jun 2020 15:07:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jun 2020 15:07:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DDBAB1804DA for ; Wed, 17 Jun 2020 06:53:34 -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, 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-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 ; Wed, 17 Jun 2020 06:53:34 -0700 (PDT) Received: by mail-lj1-f176.google.com with SMTP id q19so2990376lji.2 for ; Wed, 17 Jun 2020 06:53:34 -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 :cc; bh=0vS8wxf6SkHyGRhsbp2LqQ5VEQS0HV0kRoOb3Zw+0yw=; b=mbJu8M2BrlNuMJ6LPLti6dYvGFNAwZ5CqQS3kdl4MWyJRcBzPWxfl/7ucXw4ITZ5hW yMXkb5fHSazf9JrFyaOJWlkF2grW77ukmqJ+gLILGcEl4vj+iJNCxeBIs+mqoN8qoajU 4gQcjP7G0vpBJo2rwVHKRGF/am+dkmB/+jZcWVaYsLZ18vZ9ueCMmB+iCWHRHioxXJW7 4j6AQtYVErw5C5wPI3wzPFKK7x+Way8vNIs+o2y7sP9Z9Yv+6DS44gEzE8bC/hmUTHMB UQ2gMx0o8R3DR/MH58uf4yVcGpf4Jr4eD/Euc8+CwihTiFdWBudWRDZSHs+mI05A9TUi 4dBg== 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=0vS8wxf6SkHyGRhsbp2LqQ5VEQS0HV0kRoOb3Zw+0yw=; b=fwoSYd8JVTcm4Yd6th6Ax9/n8gYCESJuONrrDVh45hJmr+nHS/pF4NYtFE4W6hK6XA tFJ0tIcXuEHOZCHwKwNpnELvfkJU22nBDEgAFCRMakBcp636/7R0dRbLW07hZ0cqMoDc AxCtts3cNSvyZZmqNnBOBHoqb3KLhCmcw97/72CLmkU9wfRlqngO8pQKZOPkqwQpaK8q lQRcldrpXGZHaKxe9GFv7Kbg7AUZ3OXFL8JPhg7+bPvgQbRxN4wEnw2rNp3wed50reNI OhmaHUl4Tg0n/d13bJSql97id9WqFcxXuxX3OcsD8nImCHYM1zLts5vYhwrKsm9Heiji ZR+A== X-Gm-Message-State: AOAM530k38lFVpnb4yrhED6PBvFMrEJjop2+0BirGugaHSLCnb1FD/mP egbyuZzyPJBPI7mgxT7Nvqn9ZdiQFaXr/wyaVrJBByIL X-Google-Smtp-Source: ABdhPJyLMeOgOEM20l9gGOQ4fl3EK2iMOgS1JpHPcOov5ETYnZ3uqTGqOnr0NplM83kToQsEhxYQx6I24stnf1ZbY10= X-Received: by 2002:a2e:581a:: with SMTP id m26mr4184201ljb.0.1592402011485; Wed, 17 Jun 2020 06:53:31 -0700 (PDT) MIME-Version: 1.0 References: <8ADA2EC7-EE07-4429-8F84-1E5ADC7660E6@cschneid.com> <36A0AE2B-3052-4C55-AAC8-37E76C7E0561@cschneid.com> In-Reply-To: <36A0AE2B-3052-4C55-AAC8-37E76C7E0561@cschneid.com> Date: Wed, 17 Jun 2020 16:53:20 +0300 Message-ID: To: Christian Schneider Cc: PHP Internals List Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Allow void return type for constructors/destructors From: benas.molis.iml@gmail.com (Benas IML) Hey Christian, Wrong wording, sorry! :) > But I definitely wouldn't want a deprecation warning for constructors without explicit ': void' as I see no reason to force people to use it. This RFC proposes 2 things: 1) If a non-void value is returned from a constructor/destructor, a deprecation warning is thrown. Meanwhile, in PHP 9.0 a fatal error is thrown instead. 2) It will be allowed to declare constructors/destructors explicitly as `: void` (previously this was illegal). Best regards, Benas On Wed, 17 Jun 2020 at 16:36, Christian Schneider wrote: > > Am 17.06.2020 um 13:59 schrieb Benas IML : > > We should allow newer codebases to enforce `void` rules on > > constructors/destructors by allowing to explicitly declare return type as `void`. > > I don't see a big benefit in this explicit return type void as newer codebases hopefully will try to get rid of deprecation warnings and thus fixing it but if you think this is helpful then I'll shut up :-) > > > Meanwhile, we should throw a deprecation warning, if the constructor/destructor is > > returning a non-void value and doesn't have an explicit `: void` declaration. > > I'm not sure I understand the second part "and doesn't have an explicit `: void` declaration". > If there is a ' : void' declaration then returning any value will be an error. > As far as I can see this is already the case: > php -r 'class A { function __construct() : void { return 42; } }' > with PHP 7.4 gives > PHP Fatal error: A void function must not return a value in Command line code on line 1 > > But I definitely wouldn't want a deprecation warning for constructors without explicit ': void' as I see no reason to force people to use it. > > > Then, presumably in PHP 9, in addition to explicit `: void`, also enforce `void` rules implicitly > > altogether. > > Yes, that's how I would do it. > > - Chris >