1515
1616class ClassUpdater extends ClassLikeUpdater
1717{
18- public function updateClass (Edits $ edits , ClassPrototype $ classPrototype , ClassDeclaration $ classNode )
18+ public function updateClass (Edits $ edits , ClassPrototype $ classPrototype , ClassDeclaration $ classNode ): void
1919 {
2020 if (false === $ classPrototype ->applyUpdate ()) {
2121 return ;
@@ -29,49 +29,7 @@ public function updateClass(Edits $edits, ClassPrototype $classPrototype, ClassD
2929 $ this ->methodUpdater ->updateMethods ($ edits , $ classPrototype , $ classNode );
3030 }
3131
32- private function updateExtends (Edits $ edits , ClassPrototype $ classPrototype , ClassDeclaration $ classNode )
33- {
34- if (ExtendsClass::none () == $ classPrototype ->extendsClass ()) {
35- return ;
36- }
37-
38- if (null === $ classNode ->classBaseClause ) {
39- $ edits ->after ($ classNode ->name , ' extends ' . (string ) $ classPrototype ->extendsClass ());
40- return ;
41- }
42-
43-
44- $ edits ->replace ($ classNode ->classBaseClause , ' extends ' . (string ) $ classPrototype ->extendsClass ());
45- }
46-
47- private function updateImplements (Edits $ edits , ClassPrototype $ classPrototype , ClassDeclaration $ classNode )
48- {
49- if (ImplementsInterfaces::empty () == $ classPrototype ->implementsInterfaces ()) {
50- return ;
51- }
52-
53- if (null === $ classNode ->classInterfaceClause ) {
54- $ edits ->after ($ classNode ->name , ' implements ' . (string ) $ classPrototype ->implementsInterfaces ()->__toString ());
55- return ;
56- }
57-
58- $ existingNames = [];
59- foreach ($ classNode ->classInterfaceClause ->interfaceNameList ->getElements () as $ name ) {
60- $ existingNames [] = $ name ->getText ();
61- }
62-
63- $ additionalNames = $ classPrototype ->implementsInterfaces ()->notIn ($ existingNames );
64-
65- if (0 === count ($ additionalNames )) {
66- return ;
67- }
68-
69- $ names = join (', ' , [ implode (', ' , $ existingNames ), $ additionalNames ->__toString ()]);
70-
71- $ edits ->replace ($ classNode ->classInterfaceClause , ' implements ' . $ names );
72- }
73-
74- protected function updateConstants (Edits $ edits , ClassPrototype $ classPrototype , Node $ classMembers )
32+ protected function updateConstants (Edits $ edits , ClassPrototype $ classPrototype , Node $ classMembers ): void
7533 {
7634 if (count ($ classPrototype ->constants ()) === 0 ) {
7735 return ;
@@ -123,4 +81,46 @@ protected function memberDeclarations(Node $node): array
12381 {
12482 return $ node ->classMemberDeclarations ;
12583 }
84+
85+ private function updateExtends (Edits $ edits , ClassPrototype $ classPrototype , ClassDeclaration $ classNode ): void
86+ {
87+ if (ExtendsClass::none () == $ classPrototype ->extendsClass ()) {
88+ return ;
89+ }
90+
91+ if (null === $ classNode ->classBaseClause ) {
92+ $ edits ->after ($ classNode ->name , ' extends ' . (string ) $ classPrototype ->extendsClass ());
93+ return ;
94+ }
95+
96+
97+ $ edits ->replace ($ classNode ->classBaseClause , ' extends ' . (string ) $ classPrototype ->extendsClass ());
98+ }
99+
100+ private function updateImplements (Edits $ edits , ClassPrototype $ classPrototype , ClassDeclaration $ classNode ): void
101+ {
102+ if (ImplementsInterfaces::empty () == $ classPrototype ->implementsInterfaces ()) {
103+ return ;
104+ }
105+
106+ if (null === $ classNode ->classInterfaceClause ) {
107+ $ edits ->after ($ classNode ->name , ' implements ' . (string ) $ classPrototype ->implementsInterfaces ()->__toString ());
108+ return ;
109+ }
110+
111+ $ existingNames = [];
112+ foreach ($ classNode ->classInterfaceClause ->interfaceNameList ->getElements () as $ name ) {
113+ $ existingNames [] = $ name ->getText ();
114+ }
115+
116+ $ additionalNames = $ classPrototype ->implementsInterfaces ()->notIn ($ existingNames );
117+
118+ if (0 === count ($ additionalNames )) {
119+ return ;
120+ }
121+
122+ $ names = join (', ' , [ implode (', ' , $ existingNames ), $ additionalNames ->__toString ()]);
123+
124+ $ edits ->replace ($ classNode ->classInterfaceClause , ' implements ' . $ names );
125+ }
126126}
0 commit comments