Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117252 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 16722 invoked from network); 3 Mar 2022 17:20:32 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Mar 2022 17:20:32 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B6ED9180382 for ; Thu, 3 Mar 2022 10:42:19 -0800 (PST) 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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 ; Thu, 3 Mar 2022 10:42:19 -0800 (PST) Received: by mail-lf1-f41.google.com with SMTP id 5so8110911lfz.9 for ; Thu, 03 Mar 2022 10:42:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8pQemEKFprhqmWIuvQz5+aK8Q+KT8Ryxs4K2LGSYd5U=; b=EHsDXrCHhAeANd43hsDYo5RYBkeK3CeuPGrVTZpDV4tDUM2m7bnscVvxQ2FIzMPZM+ k7jWzv0Md0fjO9j5gUYtXkcFXIrgMF4KqirVDFy4TkmYOM0BN8CkLZCdUqskZQ9mNTQe Iqv7Zrn5Sga0m8IlG+AgRMZjrl0tvZW2q1+e7Xaq3uBL8yU/noJm0gWq09kflHhBBT5y 3sGF3fcmxzmexynzY4ZBIbEdM0gqGDv5/Mn2+3anIOSQ/naCUcUf/9d3saYHzf/TCl3k VQSRXxR6ubXoxWmozgp8wJLHCcbn6fkM4DgMsdHY3dgqPj7QrnO5a3AMbSqPb9iMoTgr MLvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=8pQemEKFprhqmWIuvQz5+aK8Q+KT8Ryxs4K2LGSYd5U=; b=7HzCgS619Nqvp2IAKKgpe2/u/O8zhLcCRP/40SgVxLWr4JzoiOfElotosb1lt7F4Ao WzIpBCx2WLfKdac9w4b6EDF+LiraVfD4Crup7uGPg2rkfcCQgtqA3nVX+En6iqrbko3N u65vuENYzUKFag3pjvrYUxcGhtLMtIU+Bz6dSqSrIZXHzPbJWYDOUbCqpRoxase1T0r4 bs5m1ar39UpaYXRdtsMO+j4GVWzaNIuJLf9lgcGauE+XLdcemGX0UyJtUYs179lxeqmG wz1JaALMD+wNR1kfzBdaMPMhEv08DdOr9fYvh3C33jLC7umh5qzZv+qXHj+r+m1ohJ7/ 4nRA== X-Gm-Message-State: AOAM5324Xs3NPCjWWcXIx9XV5xzf1NzOZG9aHF6TNjgy5+RrZtwbVAHD HZKjYWY3I94l2xF0JdRZME816dj5x5/D5lJgW3+MJxEVcjw= X-Google-Smtp-Source: ABdhPJzrvEPFdmifa2ueIO9vSVTrAgZ7ceKMetxYwSmkww4iPP3gOhV0w/VfZV8js00XWie8UBcLUMy5sQNF1+/QmHo= X-Received: by 2002:ac2:4202:0:b0:444:14bf:86dc with SMTP id y2-20020ac24202000000b0044414bf86dcmr22206316lfh.126.1646332937590; Thu, 03 Mar 2022 10:42:17 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 3 Mar 2022 19:42:06 +0100 Message-ID: To: DANIEL VARGAS MUCCILLO Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Interface for reflection entities who implements getAttributes method From: andreas@dqxtech.net (Andreas Hennings) Hello list. Another potential benefit of such interfaces can be polyfills. PHP 8.x: class ReflectionClass implements Reflector, AttributesHaving {..} PHP 7.x. class UserlandReflectionClass extends ReflectionClass implements AttributesHaving {..} function f(AttributesHaving $reflector) { $attributes = $reflector->getAttributes(); ... } I wonder if it should be called "AttributeReflector" or "AttributesHaving" or "AbleToHaveAttributesBeing" :) On Fri, 25 Feb 2022 at 23:58, DANIEL VARGAS MUCCILLO wrote: > > Hi Internals, hope you are all well. > > I've been playing around with Attributes and found that the only > way for safely type hint for reflection entities who implement the > getAttributes method is the following union: > > ReflectionClass|ReflectionClassConstant|ReflectionFunctionAbstract|ReflectionParameter|ReflectionProperty > > $reflectionEntity > > > For a single use case this was ok, but i would like to survey if > people here would be interested in the introduction of a interface > against which we could correctly ensure, with less effort, that > getAttribute is available. > > I believe that it would be something along the lines of: > > > interface AttributeReflector { > > public function getAttributes(?string $name = null, int $flags = 0): > > array; > > } > > > I have no experience with the PHP's source code, but if you think > that it's a good idea I would like to propose an RFC along with a PoC > patch to make this adition. > > Thanks for your time until now and all the good work I've seen here. > > -- > Daniel Vargas Muccillo