Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114083 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59127 invoked from network); 20 Apr 2021 12:26:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Apr 2021 12:26:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7349B1804DD for ; Tue, 20 Apr 2021 05:28:54 -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.5 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from processus.org (ns366368.ip-94-23-14.eu [94.23.14.201]) (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, 20 Apr 2021 05:28:53 -0700 (PDT) Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by processus.org (Postfix) with ESMTPA id 37D9A5101324 for ; Tue, 20 Apr 2021 12:28:51 +0000 (UTC) To: internals@lists.php.net References: <918bd585-0a5a-063d-7d4e-c89eadef0dde@processus.org> Message-ID: Date: Tue, 20 Apr 2021 14:28:47 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Authentication-Results: processus.org; auth=pass smtp.auth=pierre-php@processus.org smtp.mailfrom=pierre-php@processus.org X-Spamd-Bar: / Subject: Re: [PHP-DEV] [RFC] [Discussion] Adding return types to internal methods From: pierre-php@processus.org (Pierre) Le 20/04/2021 à 11:44, Máté Kocsis a écrit : > Hi Pierre, > PHP doesn't have such an advanced type inference capability: just consider > dynamic calls, or regular function invocations > where the return type information is not available. Yes I know it doesn't have it, it was a subtle way of asking if one day, the compiler may have inferences capabilities. I know it's not really possible until it continues loading code dynamically at runtime, but in some scenarios (such as preload, or inherited/implemented class type checking) it may be possible, I'm only hard guessing here > On the other hand, we could add return types implicitly, as it was proposed > earlier, but I didn't really like this solution. Return types being added automatically really looks like inference already, just a simple one, I guess. I'd love it. In all inheritance or interface implementation scenarios, it seem possible, since the compiler needs to load the implemented or inherited class code to be able to compile the current class. Any good IDE that knows PHP does the job would it also and be able to detect errors with that. > For a little more details, have a look at my initial message: > https://externals.io/message/112625#112625 Besides, I think > it's better to document the return types explicitly as a declaration, since > they usually help during implementation. > > Máté Thanks for your answer. Regards, -- Pierre