Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like WebRequest often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use WebRequest, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 35 | class WebRequest { |
||
| 36 | protected $data, $headers = []; |
||
|
|
|||
| 37 | |||
| 38 | /** |
||
| 39 | * Flag to make WebRequest::getHeader return an array of values. |
||
| 40 | * @since 1.26 |
||
| 41 | */ |
||
| 42 | const GETHEADER_LIST = 1; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Lazy-init response object |
||
| 46 | * @var WebResponse |
||
| 47 | */ |
||
| 48 | private $response; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Cached client IP address |
||
| 52 | * @var string |
||
| 53 | */ |
||
| 54 | private $ip; |
||
| 55 | |||
| 56 | /** |
||
| 57 | * The timestamp of the start of the request, with microsecond precision. |
||
| 58 | * @var float |
||
| 59 | */ |
||
| 60 | protected $requestTime; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Cached URL protocol |
||
| 64 | * @var string |
||
| 65 | */ |
||
| 66 | protected $protocol; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @var \\MediaWiki\\Session\\SessionId|null Session ID to use for this |
||
| 70 | * request. We can't save the session directly due to reference cycles not |
||
| 71 | * working too well (slow GC in Zend and never collected in HHVM). |
||
| 72 | */ |
||
| 73 | protected $sessionId = null; |
||
| 74 | |||
| 75 | public function __construct() { |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Extract relevant query arguments from the http request uri's path |
||
| 86 | * to be merged with the normal php provided query arguments. |
||
| 87 | * Tries to use the REQUEST_URI data if available and parses it |
||
| 88 | * according to the wiki's configuration looking for any known pattern. |
||
| 89 | * |
||
| 90 | * If the REQUEST_URI is not provided we'll fall back on the PATH_INFO |
||
| 91 | * provided by the server if any and use that to set a 'title' parameter. |
||
| 92 | * |
||
| 93 | * @param string $want If this is not 'all', then the function |
||
| 94 | * will return an empty array if it determines that the URL is |
||
| 95 | * inside a rewrite path. |
||
| 96 | * |
||
| 97 | * @return array Any query arguments found in path matches. |
||
| 98 | */ |
||
| 99 | public static function getPathInfo( $want = 'all' ) { |
||
| 175 | |||
| 176 | /** |
||
| 177 | * Work out an appropriate URL prefix containing scheme and host, based on |
||
| 178 | * information detected from $_SERVER |
||
| 179 | * |
||
| 180 | * @return string |
||
| 181 | */ |
||
| 182 | public static function detectServer() { |
||
| 220 | |||
| 221 | /** |
||
| 222 | * Detect the protocol from $_SERVER. |
||
| 223 | * This is for use prior to Setup.php, when no WebRequest object is available. |
||
| 224 | * At other times, use the non-static function getProtocol(). |
||
| 225 | * |
||
| 226 | * @return array |
||
| 227 | */ |
||
| 228 | public static function detectProtocol() { |
||
| 237 | |||
| 238 | /** |
||
| 239 | * Get the number of seconds to have elapsed since request start, |
||
| 240 | * in fractional seconds, with microsecond resolution. |
||
| 241 | * |
||
| 242 | * @return float |
||
| 243 | * @since 1.25 |
||
| 244 | */ |
||
| 245 | public function getElapsedTime() { |
||
| 248 | |||
| 249 | /** |
||
| 250 | * Get the unique request ID. |
||
| 251 | * This is either the value of the UNIQUE_ID envvar (if present) or a |
||
| 252 | * randomly-generated 24-character string. |
||
| 253 | * |
||
| 254 | * @return string |
||
| 255 | * @since 1.27 |
||
| 256 | */ |
||
| 257 | public static function getRequestId() { |
||
| 267 | |||
| 268 | /** |
||
| 269 | * Get the current URL protocol (http or https) |
||
| 270 | * @return string |
||
| 271 | */ |
||
| 272 | public function getProtocol() { |
||
| 278 | |||
| 279 | /** |
||
| 280 | * Check for title, action, and/or variant data in the URL |
||
| 281 | * and interpolate it into the GET variables. |
||
| 282 | * This should only be run after $wgContLang is available, |
||
| 283 | * as we may need the list of language variants to determine |
||
| 284 | * available variant URLs. |
||
| 285 | */ |
||
| 286 | public function interpolateTitle() { |
||
| 297 | |||
| 298 | /** |
||
| 299 | * URL rewriting function; tries to extract page title and, |
||
| 300 | * optionally, one other fixed parameter value from a URL path. |
||
| 301 | * |
||
| 302 | * @param string $path The URL path given from the client |
||
| 303 | * @param array $bases One or more URLs, optionally with $1 at the end |
||
| 304 | * @param string $key If provided, the matching key in $bases will be |
||
| 305 | * passed on as the value of this URL parameter |
||
| 306 | * @return array Array of URL variables to interpolate; empty if no match |
||
| 307 | */ |
||
| 308 | static function extractTitle( $path, $bases, $key = false ) { |
||
| 326 | |||
| 327 | /** |
||
| 328 | * Recursively normalizes UTF-8 strings in the given array. |
||
| 329 | * |
||
| 330 | * @param string|array $data |
||
| 331 | * @return array|string Cleaned-up version of the given |
||
| 332 | * @private |
||
| 333 | */ |
||
| 334 | function normalizeUnicode( $data ) { |
||
| 347 | |||
| 348 | /** |
||
| 349 | * Fetch a value from the given array or return $default if it's not set. |
||
| 350 | * |
||
| 351 | * @param array $arr |
||
| 352 | * @param string $name |
||
| 353 | * @param mixed $default |
||
| 354 | * @return mixed |
||
| 355 | */ |
||
| 356 | private function getGPCVal( $arr, $name, $default ) { |
||
| 376 | |||
| 377 | /** |
||
| 378 | * Fetch a scalar from the input or return $default if it's not set. |
||
| 379 | * Returns a string. Arrays are discarded. Useful for |
||
| 380 | * non-freeform text inputs (e.g. predefined internal text keys |
||
| 381 | * selected by a drop-down menu). For freeform input, see getText(). |
||
| 382 | * |
||
| 383 | * @param string $name |
||
| 384 | * @param string $default Optional default (or null) |
||
| 385 | * @return string |
||
| 386 | */ |
||
| 387 | public function getVal( $name, $default = null ) { |
||
| 398 | |||
| 399 | /** |
||
| 400 | * Set an arbitrary value into our get/post data. |
||
| 401 | * |
||
| 402 | * @param string $key Key name to use |
||
| 403 | * @param mixed $value Value to set |
||
| 404 | * @return mixed Old value if one was present, null otherwise |
||
| 405 | */ |
||
| 406 | public function setVal( $key, $value ) { |
||
| 411 | |||
| 412 | /** |
||
| 413 | * Unset an arbitrary value from our get/post data. |
||
| 414 | * |
||
| 415 | * @param string $key Key name to use |
||
| 416 | * @return mixed Old value if one was present, null otherwise |
||
| 417 | */ |
||
| 418 | public function unsetVal( $key ) { |
||
| 427 | |||
| 428 | /** |
||
| 429 | * Fetch an array from the input or return $default if it's not set. |
||
| 430 | * If source was scalar, will return an array with a single element. |
||
| 431 | * If no source and no default, returns null. |
||
| 432 | * |
||
| 433 | * @param string $name |
||
| 434 | * @param array $default Optional default (or null) |
||
| 435 | * @return array |
||
| 436 | */ |
||
| 437 | public function getArray( $name, $default = null ) { |
||
| 445 | |||
| 446 | /** |
||
| 447 | * Fetch an array of integers, or return $default if it's not set. |
||
| 448 | * If source was scalar, will return an array with a single element. |
||
| 449 | * If no source and no default, returns null. |
||
| 450 | * If an array is returned, contents are guaranteed to be integers. |
||
| 451 | * |
||
| 452 | * @param string $name |
||
| 453 | * @param array $default Option default (or null) |
||
| 454 | * @return array Array of ints |
||
| 455 | */ |
||
| 456 | public function getIntArray( $name, $default = null ) { |
||
| 463 | |||
| 464 | /** |
||
| 465 | * Fetch an integer value from the input or return $default if not set. |
||
| 466 | * Guaranteed to return an integer; non-numeric input will typically |
||
| 467 | * return 0. |
||
| 468 | * |
||
| 469 | * @param string $name |
||
| 470 | * @param int $default |
||
| 471 | * @return int |
||
| 472 | */ |
||
| 473 | public function getInt( $name, $default = 0 ) { |
||
| 476 | |||
| 477 | /** |
||
| 478 | * Fetch an integer value from the input or return null if empty. |
||
| 479 | * Guaranteed to return an integer or null; non-numeric input will |
||
| 480 | * typically return null. |
||
| 481 | * |
||
| 482 | * @param string $name |
||
| 483 | * @return int|null |
||
| 484 | */ |
||
| 485 | public function getIntOrNull( $name ) { |
||
| 491 | |||
| 492 | /** |
||
| 493 | * Fetch a floating point value from the input or return $default if not set. |
||
| 494 | * Guaranteed to return a float; non-numeric input will typically |
||
| 495 | * return 0. |
||
| 496 | * |
||
| 497 | * @since 1.23 |
||
| 498 | * @param string $name |
||
| 499 | * @param float $default |
||
| 500 | * @return float |
||
| 501 | */ |
||
| 502 | public function getFloat( $name, $default = 0.0 ) { |
||
| 505 | |||
| 506 | /** |
||
| 507 | * Fetch a boolean value from the input or return $default if not set. |
||
| 508 | * Guaranteed to return true or false, with normal PHP semantics for |
||
| 509 | * boolean interpretation of strings. |
||
| 510 | * |
||
| 511 | * @param string $name |
||
| 512 | * @param bool $default |
||
| 513 | * @return bool |
||
| 514 | */ |
||
| 515 | public function getBool( $name, $default = false ) { |
||
| 518 | |||
| 519 | /** |
||
| 520 | * Fetch a boolean value from the input or return $default if not set. |
||
| 521 | * Unlike getBool, the string "false" will result in boolean false, which is |
||
| 522 | * useful when interpreting information sent from JavaScript. |
||
| 523 | * |
||
| 524 | * @param string $name |
||
| 525 | * @param bool $default |
||
| 526 | * @return bool |
||
| 527 | */ |
||
| 528 | public function getFuzzyBool( $name, $default = false ) { |
||
| 531 | |||
| 532 | /** |
||
| 533 | * Return true if the named value is set in the input, whatever that |
||
| 534 | * value is (even "0"). Return false if the named value is not set. |
||
| 535 | * Example use is checking for the presence of check boxes in forms. |
||
| 536 | * |
||
| 537 | * @param string $name |
||
| 538 | * @return bool |
||
| 539 | */ |
||
| 540 | public function getCheck( $name ) { |
||
| 545 | |||
| 546 | /** |
||
| 547 | * Fetch a text string from the given array or return $default if it's not |
||
| 548 | * set. Carriage returns are stripped from the text, and with some language |
||
| 549 | * modules there is an input transliteration applied. This should generally |
||
| 550 | * be used for form "<textarea>" and "<input>" fields. Used for |
||
| 551 | * user-supplied freeform text input (for which input transformations may |
||
| 552 | * be required - e.g. Esperanto x-coding). |
||
| 553 | * |
||
| 554 | * @param string $name |
||
| 555 | * @param string $default Optional |
||
| 556 | * @return string |
||
| 557 | */ |
||
| 558 | public function getText( $name, $default = '' ) { |
||
| 564 | |||
| 565 | /** |
||
| 566 | * Extracts the given named values into an array. |
||
| 567 | * If no arguments are given, returns all input values. |
||
| 568 | * No transformation is performed on the values. |
||
| 569 | * |
||
| 570 | * @return array |
||
| 571 | */ |
||
| 572 | public function getValues() { |
||
| 587 | |||
| 588 | /** |
||
| 589 | * Returns the names of all input values excluding those in $exclude. |
||
| 590 | * |
||
| 591 | * @param array $exclude |
||
| 592 | * @return array |
||
| 593 | */ |
||
| 594 | public function getValueNames( $exclude = [] ) { |
||
| 597 | |||
| 598 | /** |
||
| 599 | * Get the values passed in the query string. |
||
| 600 | * No transformation is performed on the values. |
||
| 601 | * |
||
| 602 | * @return array |
||
| 603 | */ |
||
| 604 | public function getQueryValues() { |
||
| 607 | |||
| 608 | /** |
||
| 609 | * Return the contents of the Query with no decoding. Use when you need to |
||
| 610 | * know exactly what was sent, e.g. for an OAuth signature over the elements. |
||
| 611 | * |
||
| 612 | * @return string |
||
| 613 | */ |
||
| 614 | public function getRawQueryString() { |
||
| 617 | |||
| 618 | /** |
||
| 619 | * Return the contents of the POST with no decoding. Use when you need to |
||
| 620 | * know exactly what was sent, e.g. for an OAuth signature over the elements. |
||
| 621 | * |
||
| 622 | * @return string |
||
| 623 | */ |
||
| 624 | public function getRawPostString() { |
||
| 630 | |||
| 631 | /** |
||
| 632 | * Return the raw request body, with no processing. Cached since some methods |
||
| 633 | * disallow reading the stream more than once. As stated in the php docs, this |
||
| 634 | * does not work with enctype="multipart/form-data". |
||
| 635 | * |
||
| 636 | * @return string |
||
| 637 | */ |
||
| 638 | public function getRawInput() { |
||
| 645 | |||
| 646 | /** |
||
| 647 | * Get the HTTP method used for this request. |
||
| 648 | * |
||
| 649 | * @return string |
||
| 650 | */ |
||
| 651 | public function getMethod() { |
||
| 654 | |||
| 655 | /** |
||
| 656 | * Returns true if the present request was reached by a POST operation, |
||
| 657 | * false otherwise (GET, HEAD, or command-line). |
||
| 658 | * |
||
| 659 | * Note that values retrieved by the object may come from the |
||
| 660 | * GET URL etc even on a POST request. |
||
| 661 | * |
||
| 662 | * @return bool |
||
| 663 | */ |
||
| 664 | public function wasPosted() { |
||
| 667 | |||
| 668 | /** |
||
| 669 | * Return the session for this request |
||
| 670 | * @since 1.27 |
||
| 671 | * @note For performance, keep the session locally if you will be making |
||
| 672 | * much use of it instead of calling this method repeatedly. |
||
| 673 | * @return MediaWiki\\Session\\Session |
||
| 674 | */ |
||
| 675 | public function getSession() { |
||
| 687 | |||
| 688 | /** |
||
| 689 | * Set the session for this request |
||
| 690 | * @since 1.27 |
||
| 691 | * @private For use by MediaWiki\\Session classes only |
||
| 692 | * @param MediaWiki\\Session\\SessionId $sessionId |
||
| 693 | */ |
||
| 694 | public function setSessionId( MediaWiki\Session\SessionId $sessionId ) { |
||
| 697 | |||
| 698 | /** |
||
| 699 | * Get the session id for this request, if any |
||
| 700 | * @since 1.27 |
||
| 701 | * @private For use by MediaWiki\\Session classes only |
||
| 702 | * @return MediaWiki\\Session\\SessionId|null |
||
| 703 | */ |
||
| 704 | public function getSessionId() { |
||
| 707 | |||
| 708 | /** |
||
| 709 | * Returns true if the request has a persistent session. |
||
| 710 | * This does not necessarily mean that the user is logged in! |
||
| 711 | * |
||
| 712 | * @deprecated since 1.27, use |
||
| 713 | * \\MediaWiki\\Session\\SessionManager::singleton()->getPersistedSessionId() |
||
| 714 | * instead. |
||
| 715 | * @return bool |
||
| 716 | */ |
||
| 717 | public function checkSessionCookie() { |
||
| 723 | |||
| 724 | /** |
||
| 725 | * Get a cookie from the $_COOKIE jar |
||
| 726 | * |
||
| 727 | * @param string $key The name of the cookie |
||
| 728 | * @param string $prefix A prefix to use for the cookie name, if not $wgCookiePrefix |
||
| 729 | * @param mixed $default What to return if the value isn't found |
||
| 730 | * @return mixed Cookie value or $default if the cookie not set |
||
| 731 | */ |
||
| 732 | public function getCookie( $key, $prefix = null, $default = null ) { |
||
| 739 | |||
| 740 | /** |
||
| 741 | * Return the path and query string portion of the main request URI. |
||
| 742 | * This will be suitable for use as a relative link in HTML output. |
||
| 743 | * |
||
| 744 | * @throws MWException |
||
| 745 | * @return string |
||
| 746 | */ |
||
| 747 | public static function getGlobalRequestURL() { |
||
| 783 | |||
| 784 | /** |
||
| 785 | * Return the path and query string portion of the request URI. |
||
| 786 | * This will be suitable for use as a relative link in HTML output. |
||
| 787 | * |
||
| 788 | * @throws MWException |
||
| 789 | * @return string |
||
| 790 | */ |
||
| 791 | public function getRequestURL() { |
||
| 794 | |||
| 795 | /** |
||
| 796 | * Return the request URI with the canonical service and hostname, path, |
||
| 797 | * and query string. This will be suitable for use as an absolute link |
||
| 798 | * in HTML or other output. |
||
| 799 | * |
||
| 800 | * If $wgServer is protocol-relative, this will return a fully |
||
| 801 | * qualified URL with the protocol that was used for this request. |
||
| 802 | * |
||
| 803 | * @return string |
||
| 804 | */ |
||
| 805 | public function getFullRequestURL() { |
||
| 808 | |||
| 809 | /** |
||
| 810 | * @param string $key |
||
| 811 | * @param string $value |
||
| 812 | * @return string |
||
| 813 | */ |
||
| 814 | public function appendQueryValue( $key, $value ) { |
||
| 817 | |||
| 818 | /** |
||
| 819 | * Appends or replaces value of query variables. |
||
| 820 | * |
||
| 821 | * @param array $array Array of values to replace/add to query |
||
| 822 | * @return string |
||
| 823 | */ |
||
| 824 | public function appendQueryArray( $array ) { |
||
| 831 | |||
| 832 | /** |
||
| 833 | * Check for limit and offset parameters on the input, and return sensible |
||
| 834 | * defaults if not given. The limit must be positive and is capped at 5000. |
||
| 835 | * Offset must be positive but is not capped. |
||
| 836 | * |
||
| 837 | * @param int $deflimit Limit to use if no input and the user hasn't set the option. |
||
| 838 | * @param string $optionname To specify an option other than rclimit to pull from. |
||
| 839 | * @return int[] First element is limit, second is offset |
||
| 840 | */ |
||
| 841 | public function getLimitOffset( $deflimit = 50, $optionname = 'rclimit' ) { |
||
| 865 | |||
| 866 | /** |
||
| 867 | * Return the path to the temporary file where PHP has stored the upload. |
||
| 868 | * |
||
| 869 | * @param string $key |
||
| 870 | * @return string|null String or null if no such file. |
||
| 871 | */ |
||
| 872 | public function getFileTempname( $key ) { |
||
| 876 | |||
| 877 | /** |
||
| 878 | * Return the upload error or 0 |
||
| 879 | * |
||
| 880 | * @param string $key |
||
| 881 | * @return int |
||
| 882 | */ |
||
| 883 | public function getUploadError( $key ) { |
||
| 887 | |||
| 888 | /** |
||
| 889 | * Return the original filename of the uploaded file, as reported by |
||
| 890 | * the submitting user agent. HTML-style character entities are |
||
| 891 | * interpreted and normalized to Unicode normalization form C, in part |
||
| 892 | * to deal with weird input from Safari with non-ASCII filenames. |
||
| 893 | * |
||
| 894 | * Other than this the name is not verified for being a safe filename. |
||
| 895 | * |
||
| 896 | * @param string $key |
||
| 897 | * @return string|null String or null if no such file. |
||
| 898 | */ |
||
| 899 | public function getFileName( $key ) { |
||
| 903 | |||
| 904 | /** |
||
| 905 | * Return a WebRequestUpload object corresponding to the key |
||
| 906 | * |
||
| 907 | * @param string $key |
||
| 908 | * @return WebRequestUpload |
||
| 909 | */ |
||
| 910 | public function getUpload( $key ) { |
||
| 913 | |||
| 914 | /** |
||
| 915 | * Return a handle to WebResponse style object, for setting cookies, |
||
| 916 | * headers and other stuff, for Request being worked on. |
||
| 917 | * |
||
| 918 | * @return WebResponse |
||
| 919 | */ |
||
| 920 | public function response() { |
||
| 928 | |||
| 929 | /** |
||
| 930 | * Initialise the header list |
||
| 931 | */ |
||
| 932 | protected function initHeaders() { |
||
| 953 | |||
| 954 | /** |
||
| 955 | * Get an array containing all request headers |
||
| 956 | * |
||
| 957 | * @return array Mapping header name to its value |
||
| 958 | */ |
||
| 959 | public function getAllHeaders() { |
||
| 963 | |||
| 964 | /** |
||
| 965 | * Get a request header, or false if it isn't set. |
||
| 966 | * |
||
| 967 | * @param string $name Case-insensitive header name |
||
| 968 | * @param int $flags Bitwise combination of: |
||
| 969 | * WebRequest::GETHEADER_LIST Treat the header as a comma-separated list |
||
| 970 | * of values, as described in RFC 2616 § 4.2. |
||
| 971 | * (since 1.26). |
||
| 972 | * @return string|array|bool False if header is unset; otherwise the |
||
| 973 | * header value(s) as either a string (the default) or an array, if |
||
| 974 | * WebRequest::GETHEADER_LIST flag was set. |
||
| 975 | */ |
||
| 976 | public function getHeader( $name, $flags = 0 ) { |
||
| 988 | |||
| 989 | /** |
||
| 990 | * Get data from the session |
||
| 991 | * |
||
| 992 | * @note Prefer $this->getSession() instead if making multiple calls. |
||
| 993 | * @param string $key Name of key in the session |
||
| 994 | * @return mixed |
||
| 995 | */ |
||
| 996 | public function getSessionData( $key ) { |
||
| 999 | |||
| 1000 | /** |
||
| 1001 | * Set session data |
||
| 1002 | * |
||
| 1003 | * @note Prefer $this->getSession() instead if making multiple calls. |
||
| 1004 | * @param string $key Name of key in the session |
||
| 1005 | * @param mixed $data |
||
| 1006 | */ |
||
| 1007 | public function setSessionData( $key, $data ) { |
||
| 1010 | |||
| 1011 | /** |
||
| 1012 | * Check if Internet Explorer will detect an incorrect cache extension in |
||
| 1013 | * PATH_INFO or QUERY_STRING. If the request can't be allowed, show an error |
||
| 1014 | * message or redirect to a safer URL. Returns true if the URL is OK, and |
||
| 1015 | * false if an error message has been shown and the request should be aborted. |
||
| 1016 | * |
||
| 1017 | * @param array $extWhitelist |
||
| 1018 | * @throws HttpError |
||
| 1019 | * @return bool |
||
| 1020 | */ |
||
| 1021 | public function checkUrlExtension( $extWhitelist = [] ) { |
||
| 1037 | |||
| 1038 | /** |
||
| 1039 | * Attempt to redirect to a URL with a QUERY_STRING that's not dangerous in |
||
| 1040 | * IE 6. Returns true if it was successful, false otherwise. |
||
| 1041 | * |
||
| 1042 | * @param string $url |
||
| 1043 | * @return bool |
||
| 1044 | */ |
||
| 1045 | protected function doSecurityRedirect( $url ) { |
||
| 1070 | |||
| 1071 | /** |
||
| 1072 | * Parse the Accept-Language header sent by the client into an array |
||
| 1073 | * |
||
| 1074 | * @return array Array( languageCode => q-value ) sorted by q-value in |
||
| 1075 | * descending order then appearing time in the header in ascending order. |
||
| 1076 | * May contain the "language" '*', which applies to languages other than those explicitly listed. |
||
| 1077 | * This is aligned with rfc2616 section 14.4 |
||
| 1078 | * Preference for earlier languages appears in rfc3282 as an extension to HTTP/1.1. |
||
| 1079 | */ |
||
| 1080 | public function getAcceptLang() { |
||
| 1124 | |||
| 1125 | /** |
||
| 1126 | * Fetch the raw IP from the request |
||
| 1127 | * |
||
| 1128 | * @since 1.19 |
||
| 1129 | * |
||
| 1130 | * @throws MWException |
||
| 1131 | * @return string |
||
| 1132 | */ |
||
| 1133 | protected function getRawIP() { |
||
| 1147 | |||
| 1148 | /** |
||
| 1149 | * Work out the IP address based on various globals |
||
| 1150 | * For trusted proxies, use the XFF client IP (first of the chain) |
||
| 1151 | * |
||
| 1152 | * @since 1.19 |
||
| 1153 | * |
||
| 1154 | * @throws MWException |
||
| 1155 | * @return string |
||
| 1156 | */ |
||
| 1157 | public function getIP() { |
||
| 1222 | |||
| 1223 | /** |
||
| 1224 | * @param string $ip |
||
| 1225 | * @return void |
||
| 1226 | * @since 1.21 |
||
| 1227 | */ |
||
| 1228 | public function setIP( $ip ) { |
||
| 1231 | } |
||
| 1232 |
Only declaring a single property per statement allows you to later on add doc comments more easily.
It is also recommended by PSR2, so it is a common style that many people expect.