Debian Codegraph @

vendor/wikimedia/parsoid/src/Config/Api/Env.php

raw
1 <?php
2
3 declare( strict_types = 1 );
4
5 namespace Wikimedia\Parsoid\Config\Api;
6
7 use Wikimedia\Parsoid\Config\Env as IEnv;
8 use Wikimedia\Parsoid\Config\StubMetadataCollector;
9
10 /**
11 * An Env accessing MediaWiki via its Action API
12 *
13 * Note this is intended for testing, not performance.
14 */
15 class Env extends IEnv {
16
17 /**
18 * @param array $opts In addition to those from the parent class,
19 * - log: (bool) If true, write log data to stderr.
20 * - apiEndpoint: (string) URL for api.php. Required.
21 * - title: (string) Page being parsed. Required.
22 * - apiTimeout: (int) Timeout, in sections. Default 60.
23 * - userAgent: (string) User agent prefix.
24 */
25 public function __construct( array $opts ) {
26 $api = new ApiHelper( $opts );
27
28 $siteConfig = new SiteConfig( $api, $opts );
29 $pageConfig = new PageConfig( $api, $siteConfig, $opts );
30 $dataAccess = new DataAccess( $api, $siteConfig, $opts );
31 $metadata = new StubMetadataCollector( $siteConfig );
32 parent::__construct( $siteConfig, $pageConfig, $dataAccess, $metadata, $opts );
33 }
34
35 // Narrow inherited type; see
36 // https://wiki.php.net/rfc/covariant-returns-and-contravariant-parameters
37
38 /** @return SiteConfig */
39 public function getSiteConfig(): \Wikimedia\Parsoid\Config\SiteConfig {
40 // @phan-suppress-next-line PhanTypeMismatchReturnSuperType
41 return parent::getSiteConfig();
42 }
43 }