Merge "resourceloader: Fix nullable documentation for property and return types"
This commit is contained in:
commit
b1a55d5b62
5 changed files with 36 additions and 8 deletions
|
|
@ -38,17 +38,27 @@ class DerivativeResourceLoaderContext extends ResourceLoaderContext {
|
|||
*/
|
||||
private $context;
|
||||
|
||||
/** @var int|array */
|
||||
/** @var int|string[] */
|
||||
protected $modules = self::INHERIT_VALUE;
|
||||
/** @var int|string */
|
||||
protected $language = self::INHERIT_VALUE;
|
||||
/** @var int|string|null */
|
||||
protected $direction = self::INHERIT_VALUE;
|
||||
/** @var int|string */
|
||||
protected $skin = self::INHERIT_VALUE;
|
||||
/** @var int|string|null */
|
||||
protected $user = self::INHERIT_VALUE;
|
||||
/** @var int|User|null */
|
||||
protected $userObj = self::INHERIT_VALUE;
|
||||
/** @var int */
|
||||
protected $debug = self::INHERIT_VALUE;
|
||||
/** @var int|string|null */
|
||||
protected $only = self::INHERIT_VALUE;
|
||||
/** @var int|string|null */
|
||||
protected $version = self::INHERIT_VALUE;
|
||||
/** @var int|bool */
|
||||
protected $raw = self::INHERIT_VALUE;
|
||||
/** @var int|callable|null */
|
||||
protected $contentOverrideCallback = self::INHERIT_VALUE;
|
||||
|
||||
public function __construct( ResourceLoaderContext $context ) {
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Page\PageReferenceValue;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Context object that contains information about the state of a specific
|
||||
|
|
@ -41,28 +42,44 @@ class ResourceLoaderContext implements MessageLocalizer {
|
|||
public const DEBUG_LEGACY = 1;
|
||||
private const DEBUG_MAIN = 2;
|
||||
|
||||
/** @var ResourceLoader */
|
||||
protected $resourceLoader;
|
||||
/** @var WebRequest */
|
||||
protected $request;
|
||||
/** @var LoggerInterface */
|
||||
protected $logger;
|
||||
|
||||
// Module content vary
|
||||
/** @var string */
|
||||
protected $skin;
|
||||
/** @var string */
|
||||
protected $language;
|
||||
/** @var int */
|
||||
protected $debug;
|
||||
/** @var string|null */
|
||||
protected $user;
|
||||
|
||||
// Request vary (in addition to cache vary)
|
||||
/** @var string[] */
|
||||
protected $modules;
|
||||
/** @var string|null */
|
||||
protected $only;
|
||||
/** @var string|null */
|
||||
protected $version;
|
||||
/** @var bool */
|
||||
protected $raw;
|
||||
/** @var string|null */
|
||||
protected $image;
|
||||
/** @var string|null */
|
||||
protected $variant;
|
||||
/** @var string|null */
|
||||
protected $format;
|
||||
|
||||
/** @var string|null */
|
||||
protected $direction;
|
||||
/** @var string|null */
|
||||
protected $hash;
|
||||
/** @var User|null */
|
||||
protected $userObj;
|
||||
/** @var ResourceLoaderImage|false */
|
||||
protected $imageObj;
|
||||
|
|
@ -170,7 +187,7 @@ class ResourceLoaderContext implements MessageLocalizer {
|
|||
* @deprecated since 1.34 Use ResourceLoaderModule::getLogger instead
|
||||
* inside module methods. Use ResourceLoader::getLogger elsewhere.
|
||||
* @since 1.27
|
||||
* @return \Psr\Log\LoggerInterface
|
||||
* @return LoggerInterface
|
||||
*/
|
||||
public function getLogger() {
|
||||
return $this->logger;
|
||||
|
|
@ -185,6 +202,7 @@ class ResourceLoaderContext implements MessageLocalizer {
|
|||
// Must be a valid language code after this point (T64849)
|
||||
// Only support uselang values that follow built-in conventions (T102058)
|
||||
$lang = $this->getRequest()->getRawVal( 'lang', '' );
|
||||
'@phan-var string $lang'; // getRawVal does not return null here
|
||||
// Stricter version of RequestContext::sanitizeLangCode()
|
||||
$validBuiltinCode = MediaWikiServices::getInstance()->getLanguageNameUtils()
|
||||
->isValidBuiltInCode( $lang );
|
||||
|
|
|
|||
|
|
@ -1218,7 +1218,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
|
|||
*
|
||||
* @param ResourceLoaderContext $context
|
||||
* @return array|null
|
||||
* @phan-return array{main:string,files:string[][]}|null
|
||||
* @phan-return array{main:?string,files:array[]}|null
|
||||
* @throws LogicException If the 'packageFiles' definition is invalid.
|
||||
*/
|
||||
private function expandPackageFiles( ResourceLoaderContext $context ) {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ class ResourceLoaderImage {
|
|||
/**
|
||||
* Get the extension of the image.
|
||||
*
|
||||
* @param string $format Format to get the extension for, 'original' or 'rasterized'
|
||||
* @param string|null $format Format to get the extension for, 'original' or 'rasterized'
|
||||
* @return string Extension without leading dot, e.g. 'png'
|
||||
*/
|
||||
public function getExtension( $format = 'original' ) {
|
||||
|
|
@ -216,7 +216,7 @@ class ResourceLoaderImage {
|
|||
/**
|
||||
* Get the MIME type of the image.
|
||||
*
|
||||
* @param string $format Format to get the MIME type for, 'original' or 'rasterized'
|
||||
* @param string|null $format Format to get the MIME type for, 'original' or 'rasterized'
|
||||
* @return string
|
||||
*/
|
||||
public function getMimeType( $format = 'original' ) {
|
||||
|
|
@ -274,9 +274,9 @@ class ResourceLoaderImage {
|
|||
*
|
||||
* @param ResourceLoaderContext $context Image context, or any context if $variant and $format
|
||||
* given.
|
||||
* @param string|null $variant Variant to get the data for. Optional; if given, overrides the data
|
||||
* @param string|null|false $variant Variant to get the data for. Optional; if given, overrides the data
|
||||
* from $context.
|
||||
* @param string $format Format to get the data for, 'original' or 'rasterized'. Optional; if
|
||||
* @param string|false $format Format to get the data for, 'original' or 'rasterized'. Optional; if
|
||||
* given, overrides the data from $context.
|
||||
* @return string|false Possibly binary image data, or false on failure
|
||||
* @throws MWException If the image file doesn't exist
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface {
|
|||
* Get the group this module is in.
|
||||
*
|
||||
* @stable to override
|
||||
* @return string Group name
|
||||
* @return string|null Group name
|
||||
*/
|
||||
public function getGroup() {
|
||||
// Stub, override expected
|
||||
|
|
|
|||
Loading…
Reference in a new issue