utils: Add missing documentation to class properties

Add doc-typehints to class properties found by the PropertyDocumentation
sniff to improve the documentation.

Once the sniff is enabled it avoids that new code is missing type
declarations. This is focused on documentation and does not change code.

Improve a mixed type to string

Change-Id: Id994553eaeac181775ac782423ff53928ad45466
This commit is contained in:
Umherirrender 2024-09-01 01:06:06 +02:00
parent d1c03580c5
commit 574e8b702c
7 changed files with 23 additions and 14 deletions

View file

@ -46,19 +46,19 @@ use RuntimeException;
*/
class GitInfo {
/** Singleton for the repo at $IP */
/** @var self|null Singleton for the repo at $IP */
protected static $repo = null;
/** Location of the .git directory */
/** @var string|null Location of the .git directory */
protected $basedir;
/** Location of the repository */
/** @var string Location of the repository */
protected $repoDir;
/** Path to JSON cache file for pre-computed git information */
/** @var string|null Path to JSON cache file for pre-computed git information */
protected $cacheFile;
/** Cached git information */
/** @var array Cached git information */
protected $cache = [];
/**

View file

@ -31,8 +31,10 @@ use Wikimedia\IPUtils;
*/
class MWRestrictions implements Stringable {
/** @var string[] */
private $ipAddresses = [ '0.0.0.0/0', '::/0' ];
/** @var string[] */
private $pages = [];
public StatusValue $validity;

View file

@ -109,24 +109,26 @@ class ZipDirectoryReader {
return $zdr->execute();
}
/** The opened file resource */
/** @var resource The opened file resource */
protected $file;
/** The cached length of the file, or null if it has not been loaded yet. */
/** @var int|null The cached length of the file, or null if it has not been loaded yet. */
protected $fileLength;
/** A segmented cache of the file contents */
/** @var string[] A segmented cache of the file contents */
protected $buffer;
/** The file data callback */
/** @var callable The file data callback */
protected $callback;
/** The ZIP64 mode */
/** @var bool The ZIP64 mode */
protected $zip64 = false;
/** Stored headers */
/** @var array Stored headers */
protected $eocdr;
/** @var array Stored headers */
protected $eocdr64;
/** @var array Stored headers */
protected $eocdr64Locator;
protected $data;
@ -198,7 +200,7 @@ class ZipDirectoryReader {
/**
* Throw an error, and log a debug message
* @param mixed $code
* @param string $code
* @param string $debugMessage
* @throws ZipDirectoryReaderError
* @return never

View file

@ -23,12 +23,13 @@
* @newable
*/
class ZipDirectoryReaderError extends Exception {
/** @var string */
protected $errorCode;
/**
* @stable to call
*
* @param mixed $code
* @param string $code
*/
public function __construct( $code ) {
$this->errorCode = $code;
@ -36,7 +37,7 @@ class ZipDirectoryReaderError extends Exception {
}
/**
* @return mixed
* @return string
*/
public function getErrorCode() {
return $this->errorCode;

View file

@ -8,6 +8,7 @@ use MediaWiki\Utils\GitInfo;
*/
class GitInfoTest extends MediaWikiIntegrationTestCase {
/** @var string */
private static $tempDir;
public static function setUpBeforeClass(): void {

View file

@ -5,7 +5,9 @@
*/
class ZipDirectoryReaderTest extends MediaWikiIntegrationTestCase {
/** @var string */
protected $zipDir;
/** @var array[] */
protected $entries;
protected function setUp(): void {

View file

@ -7,6 +7,7 @@ use MediaWiki\Status\Status;
class MWRestrictionsTest extends MediaWikiUnitTestCase {
/** @var MWRestrictions */
protected static $restrictionsForChecks;
public static function setUpBeforeClass(): void {