|
23 | 23 | #include "ext/standard/info.h"
|
24 | 24 | #include "php_test.h"
|
25 | 25 | #include "test_arginfo.h"
|
| 26 | +#include "zend_attributes.h" |
26 | 27 |
|
27 | 28 | static zend_class_entry *zend_test_interface;
|
28 | 29 | static zend_class_entry *zend_test_class;
|
29 | 30 | static zend_class_entry *zend_test_child_class;
|
30 | 31 | static zend_class_entry *zend_test_trait;
|
| 32 | +static zend_class_entry *zend_test_attribute; |
31 | 33 | static zend_object_handlers zend_test_class_handlers;
|
32 | 34 |
|
33 | 35 | ZEND_FUNCTION(zend_test_func)
|
@@ -181,6 +183,13 @@ static zend_function *zend_test_class_static_method_get(zend_class_entry *ce, ze
|
181 | 183 | }
|
182 | 184 | /* }}} */
|
183 | 185 |
|
| 186 | +void zend_attribute_validate_zendtestattribute(zend_attribute *attr, int target) |
| 187 | +{ |
| 188 | + if (target != ZEND_ATTRIBUTE_TARGET_CLASS) { |
| 189 | + zend_error(E_COMPILE_ERROR, "Only classes can be marked with <<ZendTestAttribute>>"); |
| 190 | + } |
| 191 | +} |
| 192 | + |
184 | 193 | ZEND_METHOD(_ZendTestClass, __toString) /* {{{ */ {
|
185 | 194 | RETURN_EMPTY_STRING();
|
186 | 195 | }
|
@@ -272,6 +281,12 @@ PHP_MINIT_FUNCTION(zend_test)
|
272 | 281 | zend_register_class_alias("_ZendTestClassAlias", zend_test_class);
|
273 | 282 |
|
274 | 283 | REGISTER_LONG_CONSTANT("ZEND_TEST_DEPRECATED", 42, CONST_PERSISTENT | CONST_DEPRECATED);
|
| 284 | + |
| 285 | + INIT_CLASS_ENTRY(class_entry, "ZendTestAttribute", NULL); |
| 286 | + zend_test_attribute = zend_register_internal_class(&class_entry); |
| 287 | + zend_test_attribute->ce_flags |= ZEND_ACC_FINAL; |
| 288 | + |
| 289 | + zend_compiler_attribute_register(zend_test_attribute, zend_attribute_validate_zendtestattribute); |
275 | 290 | return SUCCESS;
|
276 | 291 | }
|
277 | 292 |
|
|
0 commit comments