Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
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
22use MediaWiki\Title\Title;
23
24/**
25 * @ingroup Parser
26 *
27 * @property int $depth
28 * @property PPFrame $parent
29 */
30interface PPFrame {
31    public const NO_ARGS = 1;
32    public const NO_TEMPLATES = 2;
33    public const STRIP_COMMENTS = 4;
34    public const NO_IGNORE = 8;
35    public const RECOVER_COMMENTS = 16;
36    public const NO_TAGS = 32;
37    public const PROCESS_NOWIKI = 64;
38
39    public const RECOVER_ORIG = self::NO_ARGS | self::NO_TEMPLATES | self::NO_IGNORE |
40        self::RECOVER_COMMENTS | self::NO_TAGS;
41
42    /**
43     * Create a child frame
44     *
45     * @param PPNode[]|false $args
46     * @param Title|false $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 ...$params
75     * @return string
76     */
77    public function implodeWithFlags( $sep, $flags, ...$params );
78
79    /**
80     * Implode with no flags specified
81     * @param string $sep
82     * @param string|PPNode ...$params
83     * @return string
84     */
85    public function implode( $sep, ...$params );
86
87    /**
88     * Makes an object that, when expand()ed, will be the same as one obtained
89     * with implode()
90     * @param string $sep
91     * @param string|PPNode ...$params
92     * @return PPNode
93     */
94    public function virtualImplode( $sep, ...$params );
95
96    /**
97     * Virtual implode with brackets
98     * @param string $start
99     * @param string $sep
100     * @param string $end
101     * @param string|PPNode ...$params
102     * @return PPNode
103     */
104    public function virtualBracketedImplode( $start, $sep, $end, ...$params );
105
106    /**
107     * Returns true if there are no arguments in this frame
108     *
109     * @return bool
110     */
111    public function isEmpty();
112
113    /**
114     * Returns all arguments of this frame
115     * @return array
116     */
117    public function getArguments();
118
119    /**
120     * Returns all numbered arguments of this frame
121     * @return array
122     */
123    public function getNumberedArguments();
124
125    /**
126     * Returns all named arguments of this frame
127     * @return array
128     */
129    public function getNamedArguments();
130
131    /**
132     * Get an argument to this frame by name
133     * @param int|string $name
134     * @return string|false
135     */
136    public function getArgument( $name );
137
138    /**
139     * Returns true if the infinite loop check is OK, false if a loop is detected
140     *
141     * @param Title $title
142     * @return bool
143     */
144    public function loopCheck( $title );
145
146    /**
147     * Return true if the frame is a template frame
148     * @return bool
149     */
150    public function isTemplate();
151
152    /**
153     * Set the "volatile" flag.
154     *
155     * Note that this is somewhat of a "hack" in order to make extensions
156     * with side effects (such as Cite) work with the PHP parser. New
157     * extensions should be written in a way that they do not need this
158     * function, because other parsers (such as Parsoid) are not guaranteed
159     * to respect it, and it may be removed in the future.
160     *
161     * @param bool $flag
162     */
163    public function setVolatile( $flag = true );
164
165    /**
166     * Get the "volatile" flag.
167     *
168     * Callers should avoid caching the result of an expansion if it has the
169     * volatile flag set.
170     *
171     * @see self::setVolatile()
172     * @return bool
173     */
174    public function isVolatile();
175
176    /**
177     * Get the TTL of the frame's output.
178     *
179     * This is the maximum amount of time, in seconds, that this frame's
180     * output should be cached for. A value of null indicates that no
181     * maximum has been specified.
182     *
183     * Note that this TTL only applies to caching frames as parts of pages.
184     * It is not relevant to caching the entire rendered output of a page.
185     *
186     * @return int|null
187     */
188    public function getTTL();
189
190    /**
191     * Set the TTL of the output of this frame and all of its ancestors.
192     * Has no effect if the new TTL is greater than the one already set.
193     * Note that it is the caller's responsibility to change the cache
194     * expiry of the page as a whole, if such behavior is desired.
195     *
196     * @see self::getTTL()
197     * @param int $ttl
198     */
199    public function setTTL( $ttl );
200
201    /**
202     * Get a title of frame
203     *
204     * @return Title
205     */
206    public function getTitle();
207}