Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126894 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 75C2F1A00BC for ; Fri, 21 Mar 2025 11:50:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742557691; bh=aarlqUXH0e2+WlRF12rWQeaWmVp2gbOsLAx6rOvqr+s=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=SnrIz8Cz5ZNTL6Lq9fQ/mK9jKVEnhQrJ279YynN99V1+++xrSp+f4087MM/pRRGL+ Ge92t2O3cnBovI/Y1SBylnhhbJytUiGuN/bhfJDZfUfpLtLAog3r5fKAYEC10HHUwH NNUBb/N/pnAjPC/+pS1rWqR9ZQgbL+xlCBp96ImAC0DEkx/V2tSDwBNhSjHUqOHPle qsYvgkmalbaNPIeQUwUf7zgCeGT6eJFNk9FBZ7KDZ76vV0UZBhF/PEIkR31N4eEr1l qGop2t/FfXs16rk8ASp5mUKvqmQ8Ppq97L621MApFI/88eQ2y3pOKL04eEoDKxhurx ZSRFyTBSqThGg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DDC23180556 for ; Fri, 21 Mar 2025 11:48:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-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,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 21 Mar 2025 11:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1742557839; bh=OffxX2j0XjDO6zhBHROGdMGgNFbdEEr2OMTeft+jC9g=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=fFIG0dCBte4Y2cXfKW9f6p/1PALfo0eYqUFZjdHINxCABHPEaB31zUc7//s/+eq2j cDPbObnJaRhh/oJ/RYU6kRhoOarbXT+KWcw1APXbQPQwnpDaAiZTIuqSJaQfROaxAJ gdkaQYZq8doTz7JVG+RSmYy8EA6tf45rLOfSd/z5xko+eJ0tgsrr2QTDil0Xl9evez nigfg1ttIXzaWLaAl8LkoRkVLkMXtcMXk1O4qckEXI1gRJvUv+ovQSc5ehjMw2nY7r /YpsjDGKUaXCNV+84pGJMf3JEV+J97M2GUTyC0M6vcZiGLbBzyZmvb9eKqSBseBEBv bquAYsyfbAzpQ== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Fri, 21 Mar 2025 12:50:39 +0100 To: Matt Fonda Cc: Daniel Scherzer , internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] [Discussion] Never parameters In-Reply-To: References: Message-ID: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-03-20 21:27, schrieb Matt Fonda: > If an interface adds a method but makes no promises about what > parameters > it accepts, then why is it part of the interface in the first > place--why > add a method that can't be used? It would more cleanly allow for userland / PHPDoc-based generics, while still providing some engine-enforced type safety. Consider this example (not sure if I got the syntax completely right): /** @template T */ interface Comparable { /** @param T $other */ public function compareTo(never $other): int; } /** @implements Comparable */ final class Number implements Comparable { public function compareTo(Number $other): int { return $this <=> $other; } } Without `never`, the `$other` parameter in the interface would need to be `mixed` or untyped, preventing the method in the `Number` class from adding the type to the engine-enforced signature, requiring it to check manually inside the method body. To me this is another good example of how a small engine change can improve the safety of the language for all users, even when third party static analysis tools are required to make full use of it. Best regards Tim Düsterhus