Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122593 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 8A6CC1AD8F6 for ; Sat, 9 Mar 2024 14:17:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1709993877; bh=sm5zYPNpbqVAsJ5vNxr2QZl1H5tN2+CSEyuXSRnvZSE=; h=From:Subject:Date:References:To:In-Reply-To:From; b=OfnS4F1eBq/Nix4Nfzy81iCcsDccvyhoyDdYYe8zHSdwvnY+l1eozaRXmggC+Vc1t 4PuFu80pm/o31IHj24AdWXhQ2j/v0LtWolpo0U4z1emnyqHyeeVRyWzspXx2ExdND1 TVvR8DvFLO5Xb8HWQlf814idvP42+qk6LmvkRw/1Guark2w7Ad8UnVAynTh/v5dsSQ hZzVO1fSkgZ7j3JRIbeIenEZxj/tV3CN/Eh8r8JOWmmSvS/rB2hCzS2qsZYdqZxpiQ vwehgu89dPhyectMaict4KYbviaApsRyMWi76Qn7u9wQiTcIVK/meTU+1qVyn2SLKp c2ROdqSAGR5/g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CD4E8180032 for ; Sat, 9 Mar 2024 14:17:55 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail.gna.ch (mail.gna.ch [212.45.196.109]) (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 ; Sat, 9 Mar 2024 14:17:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by darkcity.gna.ch (Postfix) with ESMTP id 528253A0DA8 for ; Sat, 9 Mar 2024 15:17:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=cschneid.com; s=default; t=1709993859; bh=sm5zYPNpbqVAsJ5vNxr2QZl1H5tN2+CSEyuXSRnvZSE=; h=From:Subject:Date:References:To:In-Reply-To; b=Tc9B/JAdLSE7/e3cfiavkacoBWG3oUWAfAI6SxvDfT1nszoh0NryUhkOUITSBJP6M 1jJ42N+vrtTRlT/RPSoA2XvA+TFv7ML/4np9ftAWfPHKgPy/1glvgPn0z5uMtpUkQ7 y5FqIASQLrofJW5Mx3nwtxgeODWkNdNvrib/uMZA= X-Virus-Scanned: amavisd-new at example.com Received: from mail.gna.ch ([127.0.0.1]) by localhost (darkcity.gna.ch [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CUhvm5z3HaVS for ; Sat, 9 Mar 2024 15:17:38 +0100 (CET) Received: from smtpclient.apple (unknown [IPv6:2a02:1210:2ea4:cf00:518f:5991:15e1:4e1e]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id D38FA3A0CFC for ; Sat, 9 Mar 2024 15:17:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=cschneid.com; s=default; t=1709993858; bh=sm5zYPNpbqVAsJ5vNxr2QZl1H5tN2+CSEyuXSRnvZSE=; h=From:Subject:Date:References:To:In-Reply-To; b=mlcw39HJ4/vkRfL0+Bg4B8ZgfYtM2smfFPl+toy4pjs12hv3ZwSoHKYajPjcLQATg ippmvFesoBMaZEIkR10l/FfWb15QeD5B5SOjCvXQnzUnA4oSEyigHkay+IEWhTGOSK Bmqok37fXtiJ48KRr6r4007zXq6mVTpMNeg/XYwk= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.500.171.1.1\)) Subject: Re: [PHP-DEV] Idea: Implicit inheriting function argument & return type-hint Date: Sat, 9 Mar 2024 15:17:38 +0100 References: <5ac38d16-4b70-428e-ad80-87ae54839622@mabe.berlin> To: php internals In-Reply-To: <5ac38d16-4b70-428e-ad80-87ae54839622@mabe.berlin> Message-ID: <1773BB80-D9BD-4A0E-B01B-0A9EF402174D@cschneid.com> X-Mailer: Apple Mail (2.3774.500.171.1.1) From: cschneid@cschneid.com (Christian Schneider) Am 09.03.2024 um 08:18 schrieb Marc : > As the pseudo type `mixed` exists since PHP 8.0, which is already = out-of-date, I have the feeling it would be better to force people to = explicitly write `mixed` to widen the type of an overwritten function = and let "no type" inherit the argument and return type of the parent. >=20 > Example: >=20 > class A { > public function typed(int $var): int { return $var; } > public function untyped($var) { return $var; } // implicit mixed = as no overwrite > } > class B extends A { > public function typed($var) { return $var; } // implicit int as = inherited from overwritten function > } This sounds like a bad idea to me as I cannot look at the function = definition in class B and determine what the type of $var is. On top of that: If the type of $var in A is changed then it would = automatically also change in B. While this seems convenient it could = also break B in subtle ways as the function suddenly gets different = types than expected. Regards, - Chris