Skip to content

Commit 0114f66

Browse files
committed
Split the methods and properties into public, protected and private sub-arrays.
1 parent 0c4d4cd commit 0114f66

2 files changed

Lines changed: 101 additions & 6 deletions

File tree

docgen/src/Processor.php

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ public function __construct($docgen, $file)
2727
$this->properties = [];
2828
$this->file = $file;
2929

30+
$this->methods['private'] = [];
31+
$this->methods['protected'] = [];
32+
$this->methods['public'] = [];
33+
$this->methods['static'] = [];
34+
35+
$this->properties['private'] = [];
36+
$this->properties['protected'] = [];
37+
$this->properties['public'] = [];
38+
3039
$this->scanFile();
3140
}
3241

@@ -94,23 +103,56 @@ private function scanFile() {
94103
{
95104
$tempMethod = new Method($this, $this->blocks[$i]);
96105

97-
$this->methods[$tempMethod->name] = $tempMethod;
106+
if ($tempMethod->isPublic)
107+
{
108+
$this->methods['public'][$tempMethod->name] = $tempMethod;
109+
}
110+
else if ($tempMethod->isProtected)
111+
{
112+
$this->methods['protected'][$tempMethod->name] = $tempMethod;
113+
}
114+
else if ($tempMethod->isPrivate)
115+
{
116+
$this->methods['private'][$tempMethod->name] = $tempMethod;
117+
}
118+
else if ($tempMethod->isStatic)
119+
{
120+
$this->methods['static'][$tempMethod->name] = $tempMethod;
121+
}
98122
}
99123
else if ($this->blocks[$i]->isProperty)
100124
{
101125
$tempProperty = new Property($this, $this->blocks[$i]);
102126

103127
if ($tempProperty->corrupted === false)
104128
{
105-
$this->properties[$tempProperty->name] = $tempProperty;
129+
if ($tempProperty->isPublic)
130+
{
131+
$this->properties['public'][$tempProperty->name] = $tempProperty;
132+
}
133+
else if ($tempProperty->isProtected)
134+
{
135+
$this->properties['protected'][$tempProperty->name] = $tempProperty;
136+
}
137+
else if ($tempProperty->isPrivate)
138+
{
139+
$this->properties['private'][$tempProperty->name] = $tempProperty;
140+
}
106141
}
107142
}
108143
}
109144

110145
// Alphabetically sort the arrays based on the key
111146
ksort($this->consts);
112-
ksort($this->methods);
113-
ksort($this->properties);
147+
148+
ksort($this->methods['public']);
149+
ksort($this->methods['protected']);
150+
ksort($this->methods['private']);
151+
ksort($this->methods['static']);
152+
153+
ksort($this->properties['public']);
154+
ksort($this->properties['protected']);
155+
ksort($this->properties['private']);
114156

115157
}
116158

docgen/view.php

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,40 @@
9292

9393
<h2>Methods</h2>
9494

95+
<h3>Public</h3>
9596
<ul>
9697
<?php
97-
foreach ($data->methods as $methodName => $method)
98+
foreach ($data->methods['public'] as $methodName => $method)
99+
{
100+
echo "<li><a href=\"view.php?src=$src&amp;method={$method->name}\">{$method->name}</a></li>";
101+
}
102+
?>
103+
</ul>
104+
105+
<h3>Protected</h3>
106+
<ul>
107+
<?php
108+
foreach ($data->methods['protected'] as $methodName => $method)
109+
{
110+
echo "<li><a href=\"view.php?src=$src&amp;method={$method->name}\">{$method->name}</a></li>";
111+
}
112+
?>
113+
</ul>
114+
115+
<h3>Private</h3>
116+
<ul>
117+
<?php
118+
foreach ($data->methods['private'] as $methodName => $method)
119+
{
120+
echo "<li><a href=\"view.php?src=$src&amp;method={$method->name}\">{$method->name}</a></li>";
121+
}
122+
?>
123+
</ul>
124+
125+
<h3>Static</h3>
126+
<ul>
127+
<?php
128+
foreach ($data->methods['static'] as $methodName => $method)
98129
{
99130
echo "<li><a href=\"view.php?src=$src&amp;method={$method->name}\">{$method->name}</a></li>";
100131
}
@@ -103,14 +134,36 @@
103134

104135
<h2>Properties</h2>
105136

137+
<h3>Public</h3>
138+
<ul>
139+
<?php
140+
foreach ($data->properties['public'] as $propertyName => $property)
141+
{
142+
echo "<li><a href=\"view.php?src=$src&amp;property={$property->name}\">{$property->name}</a></li>";
143+
}
144+
?>
145+
</ul>
146+
147+
<h3>Protected</h3>
148+
<ul>
149+
<?php
150+
foreach ($data->properties['protected'] as $propertyName => $property)
151+
{
152+
echo "<li><a href=\"view.php?src=$src&amp;property={$property->name}\">{$property->name}</a></li>";
153+
}
154+
?>
155+
</ul>
156+
157+
<h3>Private</h3>
106158
<ul>
107159
<?php
108-
foreach ($data->properties as $propertyName => $property)
160+
foreach ($data->properties['private'] as $propertyName => $property)
109161
{
110162
echo "<li><a href=\"view.php?src=$src&amp;property={$property->name}\">{$property->name}</a></li>";
111163
}
112164
?>
113165
</ul>
114166

167+
115168
</body>
116169
</html>

0 commit comments

Comments
 (0)