Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110841 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 68423 invoked from network); 3 Jul 2020 18:34:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Jul 2020 18:34:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 198F9180566 for ; Fri, 3 Jul 2020 10:24:19 -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=-0.4 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,URIBL_SBL, URIBL_SBL_A 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-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) (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 ; Fri, 3 Jul 2020 10:24:18 -0700 (PDT) Received: by mail-lj1-f193.google.com with SMTP id q7so24596392ljm.1 for ; Fri, 03 Jul 2020 10:24:18 -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=zfUdsSvTFZgdBUPRH54X2K5mBKwcUbrqjTp53VNHuK8=; b=TRDgpQGZwVxu9jVOirZ53qJy4kbzAveWQnWJym2FfSmwJwQMHDDvoqMnOwU9IfuPoy E798fOJhY9cWv+fq9dan9IOVyqmjzgZhNRfoAFOTqmttpf9WW/EEe1IkGiOYmNERuwsI LiMbKdtiRhrnZGzrj6F5Z3rWgyr16xDBBw94pgRBr1iodogUubFeaf0NOcKHAOXaNMwB JD6jKNpEEdq33aqXO9qVk1X2Opsrs7U0Q+9ZRqNop93wfeyQGaHZtes4y0hAYgVVVtzM 3EHB7KVOIkxGOWSu9YfISwRJ8BCxJeKwimnR71arGBo1mdyHbcOknO2mUIS0/ghV0U8L kJ2w== 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=zfUdsSvTFZgdBUPRH54X2K5mBKwcUbrqjTp53VNHuK8=; b=gGyp+vsPh1jGNPCtHHgX+vmipVSU9ASxKXtYj8J5TbzBFrz4DqqZ6NPih9CRMaCg/Y wRriRRfUMzOUS78/Ku1KbRLSQ+P1ZDiVU/QfZGGU0q5PGZmDGBCO0L6IzOEl6Nlpr/NB hnmkwYmkaQ0m6yVu3BMsxfCeA0hXiZn2HXXzsY690LWf2sV0fLfYNWKolP5Oq787N+iQ JurfmrQbbCi+wHAk8eH7OQ4f2XrFhkh4EKiPnOFBY1xOSnXMFk8OZly64dnY6Fr0QLU2 Ao7peh4hC6xRrV64J/rD9VuK/nwo3xwl8BhIJ/qzoN0b8FC38JTmAh21UXR89NN2A2cw y4SQ== X-Gm-Message-State: AOAM5304bTyIsWWUDrjyIrnPQizLFXKdNkB2N67cuIdWUJpQUUqA7RxI KfKzEZTp4IOA7YCt4QX7AqF+EOHyk/5/bhQpQUc= X-Google-Smtp-Source: ABdhPJwPOahOBdEU6MmuJryytAICDpbiHm9VzbxPaSAM7nLG3iH7RmujSYCNvKfztN2wOrq3v+a4BeAVFn8aKEjbXHQ= X-Received: by 2002:a2e:50b:: with SMTP id 11mr20465471ljf.458.1593797056306; Fri, 03 Jul 2020 10:24:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Fri, 3 Jul 2020 20:24:04 +0300 Message-ID: To: Theodore Brown Cc: PHP Internals List Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [RFC] [VOTE] Make constructors and destructors return void From: benas.molis.iml@gmail.com (Benas IML) Hey Theodore, On Fri, 3 Jul 2020 at 19:52, Theodore Brown wrote: > > On Thu, July 2, 2020 at 4:12 PM Benas IML wrote: > > > I have opened the voting for the RFC, let's hope everything is going > > to be smooth :). If you have any other questions, let me know! > > > > RFC: https://wiki.php.net/rfc/make_ctor_ret_void > > Hi Benas, > > Thanks for your work on this. I'm in favor of deprecating the ability > to return values from constructors and destructors to align their > behavior with the documentation and how most other languages work. > > Unfortunately, the RFC doesn't provide an option to vote just for > this. Instead it only offers combining the deprecation with a new Quite honestly, this would also question why the "Ensure correct magic methods' signature" RFC was introduced in the first place since it also limited some magic methods to only having a single type (if declared) i. e. `__toString()` might only have `string` return type. > option for developers to choose whether constructors and destructors > are explicitly typed as void. > > But what will be the benefit of typing constructors/destructors as > void when this is the only allowed type, and after the deprecation > adding the type won't change anything anyway? It will lead to a > situation where some projects require the explicit type, others > require not having an explicit type, Same with the `void` return type in general. If you go onto GitHub, some projects have an explicit `: void`, others not. Every single feature is used by some group of people and isn't used by another. This is again, a rather subjective thing. ...and for more arguments, please read Larry's, Rowan's and my replies on the original discussion thread since I did go into mor edetail on this matter. > and the rest have a mishmash of > the two. This will lead to further bikeshedding in projects and > unnecessary code changes. If this was the case, we would also see a ton of tabs and spaces' mixed together in projects but we don't. > Allowing an explicit void type on constructors is also at variance > with other languages. For example, TypeScript does not allow > constructor return type declarations. [1] Nor does C# [2], nor does > Java. [3] Likewise, C++ constructors do not allow an explicit return > type [4], nor do initializers in Swift [5] and Kotlin [6]. ...and also please call constructors/destructors directly in any of those languages like you can in PHP. I. e. `$object->__construct()` and `$object->__destruct()`. Unlike in any of those languages, constructors also don't look or behave like constructors in PHP so comparing those languages with PHP doesn't make a whole lot of sense. > For these two reasons, I voted no on this RFC. I think it would be > fine to deprecate the ability to return values from constructors/ > destructors, though, and this could happen in PHP 8.1 if there isn't > time for it to land in PHP 8.0. > > Best regards, > Theodore > > [1]: https://www.typescriptlang.org/play/?target=7&module=5#code/MYGwhgzhAEBiD29oG8BQ0PWPAdhALgE4Cuw+8hAFAJQBc0AbvAJYAmK6mAvqj0A > [2]: https://www.c-sharpcorner.com/article/different-types-of-constructor-in-c-sharp/ > [3]: https://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html > [4]: https://docs.microsoft.com/en-us/cpp/cpp/constructors-cpp?view=vs-2019 > [5]: https://docs.swift.org/swift-book/LanguageGuide/Initialization.html > [6]: https://kotlinlang.org/docs/reference/classes.html#constructors Best regards, Benas Seliuginas