php.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. ace.define("ace/snippets/php",[], function(require, exports, module) {
  2. "use strict";
  3. exports.snippetText = "snippet <?\n\
  4. <?php\n\
  5. \n\
  6. ${1}\n\
  7. snippet ec\n\
  8. echo ${1};\n\
  9. snippet <?e\n\
  10. <?php echo ${1} ?>\n\
  11. # this one is for php5.4\n\
  12. snippet <?=\n\
  13. <?=${1}?>\n\
  14. snippet ns\n\
  15. namespace ${1:Foo\\Bar\\Baz};\n\
  16. ${2}\n\
  17. snippet use\n\
  18. use ${1:Foo\\Bar\\Baz};\n\
  19. ${2}\n\
  20. snippet c\n\
  21. ${1:abstract }class ${2:$FILENAME}\n\
  22. {\n\
  23. ${3}\n\
  24. }\n\
  25. snippet i\n\
  26. interface ${1:$FILENAME}\n\
  27. {\n\
  28. ${2}\n\
  29. }\n\
  30. snippet t.\n\
  31. $this->${1}\n\
  32. snippet f\n\
  33. function ${1:foo}(${2:array }${3:$bar})\n\
  34. {\n\
  35. ${4}\n\
  36. }\n\
  37. # method\n\
  38. snippet m\n\
  39. ${1:abstract }${2:protected}${3: static} function ${4:foo}(${5:array }${6:$bar})\n\
  40. {\n\
  41. ${7}\n\
  42. }\n\
  43. # setter method\n\
  44. snippet sm \n\
  45. /**\n\
  46. * Sets the value of ${1:foo}\n\
  47. *\n\
  48. * @param ${2:$1} $$1 ${3:description}\n\
  49. *\n\
  50. * @return ${4:$FILENAME}\n\
  51. */\n\
  52. ${5:public} function set${6:$2}(${7:$2 }$$1)\n\
  53. {\n\
  54. $this->${8:$1} = $$1;\n\
  55. return $this;\n\
  56. }${9}\n\
  57. # getter method\n\
  58. snippet gm\n\
  59. /**\n\
  60. * Gets the value of ${1:foo}\n\
  61. *\n\
  62. * @return ${2:$1}\n\
  63. */\n\
  64. ${3:public} function get${4:$2}()\n\
  65. {\n\
  66. return $this->${5:$1};\n\
  67. }${6}\n\
  68. #setter\n\
  69. snippet $s\n\
  70. ${1:$foo}->set${2:Bar}(${3});\n\
  71. #getter\n\
  72. snippet $g\n\
  73. ${1:$foo}->get${2:Bar}();\n\
  74. \n\
  75. # Tertiary conditional\n\
  76. snippet =?:\n\
  77. $${1:foo} = ${2:true} ? ${3:a} : ${4};\n\
  78. snippet ?:\n\
  79. ${1:true} ? ${2:a} : ${3}\n\
  80. \n\
  81. snippet C\n\
  82. $_COOKIE['${1:variable}']${2}\n\
  83. snippet E\n\
  84. $_ENV['${1:variable}']${2}\n\
  85. snippet F\n\
  86. $_FILES['${1:variable}']${2}\n\
  87. snippet G\n\
  88. $_GET['${1:variable}']${2}\n\
  89. snippet P\n\
  90. $_POST['${1:variable}']${2}\n\
  91. snippet R\n\
  92. $_REQUEST['${1:variable}']${2}\n\
  93. snippet S\n\
  94. $_SERVER['${1:variable}']${2}\n\
  95. snippet SS\n\
  96. $_SESSION['${1:variable}']${2}\n\
  97. \n\
  98. # the following are old ones\n\
  99. snippet inc\n\
  100. include '${1:file}';${2}\n\
  101. snippet inc1\n\
  102. include_once '${1:file}';${2}\n\
  103. snippet req\n\
  104. require '${1:file}';${2}\n\
  105. snippet req1\n\
  106. require_once '${1:file}';${2}\n\
  107. # Start Docblock\n\
  108. snippet /*\n\
  109. /**\n\
  110. * ${1}\n\
  111. */\n\
  112. # Class - post doc\n\
  113. snippet doc_cp\n\
  114. /**\n\
  115. * ${1:undocumented class}\n\
  116. *\n\
  117. * @package ${2:default}\n\
  118. * @subpackage ${3:default}\n\
  119. * @author ${4:`g:snips_author`}\n\
  120. */${5}\n\
  121. # Class Variable - post doc\n\
  122. snippet doc_vp\n\
  123. /**\n\
  124. * ${1:undocumented class variable}\n\
  125. *\n\
  126. * @var ${2:string}\n\
  127. */${3}\n\
  128. # Class Variable\n\
  129. snippet doc_v\n\
  130. /**\n\
  131. * ${3:undocumented class variable}\n\
  132. *\n\
  133. * @var ${4:string}\n\
  134. */\n\
  135. ${1:var} $${2};${5}\n\
  136. # Class\n\
  137. snippet doc_c\n\
  138. /**\n\
  139. * ${3:undocumented class}\n\
  140. *\n\
  141. * @package ${4:default}\n\
  142. * @subpackage ${5:default}\n\
  143. * @author ${6:`g:snips_author`}\n\
  144. */\n\
  145. ${1:}class ${2:}\n\
  146. {\n\
  147. ${7}\n\
  148. } // END $1class $2\n\
  149. # Constant Definition - post doc\n\
  150. snippet doc_dp\n\
  151. /**\n\
  152. * ${1:undocumented constant}\n\
  153. */${2}\n\
  154. # Constant Definition\n\
  155. snippet doc_d\n\
  156. /**\n\
  157. * ${3:undocumented constant}\n\
  158. */\n\
  159. define(${1}, ${2});${4}\n\
  160. # Function - post doc\n\
  161. snippet doc_fp\n\
  162. /**\n\
  163. * ${1:undocumented function}\n\
  164. *\n\
  165. * @return ${2:void}\n\
  166. * @author ${3:`g:snips_author`}\n\
  167. */${4}\n\
  168. # Function signature\n\
  169. snippet doc_s\n\
  170. /**\n\
  171. * ${4:undocumented function}\n\
  172. *\n\
  173. * @return ${5:void}\n\
  174. * @author ${6:`g:snips_author`}\n\
  175. */\n\
  176. ${1}function ${2}(${3});${7}\n\
  177. # Function\n\
  178. snippet doc_f\n\
  179. /**\n\
  180. * ${4:undocumented function}\n\
  181. *\n\
  182. * @return ${5:void}\n\
  183. * @author ${6:`g:snips_author`}\n\
  184. */\n\
  185. ${1}function ${2}(${3})\n\
  186. {${7}\n\
  187. }\n\
  188. # Header\n\
  189. snippet doc_h\n\
  190. /**\n\
  191. * ${1}\n\
  192. *\n\
  193. * @author ${2:`g:snips_author`}\n\
  194. * @version ${3:$Id$}\n\
  195. * @copyright ${4:$2}, `strftime('%d %B, %Y')`\n\
  196. * @package ${5:default}\n\
  197. */\n\
  198. \n\
  199. # Interface\n\
  200. snippet interface\n\
  201. /**\n\
  202. * ${2:undocumented class}\n\
  203. *\n\
  204. * @package ${3:default}\n\
  205. * @author ${4:`g:snips_author`}\n\
  206. */\n\
  207. interface ${1:$FILENAME}\n\
  208. {\n\
  209. ${5}\n\
  210. }\n\
  211. # class ...\n\
  212. snippet class\n\
  213. /**\n\
  214. * ${1}\n\
  215. */\n\
  216. class ${2:$FILENAME}\n\
  217. {\n\
  218. ${3}\n\
  219. /**\n\
  220. * ${4}\n\
  221. */\n\
  222. ${5:public} function ${6:__construct}(${7:argument})\n\
  223. {\n\
  224. ${8:// code...}\n\
  225. }\n\
  226. }\n\
  227. # define(...)\n\
  228. snippet def\n\
  229. define('${1}'${2});${3}\n\
  230. # defined(...)\n\
  231. snippet def?\n\
  232. ${1}defined('${2}')${3}\n\
  233. snippet wh\n\
  234. while (${1:/* condition */}) {\n\
  235. ${2:// code...}\n\
  236. }\n\
  237. # do ... while\n\
  238. snippet do\n\
  239. do {\n\
  240. ${2:// code... }\n\
  241. } while (${1:/* condition */});\n\
  242. snippet if\n\
  243. if (${1:/* condition */}) {\n\
  244. ${2:// code...}\n\
  245. }\n\
  246. snippet ifil\n\
  247. <?php if (${1:/* condition */}): ?>\n\
  248. ${2:<!-- code... -->}\n\
  249. <?php endif; ?>\n\
  250. snippet ife\n\
  251. if (${1:/* condition */}) {\n\
  252. ${2:// code...}\n\
  253. } else {\n\
  254. ${3:// code...}\n\
  255. }\n\
  256. ${4}\n\
  257. snippet ifeil\n\
  258. <?php if (${1:/* condition */}): ?>\n\
  259. ${2:<!-- html... -->}\n\
  260. <?php else: ?>\n\
  261. ${3:<!-- html... -->}\n\
  262. <?php endif; ?>\n\
  263. ${4}\n\
  264. snippet else\n\
  265. else {\n\
  266. ${1:// code...}\n\
  267. }\n\
  268. snippet elseif\n\
  269. elseif (${1:/* condition */}) {\n\
  270. ${2:// code...}\n\
  271. }\n\
  272. snippet switch\n\
  273. switch ($${1:variable}) {\n\
  274. case '${2:value}':\n\
  275. ${3:// code...}\n\
  276. break;\n\
  277. ${5}\n\
  278. default:\n\
  279. ${4:// code...}\n\
  280. break;\n\
  281. }\n\
  282. snippet case\n\
  283. case '${1:value}':\n\
  284. ${2:// code...}\n\
  285. break;${3}\n\
  286. snippet for\n\
  287. for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {\n\
  288. ${4: // code...}\n\
  289. }\n\
  290. snippet foreach\n\
  291. foreach ($${1:variable} as $${2:value}) {\n\
  292. ${3:// code...}\n\
  293. }\n\
  294. snippet foreachil\n\
  295. <?php foreach ($${1:variable} as $${2:value}): ?>\n\
  296. ${3:<!-- html... -->}\n\
  297. <?php endforeach; ?>\n\
  298. snippet foreachk\n\
  299. foreach ($${1:variable} as $${2:key} => $${3:value}) {\n\
  300. ${4:// code...}\n\
  301. }\n\
  302. snippet foreachkil\n\
  303. <?php foreach ($${1:variable} as $${2:key} => $${3:value}): ?>\n\
  304. ${4:<!-- html... -->}\n\
  305. <?php endforeach; ?>\n\
  306. # $... = array (...)\n\
  307. snippet array\n\
  308. $${1:arrayName} = array('${2}' => ${3});${4}\n\
  309. snippet try\n\
  310. try {\n\
  311. ${2}\n\
  312. } catch (${1:Exception} $e) {\n\
  313. }\n\
  314. # lambda with closure\n\
  315. snippet lambda\n\
  316. ${1:static }function (${2:args}) use (${3:&$x, $y /*put vars in scope (closure) */}) {\n\
  317. ${4}\n\
  318. };\n\
  319. # pre_dump();\n\
  320. snippet pd\n\
  321. echo '<pre>'; var_dump(${1}); echo '</pre>';\n\
  322. # pre_dump(); die();\n\
  323. snippet pdd\n\
  324. echo '<pre>'; var_dump(${1}); echo '</pre>'; die(${2:});\n\
  325. snippet vd\n\
  326. var_dump(${1});\n\
  327. snippet vdd\n\
  328. var_dump(${1}); die(${2:});\n\
  329. snippet http_redirect\n\
  330. header (\"HTTP/1.1 301 Moved Permanently\"); \n\
  331. header (\"Location: \".URL); \n\
  332. exit();\n\
  333. # Getters & Setters\n\
  334. snippet gs\n\
  335. /**\n\
  336. * Gets the value of ${1:foo}\n\
  337. *\n\
  338. * @return ${2:$1}\n\
  339. */\n\
  340. public function get${3:$2}()\n\
  341. {\n\
  342. return $this->${4:$1};\n\
  343. }\n\
  344. \n\
  345. /**\n\
  346. * Sets the value of $1\n\
  347. *\n\
  348. * @param $2 $$1 ${5:description}\n\
  349. *\n\
  350. * @return ${6:$FILENAME}\n\
  351. */\n\
  352. public function set$3(${7:$2 }$$1)\n\
  353. {\n\
  354. $this->$4 = $$1;\n\
  355. return $this;\n\
  356. }${8}\n\
  357. # anotation, get, and set, useful for doctrine\n\
  358. snippet ags\n\
  359. /**\n\
  360. * ${1:description}\n\
  361. * \n\
  362. * @${7}\n\
  363. */\n\
  364. ${2:protected} $${3:foo};\n\
  365. \n\
  366. public function get${4:$3}()\n\
  367. {\n\
  368. return $this->$3;\n\
  369. }\n\
  370. \n\
  371. public function set$4(${5:$4 }$${6:$3})\n\
  372. {\n\
  373. $this->$3 = $$6;\n\
  374. return $this;\n\
  375. }\n\
  376. snippet rett\n\
  377. return true;\n\
  378. snippet retf\n\
  379. return false;\n\
  380. ";
  381. exports.scope = "php";
  382. });
  383. (function() {
  384. ace.require(["ace/snippets/php"], function(m) {
  385. if (typeof module == "object" && typeof exports == "object" && module) {
  386. module.exports = m;
  387. }
  388. });
  389. })();