Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122443 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 B203A1ACEBF for ; Tue, 20 Feb 2024 20:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1708461345; bh=WwsAg/yw7jbo0cFxDpQx2E4hvq6I19ZvFPM71q0MMfc=; h=Date:To:From:Subject:From; b=UTd115YkYNi9FNQPooS5m7PopOYdVxM4xfyeolQc+CHr9BA/zIMjgf65sM4DewqAp AoqnjX1KVX+A9ren52Gv0M9VOHr99jThKCC7BhtEZLIaPg0pjW33LDbVichCCHJnFi TZpqQeVIw5l90mhBcx9a3oHBwo5IZPaZ1Qyd0VUBjrYThQ5yEj+8pdMwxtOliesdtd ZaCR6SDdg1mAgiyMgc8Ni/alR+nizj1058eJ+0hfDDE3TtdNxIfuajCqiFAM9Ii72G vTtzsKgCNmoidneWJTjwF5Bg/0UtHq1VEpZzjfrRw101YYlnyvf3aKxcXGoXLkB5F8 cki0DPAMk8cpg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C2060180047 for ; Tue, 20 Feb 2024 20:35:42 +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.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,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-40136.proton.ch (mail-40136.proton.ch [185.70.40.136]) (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 ; Tue, 20 Feb 2024 12:35:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gpb.moe; s=protonmail; t=1708461334; x=1708720534; bh=WwsAg/yw7jbo0cFxDpQx2E4hvq6I19ZvFPM71q0MMfc=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=YTbOnyTSWUwhXkMkCUKrdSqXa58PYPOmos71rcj5LihN9XMw9ypT0qszD4OzH/b/w 0LrusmOf4aDf8vMAcUMWSXNfnsMNAk9ijMaJVG13Y3XLHaVax1HNZeF+dpPlabALM1 gAUAztMDO4HX9le3xyCgfS+sKw125/wIfCqbGuaDg86/WuhGkIqvcVv/51nCHDUqbl 6waiQ7XNwXsK2H/M8Sak0Mn0tD3f85lY64jhi7F85w0OlcvW2kc/WT+uPCndik+m4m HaxuOBN0N1NkhA8nU8Ef+rJ0OLzUNwUpV1UcByrBn8P41jqAKR6FS/X4Tv//yxrESx t1nMab2EQ8/wA== Date: Tue, 20 Feb 2024 20:35:18 +0000 To: PHP internals Subject: [PHP-DEV] Resolving self and parent types at compile time Message-ID: Feedback-ID: 96993444:user:proton Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: internals@gpb.moe ("Gina P. Banyard") Hello internals, I have an outstanding PR where I implemented resolution of the parent and s= elf types at compile time. [1] The reasoning for this is to attempt to add various methods to ReflectionTy= pe, such as isCovariant/isContravariant and other type relation methods. Currently, we cannot do this easily, as we need a "scope" with the Reflecti= onType to resolve the relative class types self, parent, and static. The current implementation uses two new bit flags to mark the type as self = and parent, to be able to preserve BC with existing code relying on the nam= es self/parent. However, we are limited in flag numbers available and using two bits for th= is seems wasteful. The question: Is it an issue if the self and parent types are resolved at c= ompile time? (when possible) In its simplest form, this would affect error messages (such as type errors= ) and also the compile time type redundancy check. [2] Note: traits and unbound Closures would still require a way to provide the = "scope" but those seem to be cases of limited use for analysing/comparing R= eflectionTypes. Best regards, Gina P. Banyard [1] https://github.com/php/php-src/pull/11460 [2] If a class Foo declares a method with union type Foo|self no compile ti= me error is thrown at the moment, this would change as self would correspon= d to Foo and the type would be Foo|Foo which is redundant