Skip to content

Commit 2d8bea4

Browse files
committed
Remove PhpCompilerAttribute and introduce failing test for attributes of PhpAttribute
1 parent 325b636 commit 2d8bea4

File tree

5 files changed

+19
-28
lines changed

5 files changed

+19
-28
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Attributes: attributes on PhpAttribute return itself
3+
--FILE--
4+
<?php
5+
6+
$reflection = new \ReflectionClass(PhpAttribute::class);
7+
$attributes = $reflection->getAttributes();
8+
9+
foreach ($attributes as $attribute) {
10+
var_dump($attribute->getName());
11+
var_dump($attribute->getArguments());
12+
var_dump($attribute->newInstance());
13+
}
14+
--EXPECTF--
15+
string(12) "PhpAttribute"
16+
array(0) {
17+
}
18+
object(PhpAttribute)#3 (0) {
19+
}

Zend/tests/attributes/007_wrong_compiler_attributes.phpt

Lines changed: 0 additions & 14 deletions
This file was deleted.

Zend/zend_attributes.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "zend_attributes.h"
44

55
ZEND_API zend_class_entry *zend_ce_php_attribute;
6-
ZEND_API zend_class_entry *zend_ce_php_compiler_attribute;
76

87
static HashTable internal_validators;
98

@@ -14,11 +13,6 @@ void zend_attribute_validate_phpattribute(zend_attribute *attr, int target)
1413
}
1514
}
1615

17-
void zend_attribute_validate_phpcompilerattribute(zend_attribute *attr, int target)
18-
{
19-
zend_error(E_COMPILE_ERROR, "The PhpCompilerAttribute can only be used by internal classes, use PhpAttribute instead");
20-
}
21-
2216
ZEND_API zend_attributes_internal_validator zend_attribute_get_validator(zend_string *lcname)
2317
{
2418
return zend_hash_find_ptr(&internal_validators, lcname);
@@ -109,10 +103,4 @@ void zend_register_attribute_ce(void)
109103
zend_ce_php_attribute->ce_flags |= ZEND_ACC_FINAL;
110104

111105
zend_compiler_attribute_register(zend_ce_php_attribute, zend_attribute_validate_phpattribute);
112-
113-
INIT_CLASS_ENTRY(ce, "PhpCompilerAttribute", NULL);
114-
zend_ce_php_compiler_attribute = zend_register_internal_class(&ce);
115-
zend_ce_php_compiler_attribute->ce_flags |= ZEND_ACC_FINAL;
116-
117-
zend_compiler_attribute_register(zend_ce_php_compiler_attribute, zend_attribute_validate_phpcompilerattribute);
118106
}

Zend/zend_attributes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
BEGIN_EXTERN_C()
1515

1616
extern ZEND_API zend_class_entry *zend_ce_php_attribute;
17-
extern ZEND_API zend_class_entry *zend_ce_php_compiler_attribute;
1817

1918
typedef struct _zend_attribute {
2019
zend_string *name;

ext/reflection/php_reflection.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6623,7 +6623,6 @@ ZEND_METHOD(ReflectionAttribute, newInstance)
66236623
RETURN_ZVAL(&obj, 1, 1);
66246624
}
66256625
/* }}} */
6626-
66276626
static const zend_function_entry reflection_ext_functions[] = { /* {{{ */
66286627
PHP_FE_END
66296628
}; /* }}} */

0 commit comments

Comments
 (0)