$len = strlen($text);
- $return = array();
+ $return = [];
$lastSpace = null;
$inTag = false;
$i = $tagWidth = 0;
function extract_paragraphs($element)
{
- $paragraphs = array();
+ $paragraphs = [];
foreach ($element->getElementsByTagName('para') as $p) {
$text = '';
foreach ($p->childNodes as $child) {
function format_doc($doc)
{
- $chunks = array();
+ $chunks = [];
if (!empty($doc['description'])) {
$chunks[] = '<comment>Description:</comment>';
function thunk_tags($text)
{
- $tagMap = array(
+ $tagMap = [
'parameter>' => 'strong>',
'function>' => 'strong>',
'literal>' => 'return>',
'type>' => 'info>',
'constant>' => 'info>',
- );
+ ];
- $andBack = array(
+ $andBack = [
'&' => '&',
'&true;' => '<return>true</return>',
'&false;' => '<return>false</return>',
'&null;' => '<return>null</return>',
- );
+ ];
return strtr(strip_tags(strtr($text, $tagMap), '<strong><return><info>'), $andBack);
}
function format_function_doc($xml)
{
- $doc = array();
+ $doc = [];
$refsect1s = $xml->getElementsByTagName('refsect1');
foreach ($refsect1s as $refsect1) {
$role = $refsect1->getAttribute('role');
break;
case 'parameters':
- $params = array();
+ $params = [];
$vars = $refsect1->getElementsByTagName('varlistentry');
foreach ($vars as $var) {
if ($name = $var->getElementsByTagName('parameter')->item(0)) {
- $params[] = array(
+ $params[] = [
'name' => '$' . $name->textContent,
'type' => find_type($xml, $name->textContent),
'description' => extract_paragraphs($var),
- );
+ ];
}
}
$doc['description'] = trim($desc);
}
- $ids = array();
+ $ids = [];
foreach ($xml->getElementsByTagName('refname') as $ref) {
$ids[] = $ref->textContent;
}
- return array($ids, format_doc($doc));
+ return [$ids, format_doc($doc)];
}
function format_class_doc($xml)
{
// @todo implement this
- return array(array(), null);
+ return [[], null];
}
$dir = new RecursiveDirectoryIterator($argv[1]);
});
$iterator = new RecursiveIteratorIterator($filter);
-$docs = array();
+$docs = [];
foreach ($iterator as $file) {
$xmlstr = str_replace('&', '&', file_get_contents($file));
} elseif ($xml->getElementsByTagName('classref')->length !== 0) {
list($ids, $doc) = format_class_doc($xml);
} else {
- $ids = array();
+ $ids = [];
$doc = null;
}
$db->query('CREATE TABLE php_manual (id char(256) PRIMARY KEY, doc TEXT)');
$cmd = $db->prepare('INSERT INTO php_manual (id, doc) VALUES (?, ?)');
foreach ($docs as $id => $doc) {
- $cmd->execute(array($id, $doc));
+ $cmd->execute([$id, $doc]);
}