This repository was archived by the owner on Jul 12, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +74
-1
lines changed
src/main/QafooLabs/Refactoring/Adapters/PHPParser/Visitor Expand file tree Collapse file tree 2 files changed +74
-1
lines changed Original file line number Diff line number Diff line change @@ -124,3 +124,76 @@ Feature: Fix Class Names
124
124
-use Bar\Bar;
125
125
+use Foo\Bar;
126
126
"""
127
+
128
+ Scenario : "Rename class changes static occurances"
129
+ Given a PHP File named "src/Foo/Bar.php" with:
130
+ """
131
+ <?php
132
+ namespace Foo;
133
+
134
+ class Foo
135
+ {
136
+ }
137
+ """
138
+ Given a PHP File named "src/Foo.php" with:
139
+ """
140
+ <?php
141
+ Foo\Foo::bar();
142
+ """
143
+ When I use refactoring "fix-class-names" with:
144
+ | arg | value |
145
+ | dir | src / |
146
+ Then the PHP File "src/Foo.php" should be refactored:
147
+ """
148
+ --- a/src/Foo/Bar.php
149
+ +++ b/src/Foo/Bar.php
150
+ @@ -2,5 +2,5 @@
151
+ namespace Foo;
152
+
153
+ -class Foo
154
+ +class Bar
155
+ {
156
+ }
157
+ --- a/Foo.php
158
+ +++ b/Foo.php
159
+ @@ -1,2 +1,2 @@
160
+ <?php
161
+ -Foo\Foo::bar();
162
+ +Foo\Bar::bar();
163
+ """
164
+ Scenario : "Rename class changes new instantiations"
165
+ Given a PHP File named "src/Foo/Bar.php" with:
166
+ """
167
+ <?php
168
+ namespace Foo;
169
+
170
+ class Foo
171
+ {
172
+ }
173
+ """
174
+ Given a PHP File named "src/Foo.php" with:
175
+ """
176
+ <?php
177
+ new Foo\Foo();
178
+ """
179
+ When I use refactoring "fix-class-names" with:
180
+ | arg | value |
181
+ | dir | src / |
182
+ Then the PHP File "src/Foo.php" should be refactored:
183
+ """
184
+ --- a/src/Foo/Bar.php
185
+ +++ b/src/Foo/Bar.php
186
+ @@ -2,5 +2,5 @@
187
+ namespace Foo;
188
+
189
+ -class Foo
190
+ +class Bar
191
+ {
192
+ }
193
+ --- a/Foo.php
194
+ +++ b/Foo.php
195
+ @@ -1,2 +1,2 @@
196
+ <?php
197
+ -new Foo\Foo();
198
+ +new Foo\Bar();
199
+ """
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ private function fullyQualifiedNameFor($alias)
78
78
} else if (isset ($ this ->useStatements [$ alias ])) {
79
79
$ class = $ this ->useStatements [$ alias ];
80
80
} else {
81
- $ class = $ this ->currentNamespace . '\\' . $ alias ;
81
+ $ class = ltrim ( $ this ->currentNamespace . '\\' . $ alias, '\\' ) ;
82
82
}
83
83
84
84
return $ class ;
You can’t perform that action at this time.
0 commit comments