Merge "Add .pipeline/ with dev image variant"
[lhc/web/wiklou.git] / includes / parser / PPFrame.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup Parser
20 */
21
22 /**
23 * @ingroup Parser
24 *
25 * @property int $depth
26 * @property PPFrame $parent
27 */
28 interface PPFrame {
29 const NO_ARGS = 1;
30 const NO_TEMPLATES = 2;
31 const STRIP_COMMENTS = 4;
32 const NO_IGNORE = 8;
33 const RECOVER_COMMENTS = 16;
34 const NO_TAGS = 32;
35
36 const RECOVER_ORIG = self::NO_ARGS | self::NO_TEMPLATES | self::NO_IGNORE |
37 self::RECOVER_COMMENTS | self::NO_TAGS;
38
39 /** This constant exists when $indexOffset is supported in newChild() */
40 const SUPPORTS_INDEX_OFFSET = 1;
41
42 /**
43 * Create a child frame
44 *
45 * @param array|bool $args
46 * @param bool|Title $title
47 * @param int $indexOffset A number subtracted from the index attributes of the arguments
48 *
49 * @return PPFrame
50 */
51 public function newChild( $args = false, $title = false, $indexOffset = 0 );
52
53 /**
54 * Expand a document tree node, caching the result on its parent with the given key
55 * @param string|int $key
56 * @param string|PPNode $root
57 * @param int $flags
58 * @return string
59 */
60 public function cachedExpand( $key, $root, $flags = 0 );
61
62 /**
63 * Expand a document tree node
64 * @param string|PPNode $root
65 * @param int $flags
66 * @return string
67 */
68 public function expand( $root, $flags = 0 );
69
70 /**
71 * Implode with flags for expand()
72 * @param string $sep
73 * @param int $flags
74 * @param string|PPNode $args,...
75 * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
76 * @return string
77 */
78 public function implodeWithFlags( $sep, $flags /*, ... */ );
79
80 /**
81 * Implode with no flags specified
82 * @param string $sep
83 * @param string|PPNode $args,...
84 * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
85 * @return string
86 */
87 public function implode( $sep /*, ... */ );
88
89 /**
90 * Makes an object that, when expand()ed, will be the same as one obtained
91 * with implode()
92 * @param string $sep
93 * @param string|PPNode ...$args
94 * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
95 * @return PPNode
96 */
97 public function virtualImplode( $sep /* ...$args */ );
98
99 /**
100 * Virtual implode with brackets
101 * @param string $start
102 * @param string $sep
103 * @param string $end
104 * @param string|PPNode ...$args
105 * @suppress PhanCommentParamWithoutRealParam HHVM bug T228695#5450847
106 * @return PPNode
107 */
108 public function virtualBracketedImplode( $start, $sep, $end /* ...$args */ );
109
110 /**
111 * Returns true if there are no arguments in this frame
112 *
113 * @return bool
114 */
115 public function isEmpty();
116
117 /**
118 * Returns all arguments of this frame
119 * @return array
120 */
121 public function getArguments();
122
123 /**
124 * Returns all numbered arguments of this frame
125 * @return array
126 */
127 public function getNumberedArguments();
128
129 /**
130 * Returns all named arguments of this frame
131 * @return array
132 */
133 public function getNamedArguments();
134
135 /**
136 * Get an argument to this frame by name
137 * @param int|string $name
138 * @return string|bool
139 */
140 public function getArgument( $name );
141
142 /**
143 * Returns true if the infinite loop check is OK, false if a loop is detected
144 *
145 * @param Title $title
146 * @return bool
147 */
148 public function loopCheck( $title );
149
150 /**
151 * Return true if the frame is a template frame
152 * @return bool
153 */
154 public function isTemplate();
155
156 /**
157 * Set the "volatile" flag.
158 *
159 * Note that this is somewhat of a "hack" in order to make extensions
160 * with side effects (such as Cite) work with the PHP parser. New
161 * extensions should be written in a way that they do not need this
162 * function, because other parsers (such as Parsoid) are not guaranteed
163 * to respect it, and it may be removed in the future.
164 *
165 * @param bool $flag
166 */
167 public function setVolatile( $flag = true );
168
169 /**
170 * Get the "volatile" flag.
171 *
172 * Callers should avoid caching the result of an expansion if it has the
173 * volatile flag set.
174 *
175 * @see self::setVolatile()
176 * @return bool
177 */
178 public function isVolatile();
179
180 /**
181 * Get the TTL of the frame's output.
182 *
183 * This is the maximum amount of time, in seconds, that this frame's
184 * output should be cached for. A value of null indicates that no
185 * maximum has been specified.
186 *
187 * Note that this TTL only applies to caching frames as parts of pages.
188 * It is not relevant to caching the entire rendered output of a page.
189 *
190 * @return int|null
191 */
192 public function getTTL();
193
194 /**
195 * Set the TTL of the output of this frame and all of its ancestors.
196 * Has no effect if the new TTL is greater than the one already set.
197 * Note that it is the caller's responsibility to change the cache
198 * expiry of the page as a whole, if such behavior is desired.
199 *
200 * @see self::getTTL()
201 * @param int $ttl
202 */
203 public function setTTL( $ttl );
204
205 /**
206 * Get a title of frame
207 *
208 * @return Title
209 */
210 public function getTitle();
211 }