Skip to content
This repository was archived by the owner on Jul 12, 2020. It is now read-only.

Commit 746cfec

Browse files
committed
[GH-28][GH-29] Fix another bug in false/positive change detection by using Name Type filtering.
1 parent 18ffa52 commit 746cfec

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/main/QafooLabs/Refactoring/Adapters/PHPParser/ParserPhpNameScanner.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@ public function findNames(File $file)
3333
return array_map(function ($use) use ($file) {
3434
$type = constant('QafooLabs\Refactoring\Domain\Model\PhpName::TYPE_' . strtoupper($use['type']));
3535
return new PhpNameOccurance(
36-
new PhpName($use['fqcn'], $use['alias'], $type),
37-
$file, $use['line']
36+
new PhpName(
37+
$use['fqcn'],
38+
$use['alias'],
39+
$type
40+
),
41+
$file,
42+
$use['line']
3843
);
3944
}, $collector->collectedNameDeclarations());
4045
}

src/main/QafooLabs/Refactoring/Application/FixClassNames.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,19 @@ public function refactor(Directory $directory)
5959

6060
if (!$expectedClassName->namespaceName()->equals($currentClassName->namespaceName())) {
6161
$renames->add(new PhpNameChange($currentClassName->fullyQualified(), $expectedClassName->fullyQualified()));
62+
63+
$buffer->replaceString(
64+
$class->namespaceDeclarationLine(),
65+
$currentClassName->namespaceName()->fullyQualifiedName(),
66+
$expectedClassName->namespaceName()->fullyQualifiedName()
67+
);
6268
}
6369
}
6470

71+
$occurances = array_filter($occurances, function ($occurance) {
72+
return $occurance->name()->type() !== PhpName::TYPE_NAMESPACE;
73+
});
74+
6575
foreach ($occurances as $occurance) {
6676
$name = $occurance->name();
6777

0 commit comments

Comments
 (0)