Skip to content

Commit

Permalink
Use preg_replace rather than str_replace
Browse files Browse the repository at this point in the history
This ensures we only make 1 replacement, rather than potentially matching sub-strings in other FQCNs.
  • Loading branch information
finiteinfinity committed May 10, 2024
1 parent 4438db1 commit 8f2313c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Coders/Model/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ private function shortenAndExtractImportableDependencies(&$placeholder, $model)
}

$importableDependencies[trim($usedClass, '\\')] = true;
$placeholder = str_replace($usedClass, $className, $placeholder);
$placeholder = preg_replace('!'.addslashes($usedClass).'\b!', addslashes($className), $placeholder, 1);
}
}

Expand Down

0 comments on commit 8f2313c

Please sign in to comment.