MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
class.phpwsdlparser.php
Ir para a documentação deste ficheiro.
1
<?php
2
3
/*
4
PhpWsdl - Generate WSDL from PHP
5
Copyright (C) 2011 Andreas Zimmermann, wan24.de
6
7
This program is free software; you can redistribute it and/or modify it under
8
the terms of the GNU General Public License as published by the Free Software
9
Foundation; either version 3 of the License, or (at your option) any later
10
version.
11
12
This program is distributed in the hope that it will be useful, but WITHOUT
13
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License along with
17
this program; if not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
if
(basename($_SERVER[
'SCRIPT_FILENAME'
])==basename(__FILE__))
21
exit;
22
28
class
PhpWsdlParser
{
34
public
$Server
;
42
public
static
$ParseRelevantRx
=
'/\/\*\*([^\*]*\*+(?:[^\*\/][^\*]*\*+)*)\/(\s*(public\s+)?function\s+([^\s|\(]+)\s*\()?/is'
;
51
public
static
$ParseKeywordsRx
=
'/^(\s*\*\s*\@([^\s|\n]+)([^\n]*))$/m'
;
58
public
static
$ParseDocsRx
=
'/^[^\*|\n]*\*[ |\t]+([^\*|\s|\@|\/|\n][^\n]*)?$/m'
;
59
65
public
function
PhpWsdlParser
($server){
66
self::__construct
($server);
67
}
68
69
public
function
__construct
($server){
70
PhpWsdl::Debug
(
'New PhpWsdlParser'
);
71
$this->Server=$server;
72
}
73
79
public
function
Parse
($str){
80
PhpWsdl::Debug
(
'Parse a string'
);
81
if
(!
PhpWsdl::CallHook
(
82
'BeforeParseHook'
,
83
Array(
84
'sender'
=> $this,
85
'server'
=> $this->Server,
86
'str'
=> &$str
87
)
88
)
89
)
90
return
;
91
// Match all relevant strings
92
$defs=Array();
93
preg_match_all(
PhpWsdlParser::$ParseRelevantRx
,$str,$defs);
94
$i=-1;
95
$len=
sizeof
($defs[0]);
96
PhpWsdl::Debug
(
'Matched '
.$len.
' relevant strings to parse'
);
97
while
(++$i<$len){
98
$def=$defs[1][$i];
99
$method=$defs[4][$i];
100
if
($method!=
''
)
101
PhpWsdl::Debug
(
'Method: "'
.$method.
'"'
);
102
// Parse keywords
103
$keywords=Array();
104
$temp=Array();
105
preg_match_all(
PhpWsdlParser::$ParseKeywordsRx
,$def,$temp);
106
$j=-1;
107
$tLen=
sizeof
($temp[0]);
108
while
(++$j<$tLen)
109
$keywords[]=Array(
110
$temp[2][$j],
111
trim($temp[3][$j])
112
);
113
if
(
PhpWsdl::$Debugging
)
114
PhpWsdl::Debug
(
'Keywords: '
.print_r($keywords,
true
));
115
// Parse documentation
116
if
($this->Server->ParseDocs){
117
$docs=Array();
118
$temp=Array();
119
preg_match_all(
PhpWsdlParser::$ParseDocsRx
,$def,$temp);
120
$j=-1;
121
$tLen=
sizeof
($temp[0]);
122
while
(++$j<$tLen)
123
$docs[]=trim($temp[1][$j]);
124
$docs=trim(implode(
"\n"
,$docs));
125
if
($docs==
''
)
126
$docs=
null
;
127
if
(!is_null($docs))
128
PhpWsdl::Debug
(
'Docs: '
.$docs);
129
}
else
{
130
$docs=
null
;
131
}
132
// Create objects
133
$this->
InterpretDefinition
($def,$method,$keywords,$docs);
134
}
135
PhpWsdl::CallHook
(
136
'AfterParseHook'
,
137
Array(
138
'sender'
=> $this,
139
'server'
=> $this->Server,
140
'str'
=> &$str
141
)
142
);
143
}
144
151
public
function
InterpretDefinition
($def,$method,$keywords,$docs){
152
PhpWsdl::Debug
(
'Interpret definition'
);
153
if
(!
PhpWsdl::CallHook
(
154
'BeforeInterpretDefinitionHook'
,
155
Array(
156
'sender'
=> $this,
157
'server'
=> $this->Server,
158
'def'
=> &$def,
159
'method'
=> &$method,
160
'keywords'
=> &$keywords,
161
'docs'
=> &$docs
162
)
163
)
164
)
165
return
null
;
166
// Initialize some variables
167
$param=Array();
// List ob parameter objects
168
$return=
null
;
// The return value object
169
$elements=Array();
// List of element objects
170
$settings=Array();
// Settings hash
171
$omit=
false
;
// Omit the object
172
$type=
null
;
// Type identifier
173
$buffer=Array();
// Other data
174
// Interpret keywords
175
$i=-1;
176
$len=
sizeof
($keywords);
177
while
(++$i<$len){
178
$keyword=$keywords[$i];
179
if
(
PhpWsdl::$Debugging
)
180
PhpWsdl::Debug
(
'Interpret keyword '
.print_r($keyword,
true
));
181
// Call the global keyword handler
182
if
(!
PhpWsdl::CallHook
(
183
'InterpretKeywordHook'
,
184
Array(
185
'sender'
=> $this,
186
'server'
=> $this->Server,
187
'def'
=> &$def,
188
'method'
=> &$method,
189
'keywords'
=> &$keywords,
190
'docs'
=> &$docs,
191
'param'
=> &$param,
192
'elements'
=> &$elements,
193
'return'
=> &$return,
194
'settings'
=> &$settings,
195
'omit'
=> &$omit,
196
'keyword'
=> &$keyword,
197
'type'
=> &$type,
198
'buffer'
=> &$buffer,
199
'newkeyword'
=> &$newkeyword
200
)
201
)
202
)
203
continue
;
204
if
($omit)
205
return
null
;
206
// Call the keyword handler
207
if
(!
PhpWsdl::CallHook
(
208
'InterpretKeyword'
.$keyword[0].
'Hook'
,
209
Array(
210
'sender'
=> $this,
211
'server'
=> $this->Server,
212
'def'
=> &$def,
213
'method'
=> &$method,
214
'keywords'
=> &$keywords,
215
'docs'
=> &$docs,
216
'param'
=> &$param,
217
'elements'
=> &$elements,
218
'return'
=> &$return,
219
'settings'
=> &$settings,
220
'omit'
=> &$omit,
221
'keyword'
=> &$keyword,
222
'type'
=> &$type,
223
'buffer'
=> &$buffer,
224
'newkeyword'
=> &$newkeyword
225
)
226
)
227
)
228
continue
;
229
if
($omit)
230
return
null
;
231
PhpWsdl::Debug
(
'Keyword not handled'
);
232
}
233
// Create object
234
$obj=
null
;
235
if
(!
PhpWsdl::CallHook
(
236
'CreateObjectHook'
,
237
Array(
238
'sender'
=> $this,
239
'server'
=> $this->Server,
240
'def'
=> &$def,
241
'method'
=> &$method,
242
'keywords'
=> &$keywords,
243
'docs'
=> &$docs,
244
'param'
=> &$param,
245
'elements'
=> &$elements,
246
'return'
=> &$return,
247
'settings'
=> &$settings,
248
'omit'
=> &$omit,
249
'type'
=> &$type,
250
'buffer'
=> &$buffer,
251
'obj'
=> &$obj
252
)
253
)
254
)
255
return
null
;
256
if
(!
PhpWsdl::CallHook
(
257
'AfterInterpretDefinitionHook'
,
258
Array(
259
'sender'
=> $this,
260
'server'
=> $this->Server,
261
'def'
=> &$def,
262
'method'
=> &$method,
263
'keywords'
=> &$keywords,
264
'docs'
=> &$docs,
265
'param'
=> &$param,
266
'elements'
=> &$elements,
267
'return'
=> &$return,
268
'settings'
=> &$settings,
269
'omit'
=> &$omit,
270
'type'
=> &$type,
271
'buffer'
=> &$buffer,
272
'obj'
=> &$obj
273
)
274
)
275
)
276
return
null
;
277
PhpWsdl::Debug
(
'Object '
.((is_null($obj))?
'not created'
:
'created'
));
278
return
$obj;
279
}
280
}
PhpWsdlParser
Definição
class.phpwsdlparser.php:28
PhpWsdlParser\Parse
Parse($str)
Definição
class.phpwsdlparser.php:79
PhpWsdlParser\$ParseKeywordsRx
static $ParseKeywordsRx
Definição
class.phpwsdlparser.php:51
PhpWsdlParser\__construct
__construct($server)
Definição
class.phpwsdlparser.php:69
PhpWsdlParser\$ParseRelevantRx
static $ParseRelevantRx
Definição
class.phpwsdlparser.php:42
PhpWsdlParser\InterpretDefinition
InterpretDefinition($def, $method, $keywords, $docs)
Definição
class.phpwsdlparser.php:151
PhpWsdlParser\PhpWsdlParser
PhpWsdlParser($server)
Definição
class.phpwsdlparser.php:65
PhpWsdlParser\$ParseDocsRx
static $ParseDocsRx
Definição
class.phpwsdlparser.php:58
PhpWsdlParser\$Server
$Server
Definição
class.phpwsdlparser.php:34
PhpWsdl\Debug
static Debug($str)
Definição
class.phpwsdl.php:2399
PhpWsdl\$Debugging
static $Debugging
Definição
class.phpwsdl.php:376
PhpWsdl\CallHook
static CallHook($name, $data=null)
Definição
class.phpwsdl.php:2320
classes
contrib
phpWsdl
class.phpwsdlparser.php
Gerado por
1.10.0