forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethod.php
More file actions
124 lines (102 loc) · 3.3 KB
/
Copy pathMethod.php
File metadata and controls
124 lines (102 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
class Method
{
public $line; // number, line number in the source file this is found on?
public $name; // bringToTop, kill, etc
public $title = [];
public $parameters = []; // an array containing the parameters
public $help = [];
public $returns = false;
public $isPublic = true;
public $isProtected = false;
public $isPrivate = false;
public $isStatic = false;
public function __construct($block)
{
// Because zero offset + allowing for final line
$this->line = $block->end + 2;
$name = $block->getLine('@method');
$equals = strpos($name, '#');
if ($equals > 0)
{
$name = substr($name, $equals + 1);
}
else
{
$equals = strrpos($name, '.');
if ($equals > 0)
{
$name = substr($name, $equals + 1);
}
else
{
// No # and no . so we'll assume "@method name" format
$equals = strrpos($name, ' ');
if ($equals > 0)
{
$name = substr($name, $equals + 1);
}
}
}
$this->name = $name;
$params = $block->getLines('@param');
for ($i = 0; $i < count($params); $i++)
{
$this->parameters[] = new Parameter($params[$i]);
}
if ($block->getTypeBoolean('@protected'))
{
$this->isPublic = false;
$this->isProtected = true;
}
else if ($block->getTypeBoolean('@private'))
{
$this->isPublic = false;
$this->isPrivate = true;
}
if ($block->getTypeBoolean('@static'))
{
$this->isStatic = true;
}
$this->title = array("name" => $this->name, "visibility" => $this->getVisibility());
$this->help = $block->cleanContent();
if ($block->getTypeBoolean('@return'))
{
$this->returns = new ReturnType($block->getLine('@return'));
}
}
public function getVisibility()
{
if ($this->isPublic)
{
return 'public';
}
else if ($this->isProtected)
{
return 'protected';
}
else if ($this->isPrivate)
{
return 'private';
}
}
public function getArray()
{
return array(
'title' => $this->title,
'static' => $this->isStatic,
'returns' => $this->returns,
'help' => implode('\n', $this->help),
'line' => $this->line,
'public' => $this->isPublic,
'protected' => $this->isProtected,
'private' => $this->isPrivate,
'parameters' => $this->parameters
);
}
public function getJSON()
{
return json_encode($this->getArray());
}
}
?>