Skip to content

Commit b6d392d

Browse files
committed
Renamed const to IS_INSTANCE to be consistent with getMethods() filter.
1 parent 551c7d5 commit b6d392d

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Zend/tests/attributes/filter.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,27 @@ class A2 implements Base { }
2626
class A3 extends A2 { }
2727

2828
$ref = new \ReflectionFunction(<<A1>> <<A2>> <<A5>> function () { });
29-
$attr = $ref->getAttributes(\stdClass::class, \ReflectionAttribute::FILTER_INSTANCEOF);
29+
$attr = $ref->getAttributes(\stdClass::class, \ReflectionAttribute::IS_INSTANCEOF);
3030
var_dump(count($attr));
3131
print_r(array_map(fn ($a) => $a->getName(), $attr));
3232

3333
$ref = new \ReflectionFunction(<<A1>> <<A2>> function () { });
34-
$attr = $ref->getAttributes(A1::class, \ReflectionAttribute::FILTER_INSTANCEOF);
34+
$attr = $ref->getAttributes(A1::class, \ReflectionAttribute::IS_INSTANCEOF);
3535
var_dump(count($attr));
3636
print_r(array_map(fn ($a) => $a->getName(), $attr));
3737

3838
$ref = new \ReflectionFunction(<<A1>> <<A2>> function () { });
39-
$attr = $ref->getAttributes(Base::class, \ReflectionAttribute::FILTER_INSTANCEOF);
39+
$attr = $ref->getAttributes(Base::class, \ReflectionAttribute::IS_INSTANCEOF);
4040
var_dump(count($attr));
4141
print_r(array_map(fn ($a) => $a->getName(), $attr));
4242

4343
$ref = new \ReflectionFunction(<<A1>> <<A2>> <<A3>> function () { });
44-
$attr = $ref->getAttributes(A2::class, \ReflectionAttribute::FILTER_INSTANCEOF);
44+
$attr = $ref->getAttributes(A2::class, \ReflectionAttribute::IS_INSTANCEOF);
4545
var_dump(count($attr));
4646
print_r(array_map(fn ($a) => $a->getName(), $attr));
4747

4848
$ref = new \ReflectionFunction(<<A1>> <<A2>> <<A3>> function () { });
49-
$attr = $ref->getAttributes(Base::class, \ReflectionAttribute::FILTER_INSTANCEOF);
49+
$attr = $ref->getAttributes(Base::class, \ReflectionAttribute::IS_INSTANCEOF);
5050
var_dump(count($attr));
5151
print_r(array_map(fn ($a) => $a->getName(), $attr));
5252

@@ -63,7 +63,7 @@ try {
6363
$ref = new \ReflectionFunction(function () { });
6464

6565
try {
66-
$ref->getAttributes(SomeMissingClass::class, \ReflectionAttribute::FILTER_INSTANCEOF);
66+
$ref->getAttributes(SomeMissingClass::class, \ReflectionAttribute::IS_INSTANCEOF);
6767
} catch (\Error $e) {
6868
var_dump('ERROR 2', $e->getMessage());
6969
}

ext/reflection/php_reflection.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ PHPAPI zend_class_entry *reflection_attribute_ptr;
111111
#define REGISTER_REFLECTION_CLASS_CONST_LONG(class_name, const_name, value) \
112112
zend_declare_class_constant_long(reflection_ ## class_name ## _ptr, const_name, sizeof(const_name)-1, (zend_long)value);
113113

114-
#define REFLECTION_ATTRIBUTE_FILTER_INSTANCEOF (1 << 1)
114+
#define REFLECTION_ATTRIBUTE_IS_INSTANCEOF (1 << 1)
115115

116116
/* {{{ Object structure */
117117

@@ -1224,12 +1224,12 @@ static void reflect_attributes(INTERNAL_FUNCTION_PARAMETERS, HashTable *attribut
12241224
RETURN_THROWS();
12251225
}
12261226

1227-
if (flags & ~REFLECTION_ATTRIBUTE_FILTER_INSTANCEOF) {
1227+
if (flags & ~REFLECTION_ATTRIBUTE_IS_INSTANCEOF) {
12281228
zend_throw_error(NULL, "Invalid attribute filter flag specified");
12291229
RETURN_THROWS();
12301230
}
12311231

1232-
if (name && (flags & REFLECTION_ATTRIBUTE_FILTER_INSTANCEOF)) {
1232+
if (name && (flags & REFLECTION_ATTRIBUTE_IS_INSTANCEOF)) {
12331233
if (NULL == (base = zend_lookup_class(name))) {
12341234
if (!EG(exception)) {
12351235
zend_throw_error(NULL, "Class '%s' not found", ZSTR_VAL(name));
@@ -7145,7 +7145,7 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */
71457145
_reflection_entry.ce_flags |= ZEND_ACC_FINAL;
71467146
reflection_attribute_ptr = zend_register_internal_class(&_reflection_entry);
71477147

7148-
REGISTER_REFLECTION_CLASS_CONST_LONG(attribute, "FILTER_INSTANCEOF", REFLECTION_ATTRIBUTE_FILTER_INSTANCEOF);
7148+
REGISTER_REFLECTION_CLASS_CONST_LONG(attribute, "IS_INSTANCEOF", REFLECTION_ATTRIBUTE_IS_INSTANCEOF);
71497149

71507150
REFLECTION_G(key_initialized) = 0;
71517151

0 commit comments

Comments
 (0)