Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
28.57% |
4 / 14 |
|
23.08% |
3 / 13 |
CRAP | |
0.00% |
0 / 1 |
| DerivativeRequest | |
28.57% |
4 / 14 |
|
23.08% |
3 / 13 |
85.43 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getCookie | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getHeader | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAllHeaders | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSession | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getSessionData | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setSessionData | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAcceptLang | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getIP | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| setIP | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getProtocol | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getUpload | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getElapsedTime | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Deal with importing all those nasty globals and things |
| 4 | * |
| 5 | * Copyright © 2003 Brooke Vibber <bvibber@wikimedia.org> |
| 6 | * https://www.mediawiki.org/ |
| 7 | * |
| 8 | * @license GPL-2.0-or-later |
| 9 | * @file |
| 10 | */ |
| 11 | |
| 12 | namespace MediaWiki\Request; |
| 13 | |
| 14 | use MediaWiki\Session\Session; |
| 15 | |
| 16 | /** |
| 17 | * Similar to MediaWiki\Request\FauxRequest, but only fakes URL parameters and method |
| 18 | * (POST or GET) and use the base request for the remaining stuff |
| 19 | * (cookies, session and headers). |
| 20 | * |
| 21 | * @newable |
| 22 | * |
| 23 | * @ingroup HTTP |
| 24 | * @since 1.19 |
| 25 | */ |
| 26 | class DerivativeRequest extends FauxRequest { |
| 27 | private WebRequest $base; |
| 28 | /** @var string|null */ |
| 29 | private $ip; |
| 30 | |
| 31 | /** |
| 32 | * @stable to call |
| 33 | * |
| 34 | * @param WebRequest $base |
| 35 | * @param array $data Array of *non*-urlencoded key => value pairs, the |
| 36 | * fake GET/POST values |
| 37 | * @param bool $wasPosted Whether to treat the data as POST |
| 38 | */ |
| 39 | public function __construct( WebRequest $base, $data, $wasPosted = false ) { |
| 40 | $this->base = $base; |
| 41 | parent::__construct( $data, $wasPosted ); |
| 42 | } |
| 43 | |
| 44 | /** @inheritDoc */ |
| 45 | public function getCookie( $key, $prefix = null, $default = null ) { |
| 46 | return $this->base->getCookie( $key, $prefix, $default ); |
| 47 | } |
| 48 | |
| 49 | /** @inheritDoc */ |
| 50 | public function getHeader( $name, $flags = 0 ) { |
| 51 | return $this->base->getHeader( $name, $flags ); |
| 52 | } |
| 53 | |
| 54 | /** @inheritDoc */ |
| 55 | public function getAllHeaders() { |
| 56 | return $this->base->getAllHeaders(); |
| 57 | } |
| 58 | |
| 59 | /** @inheritDoc */ |
| 60 | public function getSession(): Session { |
| 61 | return $this->base->getSession(); |
| 62 | } |
| 63 | |
| 64 | /** @inheritDoc */ |
| 65 | public function getSessionData( $key ) { |
| 66 | return $this->base->getSessionData( $key ); |
| 67 | } |
| 68 | |
| 69 | /** @inheritDoc */ |
| 70 | public function setSessionData( $key, $data ) { |
| 71 | $this->base->setSessionData( $key, $data ); |
| 72 | } |
| 73 | |
| 74 | /** @inheritDoc */ |
| 75 | public function getAcceptLang() { |
| 76 | return $this->base->getAcceptLang(); |
| 77 | } |
| 78 | |
| 79 | /** @inheritDoc */ |
| 80 | public function getIP(): string { |
| 81 | return $this->ip ?: $this->base->getIP(); |
| 82 | } |
| 83 | |
| 84 | /** @inheritDoc */ |
| 85 | public function setIP( $ip ) { |
| 86 | $this->ip = $ip; |
| 87 | } |
| 88 | |
| 89 | /** @inheritDoc */ |
| 90 | public function getProtocol() { |
| 91 | return $this->base->getProtocol(); |
| 92 | } |
| 93 | |
| 94 | /** @inheritDoc */ |
| 95 | public function getUpload( $key ) { |
| 96 | // @phan-suppress-next-line PhanTypeMismatchReturnSuperType |
| 97 | return $this->base->getUpload( $key ); |
| 98 | } |
| 99 | |
| 100 | /** @inheritDoc */ |
| 101 | public function getElapsedTime() { |
| 102 | return $this->base->getElapsedTime(); |
| 103 | } |
| 104 | } |