Skip to content

Commit

Permalink
Match namespace|use only on begining of line (#477)
Browse files Browse the repository at this point in the history
Ensure use matches are only on begining of lines to prevent conflicts
with use keyword for traits.
  • Loading branch information
gjm authored Aug 9, 2024
1 parent e116aeb commit 5597adb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Infer/Reflector/ClassReflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getNameContext(): NameContext
// Removes all comments.
$code = preg_replace('/\/\*(?:[^*]|\*+[^*\/])*\*+\/|(?<![:\'"])\/\/.*|(?<![:\'"])#.*/', '', $code);

$re = '/(namespace|use) ([.\s\S]*?);/m';
$re = '/^(namespace|use) ([.\s\S]*?);/m';
preg_match_all($re, $code, $matches);

$code = "<?php\n".implode("\n", $matches[0]);
Expand Down

0 comments on commit 5597adb

Please sign in to comment.