* @ingroup HTTP
*/
class WebRequest {
- protected $data, $headers = array();
+ protected $data, $headers = [];
/**
* Flag to make WebRequest::getHeader return an array of values.
// PATH_INFO is mangled due to http://bugs.php.net/bug.php?id=31892
// And also by Apache 2.x, double slashes are converted to single slashes.
// So we will use REQUEST_URI if possible.
- $matches = array();
+ $matches = [];
if ( !empty( $_SERVER['REQUEST_URI'] ) ) {
// Slurp out the path portion to examine...
$url = $_SERVER['REQUEST_URI'];
global $wgActionPaths;
if ( $wgActionPaths ) {
- $router->add( $wgActionPaths, array( 'action' => '$key' ) );
+ $router->add( $wgActionPaths, [ 'action' => '$key' ] );
}
global $wgVariantArticlePath, $wgContLang;
if ( $wgVariantArticlePath ) {
$router->add( $wgVariantArticlePath,
- array( 'variant' => '$2' ),
- array( '$2' => $wgContLang->getVariants() )
+ [ 'variant' => '$2' ],
+ [ '$2' => $wgContLang->getVariants() ]
);
}
- Hooks::run( 'WebRequestPathInfoRouter', array( $router ) );
+ Hooks::run( 'WebRequestPathInfoRouter', [ $router ] );
$matches = $router->parse( $path );
}
$proto = self::detectProtocol();
$stdPort = $proto === 'https' ? 443 : 80;
- $varNames = array( 'HTTP_HOST', 'SERVER_NAME', 'HOSTNAME', 'SERVER_ADDR' );
+ $varNames = [ 'HTTP_HOST', 'SERVER_NAME', 'HOSTNAME', 'SERVER_ADDR' ];
$host = 'localhost';
$port = $stdPort;
foreach ( $varNames as $varName ) {
if ( substr( $path, 0, $baseLen ) == $base ) {
$raw = substr( $path, $baseLen );
if ( $raw !== '' ) {
- $matches = array( 'title' => rawurldecode( $raw ) );
+ $matches = [ 'title' => rawurldecode( $raw ) ];
if ( $key ) {
$matches[$key] = $keyValue;
}
}
}
}
- return array();
+ return [];
}
/**
$names = array_keys( $this->data );
}
- $retVal = array();
+ $retVal = [];
foreach ( $names as $name ) {
$value = $this->getGPCVal( $this->data, $name, null );
if ( !is_null( $value ) ) {
* @param array $exclude
* @return array
*/
- public function getValueNames( $exclude = array() ) {
+ public function getValueNames( $exclude = [] ) {
return array_diff( array_keys( $this->getValues() ), $exclude );
}
* @return string
*/
public function appendQueryValue( $key, $value ) {
- return $this->appendQueryArray( array( $key => $value ) );
+ return $this->appendQueryArray( [ $key => $value ] );
}
/**
$offset = 0;
}
- return array( $limit, $offset );
+ return [ $limit, $offset ];
}
/**
* @throws HttpError
* @return bool
*/
- public function checkUrlExtension( $extWhitelist = array() ) {
+ public function checkUrlExtension( $extWhitelist = [] ) {
$extWhitelist[] = 'php';
if ( IEUrlExtension::areServerVarsBad( $_SERVER, $extWhitelist ) ) {
if ( !$this->wasPosted() ) {
// http://www.thefutureoftheweb.com/blog/use-accept-language-header
$acceptLang = $this->getHeader( 'Accept-Language' );
if ( !$acceptLang ) {
- return array();
+ return [];
}
// Return the language codes in lower case
);
if ( !count( $lang_parse[1] ) ) {
- return array();
+ return [];
}
$langcodes = $lang_parse[1];
}
# Allow extensions to improve our guess
- Hooks::run( 'GetIP', array( &$ip ) );
+ Hooks::run( 'GetIP', [ &$ip ] );
if ( !$ip ) {
throw new MWException( "Unable to determine IP." );