Removed parsing support traits to have extends and implements.

This commit is contained in:
Guilherme Blanco 2014-12-05 17:09:49 +00:00 committed by Julien Pauli
parent f48c232740
commit d51fb69c01
4 changed files with 4 additions and 16 deletions

View file

@ -12,4 +12,4 @@ trait Foo extends Base {
echo 'DONE';
?>
--EXPECTF--
Fatal error: A trait (Foo) cannot extend a class. Traits can only be composed from other traits with the 'use' keyword. Error in %s on line %d
Parse error: syntax error, unexpected 'extends' (T_EXTENDS), expecting '{' in %s on line %d

View file

@ -16,4 +16,4 @@ trait THello implements MyInterface {
?>
--EXPECTF--
Fatal error: Cannot use 'MyInterface' as interface on 'THello' since it is a Trait in %s on line %d
Parse error: syntax error, unexpected 'implements' (T_IMPLEMENTS), expecting '{' in %s on line %d

View file

@ -4457,12 +4457,6 @@ void zend_compile_implements(znode *class_node, zend_ast *ast) /* {{{ */
zend_op *opline;
/* Traits can not implement interfaces */
if (ZEND_CE_IS_TRAIT(CG(active_class_entry))) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use '%s' as interface on '%s' "
"since it is a Trait", name->val, CG(active_class_entry)->name->val);
}
if (!zend_is_const_default_class_ref(class_ast)) {
zend_error_noreturn(E_COMPILE_ERROR,
"Cannot use '%s' as interface name as it is reserved", name->val);
@ -4536,12 +4530,6 @@ void zend_compile_class_decl(zend_ast *ast) /* {{{ */
}
if (extends_ast) {
if (ZEND_CE_IS_TRAIT(ce)) {
zend_error_noreturn(E_COMPILE_ERROR, "A trait (%s) cannot extend a class. "
"Traits can only be composed from other traits with the 'use' keyword. Error",
name->val);
}
if (!zend_is_const_default_class_ref(extends_ast)) {
zend_string *extends_name = zend_ast_get_str(extends_ast);
zend_error_noreturn(E_COMPILE_ERROR,

View file

@ -445,8 +445,8 @@ class_modifier:
trait_declaration_statement:
T_TRAIT { $<num>$ = CG(zend_lineno); }
T_STRING extends_from implements_list backup_doc_comment '{' class_statement_list '}'
{ $$ = zend_ast_create_decl(ZEND_AST_CLASS, ZEND_ACC_TRAIT, $<num>2, $6, zend_ast_get_str($3), $4, $5, $8); }
T_STRING backup_doc_comment '{' class_statement_list '}'
{ $$ = zend_ast_create_decl(ZEND_AST_CLASS, ZEND_ACC_TRAIT, $<num>2, $4, zend_ast_get_str($3), NULL, NULL, $6); }
;
interface_declaration_statement: