forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParameter.php
More file actions
101 lines (76 loc) · 2.67 KB
/
Copy pathParameter.php
File metadata and controls
101 lines (76 loc) · 2.67 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
<?php
class Parameter
{
public $processor;
public $name; // rect, copy, etc
public $types = []; // an array containing all possible types it can be: string, number, etc
public $help = [];
public $optional = false;
public $default = null; // assigned value is the default value
public $debug = '';
public function __construct($processor, $line)
{
$this->processor = $processor;
preg_match("/.*(@param)\s?{(\S*)} (\S*)( - ?)?(.*)/", $line, $output);
// $this->processor->log("Parameter count: " . count($output));
if (count($output) > 2)
{
// $this->processor->log("parsePhaser parameter");
$this->parsePhaser($output);
}
else
{
preg_match("/(@param)\s(\S*)\s{(\S*)}\s?(.*)?/", $line, $output);
// $this->processor->log("parsePixi parameter - " . count($output));
if (count($output) > 0)
{
$this->parsePixi($output);
}
}
}
public function parsePhaser($output)
{
$name = $output[3];
// $this->processor->log("parameter: $name");
if ($name[0] === '[')
{
$this->optional = true;
$name = substr($name, 1, -1);
// Default?
$equals = strpos($name, '=');
if ($equals > 0)
{
$this->default = (string) substr($name, $equals + 1);
$name = substr($name, 0, $equals);
}
}
$this->name = $name;
$this->types = $this->processor->parseTypes($output[2], false, $name);
$this->help[] = $output[5];
}
public function parsePixi($output)
{
$this->name = $output[2];
// $this->processor->log("parameter: $this->name");
$this->types = $this->processor->parseTypes($output[3], true, $this->name);
if (isset($output[4]))
{
$this->help[] = $output[4];
}
}
public function getArray()
{
return array(
'name' => $this->name,
'type' => $this->types,
'help' => implode('\n', $this->help),
'optional' => $this->optional,
'default' => $this->default
);
}
public function getJSON()
{
return json_encode($this->getArray());
}
}
?>