Add missing @var and improve documentation

Change-Id: Ib258665c3fe76eeadd32f949fe01d88e6f2fd70d
This commit is contained in:
Umherirrender 2020-12-17 20:07:37 +01:00
parent 7c475b219f
commit 4de4305c6c
5 changed files with 36 additions and 23 deletions

View file

@ -2,9 +2,6 @@
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
<exclude name="MediaWiki.Commenting.FunctionComment.ObjectTypeHintParam" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingVar" />
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage" />
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
</rule>

View file

@ -22,21 +22,36 @@ class Gadget {
public const CACHE_TTL = 86400;
private $scripts = [],
$styles = [],
$dependencies = [],
$peers = [],
$messages = [],
$name,
$definition,
$resourceLoaded = false,
$requiredRights = [],
$requiredSkins = [],
$targets = [ 'desktop' ],
$onByDefault = false,
$hidden = false,
$type = '',
$category;
/** @var string[] */
private $scripts = [];
/** @var string[] */
private $styles = [];
/** @var string[] */
private $dependencies = [];
/** @var string[] */
private $peers = [];
/** @var string[] */
private $messages = [];
/** @var string|null */
private $name;
/** @var string|null */
private $definition;
/** @var bool */
private $resourceLoaded = false;
/** @var string[] */
private $requiredRights = [];
/** @var string[] */
private $requiredSkins = [];
/** @var string[] */
private $targets = [ 'desktop' ];
/** @var bool */
private $onByDefault = false;
/** @var bool */
private $hidden = false;
/** @var string */
private $type = '';
/** @var string|null */
private $category;
public function __construct( array $options ) {
foreach ( $options as $member => $option ) {

View file

@ -11,6 +11,7 @@ use Wikimedia\Rdbms\Database;
class MediaWikiGadgetsDefinitionRepo extends GadgetRepo {
private const CACHE_VERSION = 2;
/** @var array|false|null */
private $definitionCache;
/**
@ -69,7 +70,7 @@ class MediaWikiGadgetsDefinitionRepo extends GadgetRepo {
* Loads list of gadgets and returns it as associative array of sections with gadgets
* e.g. [ 'sectionnname1' => [ $gadget1, $gadget2 ],
* 'sectionnname2' => [ $gadget3 ] ];
* @return array|bool Gadget array or false on failure
* @return array|false Gadget array or false on failure
*/
protected function loadGadgets() {
if ( $this->definitionCache !== null ) {
@ -134,7 +135,7 @@ class MediaWikiGadgetsDefinitionRepo extends GadgetRepo {
* Fetch list of gadgets and returns it as associative array of sections with gadgets
* e.g. [ $name => $gadget1, etc. ]
* @param string|null $forceNewText Injected text of MediaWiki:gadgets-definition [optional]
* @return array|bool
* @return array|false
*/
public function fetchStructuredList( $forceNewText = null ) {
if ( $forceNewText === null ) {
@ -198,7 +199,7 @@ class MediaWikiGadgetsDefinitionRepo extends GadgetRepo {
* Creates an instance of this class from definition in MediaWiki:Gadgets-definition
* @param string $definition Gadget definition
* @param string $category
* @return Gadget|bool Instance of Gadget class or false if $definition is invalid
* @return Gadget|false Instance of Gadget class or false if $definition is invalid
*/
public function newFromDefinition( $definition, $category ) {
$m = [];

View file

@ -173,7 +173,7 @@ class SpecialGadgetUsage extends QueryPage {
/**
* @param Skin $skin
* @param object $result Result row
* @param stdClass $result Result row
* @return string|bool String of HTML
*/
public function formatResult( $skin, $result ) {

View file

@ -7,7 +7,7 @@
*/
class GadgetDefinitionValidator {
/**
* Validation metadata.
* @var array Validation metadata.
* 'foo.bar.baz' => [ 'type check callback',
* 'type name' [, 'member type check callback', 'member type name'] ]
*/