This repository was archived by the owner on Jul 12, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +20
-9
lines changed
src/main/QafooLabs/Refactoring Expand file tree Collapse file tree 3 files changed +20
-9
lines changed Original file line number Diff line number Diff line change 13
13
14
14
namespace QafooLabs \Refactoring \Application ;
15
15
16
+ use QafooLabs \Collections \Set ;
16
17
use QafooLabs \Refactoring \Domain \Model \Directory ;
17
18
use QafooLabs \Refactoring \Domain \Model \File ;
18
19
use QafooLabs \Refactoring \Domain \Model \PhpName ;
@@ -35,7 +36,7 @@ public function refactor(Directory $directory)
35
36
{
36
37
$ phpFiles = $ directory ->findAllPhpFilesRecursivly ();
37
38
38
- $ renames = array ();
39
+ $ renames = new Set ();
39
40
$ occurances = array ();
40
41
41
42
foreach ($ phpFiles as $ phpFile ) {
@@ -59,19 +60,15 @@ public function refactor(Directory $directory)
59
60
60
61
$ buffer ->replaceString ($ line , $ currentClassName ->shortName (), $ expectedClassName ->shortName ());
61
62
62
- $ rename = true ;
63
+ $ renames -> add ( new PhpNameChange ( $ currentClassName , $ expectedClassName )) ;
63
64
}
64
65
65
66
if ($ expectedClassName ->namespaceName () !== $ currentClassName ->namespaceName ()) {
66
67
$ namespaceLine = $ class ->namespaceDeclarationLine ();
67
68
68
69
$ buffer ->replaceString ($ namespaceLine , $ currentClassName ->namespaceName (), $ expectedClassName ->namespaceName ());
69
70
70
- $ rename = true ;
71
- }
72
-
73
- if ($ rename ) {
74
- $ renames [] = new PhpNameChange ($ currentClassName , $ expectedClassName );
71
+ $ renames ->add (new PhpNameChange ($ currentClassName , $ expectedClassName ));
75
72
}
76
73
}
77
74
Original file line number Diff line number Diff line change 13
13
14
14
namespace QafooLabs \Refactoring \Domain \Model ;
15
15
16
+ use QafooLabs \Collections \Hashable ;
17
+
16
18
/**
17
19
* Representation of a Name in PHP
18
20
*/
19
- class PhpName
21
+ class PhpName implements Hashable
20
22
{
21
23
private $ fullyQualifiedName ;
22
24
private $ relativeName ;
@@ -129,4 +131,9 @@ public function __toString()
129
131
{
130
132
return sprintf ('%s[%s] ' , $ this ->fullyQualifiedName , $ this ->relativeName );
131
133
}
134
+
135
+ public function hashCode ()
136
+ {
137
+ return "1373136332 " . $ this ->fullyQualifiedName . $ this ->relativeName ;
138
+ }
132
139
}
Original file line number Diff line number Diff line change 13
13
14
14
namespace QafooLabs \Refactoring \Domain \Model ;
15
15
16
- class PhpNameChange
16
+ use QafooLabs \Collections \Hashable ;
17
+
18
+ class PhpNameChange implements Hashable
17
19
{
18
20
private $ fromName ;
19
21
private $ toName ;
@@ -33,4 +35,9 @@ public function change(PhpName $name)
33
35
{
34
36
return $ name ->change ($ this ->fromName , $ this ->toName );
35
37
}
38
+
39
+ public function hashCode ()
40
+ {
41
+ return "1373136290 " . $ this ->fromName ->hashCode () . $ this ->toName ->hashCode ();
42
+ }
36
43
}
You can’t perform that action at this time.
0 commit comments