diff --git a/src/Support/MutationGenerator.php b/src/Support/MutationGenerator.php index d712121..7fb47a4 100644 --- a/src/Support/MutationGenerator.php +++ b/src/Support/MutationGenerator.php @@ -154,7 +154,7 @@ private function doesNotContainClassToMutate(string $contents, array $classesToM $namespace = preg_quote(implode('\\', $parts)); $classOrNamespace = preg_quote($classOrNamespace); - if (preg_match("/namespace\\s+$namespace/", $contents) === 1 && preg_match("/(?:class|trait)\\s+$class.*/", $contents) === 1) { + if (preg_match("/namespace\\s+$namespace/", $contents) === 1 && preg_match("/(?:class|trait)\\s+$class\b.*/", $contents) === 1) { return false; } diff --git a/tests/Unit/MutationGeneratorTest.php b/tests/Unit/MutationGeneratorTest.php index 79c67ed..00163f9 100644 --- a/tests/Unit/MutationGeneratorTest.php +++ b/tests/Unit/MutationGeneratorTest.php @@ -96,7 +96,7 @@ classesToMutate: $classes, [['AgeHelper'], 2], [['SizeHelper'], 0], [[AgeHelper::class], 2], - [['Tests\\Fixtures\\Classes\\AgeHelp'], 2], + [['Tests\\Fixtures\\Classes\\AgeHelp'], 0], [['Invalid\\Namespace\\AgeHelper'], 0], [['Invalid\\Namespace\\AgeHelp'], 0], [['Invalid\\Namespace\\AgeHelper', AgeHelper::class], 2], @@ -118,7 +118,7 @@ classesToMutate: $classes, [[SizeHelper::class], 0], [[SizeHelperTrait::class, SizeHelper::class], 1], [['SizeHelperTrait'], 1], - [['Tests\\Fixtures\\Traits\\SizeHelperTrai'], 1], + [['Tests\\Fixtures\\Traits\\SizeHelperTrai'], 0], [['Invalid\\Namespace\\SizeHelperTrait'], 0], ]);