Skip to content

Commit

Permalink
fix: match result cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
marcocesarato committed Jan 6, 2021
1 parent f7a57ff commit 6f3d115
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Match.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,14 @@ public static function getLineNumber($lastMatch, $contentRaw)
public static function getText($type, $name, $description, $match, $line = null)
{
$maxLengthMatch = 500;
$prefix = ucfirst($type) . ' `' . $name . '`';
$prefix = ucfirst($type) . ' (' . $name . ')';
if (!empty($line)) {
$prefix .= ' [line ' . $line . ']';
}
$shortMatch = trim($match);
$shortMatch = str_replace(PHP_EOL, ' ', $shortMatch);
$shortMatch = strlen($shortMatch) > $maxLengthMatch ? substr($shortMatch, 0, $maxLengthMatch) . '...' : $match;
$shortMatch = preg_replace('/[\s]+/', ' ', $shortMatch);

return $matchDescription = '[!] ' . trim($prefix) . "\n - " . $description . "\n => " . $shortMatch;
}
Expand All @@ -98,6 +99,6 @@ public static function patternFunction($func)
*/
public static function cleanFunctionResult($match)
{
return preg_replace("/(?:.*?)(\S+[\s\r\n]*\((?<=\().*?(?=\))\))(?:.*)/si", '$1', $match);
return preg_replace("/(?:.*?)([a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*[\s\r\n]*\((?<=\().*?(?=\))\))(?:.*)/si", '$1', $match);
}
}

0 comments on commit 6f3d115

Please sign in to comment.