3030 *
3131 * @final
3232 */
33- class Escaper
33+ class Escaper implements EscaperInterface
3434{
3535 /**
3636 * Entity Map mapping Unicode codepoints to any available named HTML entities.
@@ -183,24 +183,13 @@ public function getEncoding()
183183 return $ this ->encoding ;
184184 }
185185
186- /**
187- * Escape a string for the HTML Body context where there are very few characters
188- * of special meaning. Internally this will use htmlspecialchars().
189- *
190- * @return ($string is non-empty-string ? non-empty-string : string)
191- */
186+ /** @inheritDoc */
192187 public function escapeHtml (string $ string )
193188 {
194189 return htmlspecialchars ($ string , $ this ->htmlSpecialCharsFlags , $ this ->encoding );
195190 }
196191
197- /**
198- * Escape a string for the HTML Attribute context. We use an extended set of characters
199- * to escape that are not covered by htmlspecialchars() to cover cases where an attribute
200- * might be unquoted or quoted illegally (e.g. backticks are valid quotes for IE).
201- *
202- * @return ($string is non-empty-string ? non-empty-string : string)
203- */
192+ /** @inheritDoc */
204193 public function escapeHtmlAttr (string $ string )
205194 {
206195 $ string = $ this ->toUtf8 ($ string );
@@ -214,17 +203,7 @@ public function escapeHtmlAttr(string $string)
214203 return $ this ->fromUtf8 ($ result );
215204 }
216205
217- /**
218- * Escape a string for the Javascript context. This does not use json_encode(). An extended
219- * set of characters are escaped beyond ECMAScript's rules for Javascript literal string
220- * escaping in order to prevent misinterpretation of Javascript as HTML leading to the
221- * injection of special characters and entities. The escaping used should be tolerant
222- * of cases where HTML escaping was not applied on top of Javascript escaping correctly.
223- * Backslash escaping is not used as it still leaves the escaped character as-is and so
224- * is not useful in a HTML context.
225- *
226- * @return ($string is non-empty-string ? non-empty-string : string)
227- */
206+ /** @inheritDoc */
228207 public function escapeJs (string $ string )
229208 {
230209 $ string = $ this ->toUtf8 ($ string );
@@ -238,24 +217,13 @@ public function escapeJs(string $string)
238217 return $ this ->fromUtf8 ($ result );
239218 }
240219
241- /**
242- * Escape a string for the URI or Parameter contexts. This should not be used to escape
243- * an entire URI - only a subcomponent being inserted. The function is a simple proxy
244- * to rawurlencode() which now implements RFC 3986 since PHP 5.3 completely.
245- *
246- * @return ($string is non-empty-string ? non-empty-string : string)
247- */
220+ /** @inheritDoc */
248221 public function escapeUrl (string $ string )
249222 {
250223 return rawurlencode ($ string );
251224 }
252225
253- /**
254- * Escape a string for the CSS context. CSS escaping can be applied to any string being
255- * inserted into CSS and escapes everything except alphanumerics.
256- *
257- * @return ($string is non-empty-string ? non-empty-string : string)
258- */
226+ /** @inheritDoc */
259227 public function escapeCss (string $ string )
260228 {
261229 $ string = $ this ->toUtf8 ($ string );
0 commit comments