Changeset View
Changeset View
Standalone View
Standalone View
src/parser/PhutilDocblockParser.php
Context not available. | |||||
// Build a map of character offset -> line number. | // Build a map of character offset -> line number. | ||||
$map = array(); | $map = array(); | ||||
$lines = explode("\n", $text); | $lines = @explode("\n", $text); | ||||
$num = 1; | $num = 1; | ||||
foreach ($lines as $line) { | foreach ($lines as $line) { | ||||
$len = strlen($line) + 1; | $len = @strlen($line) + 1; | ||||
for ($jj = 0; $jj < $len; $jj++) { | for ($jj = 0; $jj < $len; $jj++) { | ||||
$map[] = $num; | $map[] = $num; | ||||
} | } | ||||
Context not available. | |||||
$docblock = preg_replace('@^\s*\*@m', '', $docblock); | $docblock = preg_replace('@^\s*\*@m', '', $docblock); | ||||
// Normalize multi-line @specials. | // Normalize multi-line @specials. | ||||
$lines = explode("\n", $docblock); | $lines = @explode("\n", $docblock); | ||||
$last = false; | $last = false; | ||||
foreach ($lines as $k => $line) { | foreach ($lines as $k => $line) { | ||||
Context not available. | |||||
// we allow that and one additional space before assuming something is | // we allow that and one additional space before assuming something is | ||||
// a code block. | // a code block. | ||||
if (preg_match('/^\s{0,2}@\w/i', $line)) { | if (@preg_match('/^\s{0,2}@\w/i', $line)) { | ||||
$last = $k; | $last = $k; | ||||
$lines[$last] = trim($line); | $lines[$last] = trim($line); | ||||
} else if (preg_match('/^\s*$/', $line)) { | } else if (@preg_match('/^\s*$/', $line)) { | ||||
$last = false; | $last = false; | ||||
} else if ($last !== false) { | } else if ($last !== false) { | ||||
$lines[$last] = $lines[$last].' '.trim($line); | $lines[$last] = $lines[$last].' '.trim($line); | ||||
Context not available. | |||||
// For flags like "@stable" which don't have any string data, set the | // For flags like "@stable" which don't have any string data, set the | ||||
// value to true. | // value to true. | ||||
if (!strlen($data)) { | if (!@strlen($data)) { | ||||
$data = true; | $data = true; | ||||
} | } | ||||
Context not available. | |||||
// Smush the whole docblock to the left edge. | // Smush the whole docblock to the left edge. | ||||
$min_indent = 80; | $min_indent = 80; | ||||
$indent = 0; | $indent = 0; | ||||
foreach (array_filter(explode("\n", $docblock)) as $line) { | foreach (array_filter(@explode("\n", $docblock)) as $line) { | ||||
for ($ii = 0; $ii < strlen($line); $ii++) { | for ($ii = 0; $ii < @strlen($line); $ii++) { | ||||
if ($line[$ii] != ' ') { | if ($line[$ii] != ' ') { | ||||
break; | break; | ||||
} | } | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0