File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,19 @@ class NamespaceReplacer extends BaseReplacer
99
1010 public function replace ($ contents )
1111 {
12- $ searchNamespace = addslashes ($ this ->autoloader ->getSearchNamespace ());
13- $ dependencyNamespace = addslashes ($ this ->dep_namespace );
12+ $ searchNamespace = preg_quote ($ this ->autoloader ->getSearchNamespace (), ' / ' );
13+ $ dependencyNamespace = preg_quote ($ this ->dep_namespace , ' / ' );
1414
15- return preg_replace_callback (
16- '/([^a-zA-Z0-9_\x7f-\xff])((?<! ' . $ dependencyNamespace . ') ' . $ searchNamespace . '[ \\\|;])/U ' ,
15+ return preg_replace_callback ("
16+ / # Start the pattern
17+ ([^a-zA-Z0-9_ \x7f- \xff]) # Match the non-class character before the namespace
18+ ( # Start the namespace matcher
19+ (?<! $ dependencyNamespace) # Does NOT start with the prefix
20+ (?<![a-zA-Z0-9_] \\\\) # Not a class-allowed character followed by a slash
21+ $ searchNamespace # The namespace we're looking for
22+ [ \\\|;] # Backslash, semicolon, or pipe
23+ ) # End the namespace matcher
24+ /Ux " ,
1725 function ($ matches ) {
1826 return $ matches [1 ] . $ this ->dep_namespace . $ matches [2 ];
1927 },
You can’t perform that action at this time.
0 commit comments