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
142 lines (116 loc) · 3.95 KB
/
Copy pathMethod.php
File metadata and controls
142 lines (116 loc) · 3.95 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
class Method
{
public $processor;
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 = null;
public $inherited = false;
public $inheritedFrom = '';
public $isPublic = true;
public $isProtected = false;
public $isPrivate = false;
public $isStatic = false;
public function __construct($processor, $block)
{
$this->processor = $processor;
// 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->processor->log("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
// $this->processor->log("Method: $name");
// $this->processor->log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
$this->name = $name;
$params = $block->getLines('@param');
for ($i = 0; $i < count($params); $i++)
{
$this->parameters[] = new Parameter($this->processor, $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($this->processor, $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()
{
$params = [];
foreach ($this->parameters as $key => $value)
{
$params[] = $value->getArray();
}
return array(
'name' => $this->title['name'],
'static' => $this->isStatic,
'returns' => $this->returns,
'help' => implode('\n', $this->help),
'line' => $this->line,
'public' => $this->isPublic,
'protected' => $this->isProtected,
'private' => $this->isPrivate,
'parameters' => $params,
'inherited' => $this->inherited,
'inheritedFrom' => $this->inheritedFrom
);
}
public function getJSON()
{
return json_encode($this->getArray());
}
}
?>