forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClassDesc.php
More file actions
108 lines (86 loc) · 2.97 KB
/
Copy pathClassDesc.php
File metadata and controls
108 lines (86 loc) · 2.97 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
<?php
class ClassDesc
{
public $processor;
public $name; // Phaser.Sprite
public $parameters = []; // an array containing the parameters
public $help = [];
public $extends = '';
public $hasConstructor = false;
public $isStatic = false;
public $corrupted = false;
public function __construct($processor, $block)
{
$this->processor = $processor;
if ($block->getTypeBoolean('@class') === false)
{
$this->corrupted = true;
return;
}
$this->name = $block->getLineContent('@class');
if (substr($this->name, 0, 6) !== 'Phaser')
{
$this->name = 'PIXI.' . $this->name;
}
$this->processor->log("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
$this->processor->log("Class: $this->name");
$this->processor->log("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^");
$params = $block->getLines('@param');
for ($i = 0; $i < count($params); $i++)
{
$this->parameters[] = new Parameter($this->processor, $params[$i]);
}
if ($block->getTypeBoolean('@extends'))
{
$this->extends = $block->getLineContent('@extends');
if (substr($this->extends, 0, 6) !== 'Phaser' && substr($this->extends, 0, 4) !== 'PIXI')
{
$this->extends = 'PIXI.' . $this->extends;
}
}
if ($block->getTypeBoolean('@constructor'))
{
$this->hasConstructor = true;
}
else
{
// Like Phaser.Math
$this->isStatic = true;
}
// This is a problem because the @classdesc block is often multi-line, but repeated in the clear content too.
// So all the classes probably need tidying up before this part will work correctly.
$this->help = $block->cleanContent();
}
public function extendsFrom()
{
if ($this->extends !== '')
{
return true;
}
else
{
return false;
}
}
public function getArray()
{
$params = [];
for ($i = 0; $i < count($this->parameters); $i++)
{
$params[] = $this->parameters[$i]->getArray();
}
return array(
'name' => $this->name,
'extends' => $this->extends,
'static' => $this->isStatic,
'constructor' => $this->hasConstructor,
'parameters' => $params,
'help' => implode('\n', $this->help)
);
}
public function getJSON()
{
return json_encode($this->getArray());
}
}
?>