Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130443 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 lists.php.net (Postfix) with ESMTPS id C445F1A00BC for ; Wed, 25 Mar 2026 07:37:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1774424261; bh=mKd2gVDKfmR61GVuX74QRC3Cit8K3TWsaZAcUJgCYJA=; h=From:Date:Subject:To:From; b=A0IK9IVrjGOWzYmrpkoiXYcKNYIlmblCZcYI4WfEW1MOA7bipxXHSIJ54/QdICnXG ByGGNGjT1kd0N9uxnX35yHgpsbeTUL+S/ssy2vNBt6TXZbk6syMevLLForjMnR9zzF 40AQxqNkWoZ7dpLKQDYUNAkLWIymdapb4xFK5rkjxE/HCAbLPLUAdMe0CvBgwuejhY a6rTGbeqb3PnXp4J1Bq6PsHtVGga+6Yj6asxPd5YqzhkQvHerukr63uDcWav49SNP+ C0p42W8qoN72VL8SgUL8myq/S1g62CVBIsiNLhk3zfX/P09WOXV6R+hczLVfqGyxHA 9sFiNjndl5k2g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A203D1801DA for ; Wed, 25 Mar 2026 07:37:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,DMARC_MISSING, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from developer-rob-server01.developer-rob.co.uk (mail.developer-rob.co.uk [35.176.203.165]) (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 ; Wed, 25 Mar 2026 07:37:40 +0000 (UTC) Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (Authenticated sender: contact@developer-rob.co.uk) by developer-rob-server01.developer-rob.co.uk (Postfix) with ESMTPSA id 5974F88CA6 for ; Wed, 25 Mar 2026 07:37:34 +0000 (GMT) Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-8cfc1aced74so733345785a.2 for ; Wed, 25 Mar 2026 00:37:34 -0700 (PDT) X-Gm-Message-State: AOJu0YzSv4auKcmRSVXPXf2pgeCR2GV7k9NAXuJ6D81uHQeKtjbhG1gm M1KrEGAeY2DFTOSdTXkTnj74yA8+K13K3z8KRQfXhs77yTzm7+Cujc+lP3VGjWF7+aS5SmpoJI0 dHm1g5Se39wPG6pUGpApWxUHW+Jl+l5E= X-Received: by 2002:a05:620a:2584:b0:8cf:d65d:ada2 with SMTP id af79cd13be357-8d000f6b26cmr346954985a.32.1774424253255; Wed, 25 Mar 2026 00:37:33 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Wed, 25 Mar 2026 07:37:22 +0000 X-Gmail-Original-Message-ID: X-Gm-Features: AaiRm52jrXYfF0dV2ZV_48ro1O0ZlPKFLJYEjQ_RAMT3f2tKEuYWgym_rk_xK1g Message-ID: Subject: [PHP-DEV] [IDEA for RFC] class_uses and optionally returning traits for parent classes To: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" From: contact@developer-rob.co.uk (Robert Humphries) Good Morning Internals, I am aware that traits in general are a topic where people can have strong opinions, so I wanted to get an idea of initial thoughts on this before deciding if it is worth looking into any further. At the moment, there are three functions in SPL that allow access to what a given class is using in some way: * `class_implements` * `class_parents` * `class_uses` (returns the traits the current class uses) `class_uses` is unique out of the three in that it only returns traits declared on the current class as opposed to the parent class (and higher in inheritance). While this is documented in the manual, looking at the original bug ticket that introduced `class_uses` (https://bugs.php.net/bug.php?id=55266) then it isn't documented why it only returns traits on the current class. As far as I can tell from the bug ticket and the code, `class_implements` was copied for `class_uses` and while `_zend_class_entry->interaces` contains all interfaces (including from the parent classes), `_zend_class_entry->interaces->trait_names` does not. So, in terms of my question; what would be the general thoughts on a new optional argument to `class_uses` that iterates to each parent class, adding the traits from the parent as well? Thanks, Robert