@@ -553,10 +553,10 @@ protected function emitInterface($result, $interface) {
553
553
$ this ->emitMeta ($ result , $ interface ->name , $ interface ->annotations , $ interface ->comment );
554
554
555
555
// Emit default implementations
556
- if (isset ( $ result ->locals [ 3 ]) ) {
556
+ if ($ defaults = $ result ->codegen -> scope [ 0 ]-> defaultImplementations ) {
557
557
$ p = strrpos ($ interface ->name , '\\' );
558
558
$ name = substr ($ interface ->name , 0 , $ p ).'\\__ ' .substr ($ interface ->name , $ p + 1 ).'_Defaults ' ;
559
- $ this ->emitOne ($ result , new TraitDeclaration ([], new IsValue ($ name ), $ result -> locals [ 3 ] ));
559
+ $ this ->emitOne ($ result , new TraitDeclaration ([], new IsValue ($ name ), $ defaults ));
560
560
}
561
561
562
562
$ result ->codegen ->leave ();
@@ -670,10 +670,9 @@ protected function emitMethod($result, $method) {
670
670
671
671
if (null === $ method ->body ) {
672
672
$ result ->out ->write ('; ' );
673
- $ default = null ;
674
673
} else if ('interface ' === $ result ->codegen ->scope [0 ]->type ->kind ) {
675
674
$ result ->out ->write ('; ' );
676
- $ default = $ method ;
675
+ $ result -> codegen -> scope [ 0 ]-> defaultImplementations [] = $ method ;
677
676
} else {
678
677
$ result ->out ->write (' { ' );
679
678
@@ -697,18 +696,13 @@ protected function emitMethod($result, $method) {
697
696
698
697
$ this ->emitAll ($ result , $ method ->body );
699
698
$ result ->out ->write ('} ' );
700
- $ default = null ;
701
699
}
702
700
703
701
foreach ($ promoted as $ param ) {
704
702
$ this ->emitProperty ($ result , new Property (explode (' ' , $ param ->promote ), $ param ->name , $ param ->type ));
705
703
}
706
704
707
705
$ result ->locals = array_pop ($ result ->stack );
708
-
709
- // Copy default implementations to class scope
710
- $ default && $ result ->locals [3 ][]= $ default ;
711
-
712
706
$ result ->codegen ->scope [0 ]->meta [self ::METHOD ][$ method ->name ]= $ meta ;
713
707
}
714
708
0 commit comments