File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #60145 (Usage of trait's use statement inside interfaces not properly checked.)
3
+ --FILE--
4
+ <?php
5
+
6
+ trait foo {
7
+
8
+ }
9
+
10
+ interface MyInterface {
11
+ use foo;
12
+
13
+ public function b ();
14
+
15
+ }
16
+ --EXPECTF --
17
+ Fatal error: Cannot use traits inside of interfaces. foo is used in MyInterface in %s on line %d
Original file line number Diff line number Diff line change @@ -5023,6 +5023,12 @@ void zend_do_implements_interface(znode *interface_name TSRMLS_DC) /* {{{ */
5023
5023
void zend_do_implements_trait (znode * trait_name TSRMLS_DC ) /* {{{ */
5024
5024
{
5025
5025
zend_op * opline ;
5026
+ if ((CG (active_class_entry )-> ce_flags & ZEND_ACC_INTERFACE )) {
5027
+ zend_error (E_COMPILE_ERROR ,
5028
+ "Cannot use traits inside of interfaces. %s is used in %s" ,
5029
+ Z_STRVAL (trait_name -> u .constant ), CG (active_class_entry )-> name );
5030
+ }
5031
+
5026
5032
5027
5033
switch (zend_get_class_fetch_type (Z_STRVAL (trait_name -> u .constant ), Z_STRLEN (trait_name -> u .constant ))) {
5028
5034
case ZEND_FETCH_CLASS_SELF :
You can’t perform that action at this time.
0 commit comments