Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110629 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 36795 invoked from network); 17 Jun 2020 14:50:27 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jun 2020 14:50:27 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5D26A1804A8 for ; Wed, 17 Jun 2020 06:36:09 -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=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS1836 195.49.0.0/17 X-Spam-Virus: No X-Envelope-From: Received: from darkcity.gna.ch (darkcity.gna.ch [195.49.47.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 17 Jun 2020 06:36:08 -0700 (PDT) Received: from flatter2.home (156.178.79.83.dynamic.wline.res.cust.swisscom.ch [83.79.178.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id 83A386C0C68; Wed, 17 Jun 2020 15:36:06 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) In-Reply-To: Date: Wed, 17 Jun 2020 15:36:05 +0200 Cc: PHP Internals List Content-Transfer-Encoding: quoted-printable Message-ID: <36A0AE2B-3052-4C55-AAC8-37E76C7E0561@cschneid.com> References: <8ADA2EC7-EE07-4429-8F84-1E5ADC7660E6@cschneid.com> To: Benas IML X-Mailer: Apple Mail (2.3608.80.23.2.2) Subject: Re: [PHP-DEV] [RFC] [DISCUSSION] Allow void return type for constructors/destructors From: cschneid@cschneid.com (Christian Schneider) 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