php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80097 ReflectionAttribute is not a Reflector
Submitted: 2020-09-12 15:06 UTC Modified: 2020-09-12 15:24 UTC
From: me at derrabus dot de Assigned: beberlei (profile)
Status: Closed Package: Reflection related
PHP Version: 8.0.0beta3 OS: any
Private report: No CVE-ID: None
 [2020-09-12 15:06 UTC] me at derrabus dot de
Description:
------------
The new ReflectionAttribute class does not implement the Reflector interface. This is not really a big problem, but feels inconsistent and somewhat unintended.

Test script:
---------------
<?php

$classes = [
    'ReflectionClass',
    'ReflectionClassConstant',
    'ReflectionZendExtension',
    'ReflectionExtension',
    'ReflectionFunction',
    'ReflectionFunctionAbstract',
    'ReflectionMethod',
    'ReflectionNamedType',
    'ReflectionObject',
    'ReflectionParameter',
    'ReflectionProperty',
    'ReflectionType',
    'ReflectionAttribute',
];

foreach ($classes as $class) {
    $isReflector = class_implements($class, 'Reflector') ? 'yes' : 'no';
    $class = str_pad($class, 30);
    echo "$class$isReflector\n";
}

Expected result:
----------------
ReflectionClass               yes
ReflectionClassConstant       yes
ReflectionZendExtension       yes
ReflectionExtension           yes
ReflectionFunction            yes
ReflectionFunctionAbstract    yes
ReflectionMethod              yes
ReflectionNamedType           yes
ReflectionObject              yes
ReflectionParameter           yes
ReflectionProperty            yes
ReflectionType                yes
ReflectionAttribute           yes

Actual result:
--------------
ReflectionClass               yes
ReflectionClassConstant       yes
ReflectionZendExtension       yes
ReflectionExtension           yes
ReflectionFunction            yes
ReflectionFunctionAbstract    yes
ReflectionMethod              yes
ReflectionNamedType           yes
ReflectionObject              yes
ReflectionParameter           yes
ReflectionProperty            yes
ReflectionType                yes
ReflectionAttribute           no

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-12 15:24 UTC] beberlei@php.net
-Assigned To: +Assigned To: beberlei
 [2020-11-14 21:17 UTC] carusogabriel@php.net
The following pull request has been associated:

Patch Name: Bugfix 80097: Have ReflectionAttribute implement Reflector, __toString
On GitHub:  https://github.com/php/php-src/pull/6117
Patch:      https://github.com/php/php-src/pull/6117.patch
 [2021-07-07 10:42 UTC] git@php.net
Automatic comment on behalf of beberlei (author) and nikic (committer)
Revision: https://github.com/php/php-src/commit/bc39abe8c3c492e29bc5d60ca58442040bbf063b
Log: Fix #80097: Have ReflectionAttribute implement Reflector and __toString
 [2021-07-07 10:42 UTC] git@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Nov 23 07:01:29 2024 UTC