Debian Codegraph @

tests/phpunit/mocks/content/DummyNonTextContentHandler.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\Content\Content;
4 use MediaWiki\Content\Renderer\ContentParseParams;
5 use MediaWiki\Parser\ParserOutput;
6
7 class DummyNonTextContentHandler extends DummyContentHandlerForTesting {
8
9 public function __construct( $dataModel ) {
10 parent::__construct( $dataModel, [ "testing-nontext" ] );
11 }
12
13 /**
14 * @see ContentHandler::serializeContent
15 *
16 * @param Content $content
17 * @param string|null $format
18 *
19 * @return string
20 */
21 public function serializeContent( Content $content, $format = null ) {
22 return $content->serialize();
23 }
24
25 /**
26 * @see ContentHandler::unserializeContent
27 *
28 * @param string $blob
29 * @param string|null $format Unused.
30 *
31 * @return Content
32 */
33 public function unserializeContent( $blob, $format = null ) {
34 return new DummyNonTextContent( $blob );
35 }
36
37 /**
38 * Creates an empty Content object of the type supported by this ContentHandler.
39 * @return DummyNonTextContent
40 */
41 public function makeEmptyContent() {
42 return new DummyNonTextContent( '' );
43 }
44
45 public function supportsDirectApiEditing() {
46 return true;
47 }
48
49 /**
50 * @see ContentHandler::fillParserOutput()
51 *
52 * @since 1.38
53 * @param Content $content
54 * @param ContentParseParams $cpoParams
55 * @param ParserOutput &$output The output object to fill (reference).
56 */
57 protected function fillParserOutput(
58 Content $content,
59 ContentParseParams $cpoParams,
60 ParserOutput &$output
61 ) {
62 '@phan-var DummyNonTextContent $content';
63 $output = new ParserOutput( $content->serialize() );
64 }
65 }