Fix even more PSR12.Properties.ConstantVisibility.NotFound

Change-Id: I6d98efcfac1f1c0ab6a442e0af6d5daa6ef7801a
This commit is contained in:
Reedy 2020-05-15 23:40:17 +01:00
parent b1e515e36e
commit b038d6333a
12 changed files with 65 additions and 82 deletions

View file

@ -21,8 +21,6 @@
<rule ref="PSR12.Properties.ConstantVisibility.NotFound">
<exclude-pattern>includes/Storage/</exclude-pattern>
<exclude-pattern>includes/libs/</exclude-pattern>
<exclude-pattern>includes/parser/</exclude-pattern>
<exclude-pattern>includes/utils/</exclude-pattern>
<exclude-pattern>languages/</exclude-pattern>
<exclude-pattern>tests/phpunit/includes/</exclude-pattern>
</rule>

View file

@ -31,15 +31,15 @@ class BlockLevelPass {
private $text;
# State constants for the definition list colon extraction
const COLON_STATE_TEXT = 0;
const COLON_STATE_TAG = 1;
const COLON_STATE_TAGSTART = 2;
const COLON_STATE_CLOSETAG = 3;
const COLON_STATE_TAGSLASH = 4;
const COLON_STATE_COMMENT = 5;
const COLON_STATE_COMMENTDASH = 6;
const COLON_STATE_COMMENTDASHDASH = 7;
const COLON_STATE_LC = 8;
private const COLON_STATE_TEXT = 0;
private const COLON_STATE_TAG = 1;
private const COLON_STATE_TAGSTART = 2;
private const COLON_STATE_CLOSETAG = 3;
private const COLON_STATE_TAGSLASH = 4;
private const COLON_STATE_COMMENT = 5;
private const COLON_STATE_COMMENTDASH = 6;
private const COLON_STATE_COMMENTDASHDASH = 7;
private const COLON_STATE_LC = 8;
/**
* Make lists from lines starting with ':', '*', '#', etc.

View file

@ -65,37 +65,37 @@ class DateFormatter {
private $targetFormats;
/** Used as a preference ID for rules that apply regardless of preference */
const ALL = -1;
private const ALL = -1;
/** No preference: the date may be left in the same format as the input */
const NONE = 0;
private const NONE = 0;
/** e.g. January 15, 2001 */
const MDY = 1;
private const MDY = 1;
/** e.g. 15 January 2001 */
const DMY = 2;
private const DMY = 2;
/** e.g. 2001 January 15 */
const YMD = 3;
private const YMD = 3;
/** e.g. 2001-01-15 */
const ISO = 4;
private const ISO = 4;
/** The highest ID that is a valid user preference */
const LASTPREF = 4;
private const LASTPREF = 4;
/** e.g. 2001, 15 January */
const YDM = 5;
private const YDM = 5;
/** e.g. 15 January */
const DM = 6;
private const DM = 6;
/** e.g. January 15 */
const MD = 7;
private const MD = 7;
/** The highest ID that is a valid target format */
const LAST = 7;
private const LAST = 7;
/**
* @param Language $lang In which language to format the date

View file

@ -26,19 +26,16 @@
* @property PPFrame $parent
*/
interface PPFrame {
const NO_ARGS = 1;
const NO_TEMPLATES = 2;
const STRIP_COMMENTS = 4;
const NO_IGNORE = 8;
const RECOVER_COMMENTS = 16;
const NO_TAGS = 32;
public const NO_ARGS = 1;
public const NO_TEMPLATES = 2;
public const STRIP_COMMENTS = 4;
public const NO_IGNORE = 8;
public const RECOVER_COMMENTS = 16;
public const NO_TAGS = 32;
const RECOVER_ORIG = self::NO_ARGS | self::NO_TEMPLATES | self::NO_IGNORE |
public const RECOVER_ORIG = self::NO_ARGS | self::NO_TEMPLATES | self::NO_IGNORE |
self::RECOVER_COMMENTS | self::NO_TAGS;
/** This constant exists when $indexOffset is supported in newChild() */
const SUPPORTS_INDEX_OFFSET = 1;
/**
* Create a child frame
*

View file

@ -48,13 +48,13 @@ class PPNode_Hash_Tree implements PPNode {
* The offset of the name within descriptors, used in some places for
* readability.
*/
const NAME = 0;
public const NAME = 0;
/**
* The offset of the child list within descriptors, used in some places for
* readability.
*/
const CHILDREN = 1;
public const CHILDREN = 1;
/**
* Construct an object using the data from $store[$index]. The rest of the

View file

@ -82,11 +82,11 @@ class Parser {
* changes in an incompatible way, so the parser cache
* can automatically discard old data.
*/
const VERSION = '1.6.4';
public const VERSION = '1.6.4';
# Flags for Parser::setFunctionHook
const SFH_NO_HASH = 1;
const SFH_OBJECT_ARGS = 2;
public const SFH_NO_HASH = 1;
public const SFH_OBJECT_ARGS = 2;
# Constants needed for external link processing
# Everything except bracket, space, or control characters
@ -94,7 +94,7 @@ class Parser {
# as well as U+3000 is IDEOGRAPHIC SPACE for T21052
# \x{FFFD} is the Unicode replacement character, which the HTML5 spec
# uses to replace invalid HTML characters.
const EXT_LINK_URL_CLASS = '[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}]';
public const EXT_LINK_URL_CLASS = '[^][<>"\\x00-\\x20\\x7F\p{Zs}\x{FFFD}]';
# Simplified expression to match an IPv4 or IPv6 address, or
# at least one character of a host name (embeds EXT_LINK_URL_CLASS)
// phpcs:ignore Generic.Files.LineLength
@ -108,15 +108,16 @@ class Parser {
private const SPACE_NOT_NL = '(?:\t|&nbsp;|&\#0*160;|&\#[Xx]0*[Aa]0;|\p{Zs})';
# Flags for preprocessToDom
const PTD_FOR_INCLUSION = 1;
public const PTD_FOR_INCLUSION = 1;
# Allowed values for $this->mOutputType
# Parameter to startExternalParse().
const OT_HTML = 1; # like parse()
const OT_WIKI = 2; # like preSaveTransform()
const OT_PREPROCESS = 3; # like preprocess()
const OT_MSG = 3;
const OT_PLAIN = 4; # like extractSections() - portions of the original are returned unchanged.
public const OT_HTML = 1; # like parse()
public const OT_WIKI = 2; # like preSaveTransform()
public const OT_PREPROCESS = 3; # like preprocess()
public const OT_MSG = 3;
# like extractSections() - portions of the original are returned unchanged.
public const OT_PLAIN = 4;
/**
* @var string Prefix and suffix for temporary replacement strings
@ -135,18 +136,12 @@ class Parser {
* escaping quote marks, and break out of the attribute. Thus we add
* `'".
*/
const MARKER_SUFFIX = "-QINU`\"'\x7f";
const MARKER_PREFIX = "\x7f'\"`UNIQ-";
public const MARKER_SUFFIX = "-QINU`\"'\x7f";
public const MARKER_PREFIX = "\x7f'\"`UNIQ-";
# Markers used for wrapping the table of contents
const TOC_START = '<mw:toc>';
const TOC_END = '</mw:toc>';
/**
* @var int Assume that no output will later be saved this many seconds after parsing
* @deprecated since 1.35; moved to CoreMagicWords and made private
*/
const MAX_TTS = 900;
public const TOC_START = '<mw:toc>';
public const TOC_END = '</mw:toc>';
# Persistent:
/** @deprecated since 1.35; use Parser::getTags() */

View file

@ -34,19 +34,19 @@ class ParserCache {
*/
/** Use only current data */
const USE_CURRENT_ONLY = 0;
private const USE_CURRENT_ONLY = 0;
/** Use expired data if current data is unavailable */
const USE_EXPIRED = 1;
private const USE_EXPIRED = 1;
/** Use expired data or data from different revisions if current data is unavailable */
const USE_OUTDATED = 2;
private const USE_OUTDATED = 2;
/**
* Use expired data and data from different revisions, and if all else
* fails vary on all variable options
*/
const USE_ANYTHING = 3;
private const USE_ANYTHING = 3;
/** @var BagOStuff */
private $cache;

View file

@ -41,13 +41,6 @@ use Wikimedia\ScopedCallback;
*/
class ParserOptions {
/**
* Flag indicating that newCanonical() accepts an IContextSource or the string 'canonical', for
* back-compat checks from extensions.
* @since 1.32
*/
const HAS_NEWCANONICAL_FROM_CONTEXT = 1;
/**
* Default values for all options that are relevant for caching.
* @see self::getDefaults()

View file

@ -29,12 +29,12 @@ class ParserOutput extends CacheTime {
*
* @since 1.31
*/
const SUPPORTS_STATELESS_TRANSFORMS = 1;
public const SUPPORTS_STATELESS_TRANSFORMS = 1;
/**
* @since 1.31
*/
const SUPPORTS_UNWRAP_TRANSFORM = 1;
public const SUPPORTS_UNWRAP_TRANSFORM = 1;
/**
* @var string|null The output text
@ -251,17 +251,17 @@ class ParserOutput extends CacheTime {
/** @var int Upper bound of expiry based on parse duration */
private $mMaxAdaptiveExpiry = INF;
const EDITSECTION_REGEX =
private const EDITSECTION_REGEX =
'#<(?:mw:)?editsection page="(.*?)" section="(.*?)"(?:/>|>(.*?)(</(?:mw:)?editsection>))#s';
// finalizeAdaptiveCacheExpiry() uses TTL = MAX( m * PARSE_TIME + b, MIN_AR_TTL)
// Current values imply that m=3933.333333 and b=-333.333333
// See https://www.nngroup.com/articles/website-response-times/
const PARSE_FAST_SEC = 0.100; // perceived "fast" page parse
const PARSE_SLOW_SEC = 1.0; // perceived "slow" page parse
const FAST_AR_TTL = 60; // adaptive TTL for "fast" pages
const SLOW_AR_TTL = 3600; // adaptive TTL for "slow" pages
const MIN_AR_TTL = 15; // min adaptive TTL (for sanity, pool counter, and edit stashing)
private const PARSE_FAST_SEC = 0.100; // perceived "fast" page parse
private const PARSE_SLOW_SEC = 1.0; // perceived "slow" page parse
private const FAST_AR_TTL = 60; // adaptive TTL for "fast" pages
private const SLOW_AR_TTL = 3600; // adaptive TTL for "slow" pages
private const MIN_AR_TTL = 15; // min adaptive TTL (for sanity, pool counter, and edit stashing)
/**
* @param string|null $text HTML. Use null to indicate that this ParserOutput contains only

View file

@ -29,7 +29,7 @@ use MediaWiki\MediaWikiServices;
*/
abstract class Preprocessor {
const CACHE_VERSION = 1;
public const CACHE_VERSION = 1;
/**
* @var Parser

View file

@ -41,8 +41,8 @@
*/
// phpcs:ignore Squiz.Classes.ValidClassName.NotCamelCaps
class Preprocessor_Hash extends Preprocessor {
const CACHE_PREFIX = 'preprocess-hash';
const CACHE_VERSION = 2;
public const CACHE_PREFIX = 'preprocess-hash';
public const CACHE_VERSION = 2;
/**
* @param Parser $parser

View file

@ -35,7 +35,7 @@ class Sanitizer {
* Regular expression to match various types of character references in
* Sanitizer::normalizeCharReferences and Sanitizer::decodeCharReferences
*/
const CHAR_REFS_REGEX =
private const CHAR_REFS_REGEX =
'/&([A-Za-z0-9\x80-\xff]+);
|&\#([0-9]+);
|&\#[xX]([0-9A-Fa-f]+);
@ -45,7 +45,7 @@ class Sanitizer {
* Acceptable tag name charset from HTML5 parsing spec
* https://www.w3.org/TR/html5/syntax.html#tag-open-state
*/
const ELEMENT_BITS_REGEX = '!^(/?)([A-Za-z][^\t\n\v />\0]*+)([^>]*?)(/?>)([^<]*)$!';
private const ELEMENT_BITS_REGEX = '!^(/?)([A-Za-z][^\t\n\v />\0]*+)([^>]*?)(/?>)([^<]*)$!';
/**
* Blacklist for evil uris like javascript:
@ -55,15 +55,15 @@ class Sanitizer {
* things that you know are safe and deny everything else.
* [1]: http://ha.ckers.org/xss.html
*/
const EVIL_URI_PATTERN = '!(^|\s|\*/\s*)(javascript|vbscript)([^\w]|$)!i';
const XMLNS_ATTRIBUTE_PATTERN = "/^xmlns:[:A-Z_a-z-.0-9]+$/";
private const EVIL_URI_PATTERN = '!(^|\s|\*/\s*)(javascript|vbscript)([^\w]|$)!i';
private const XMLNS_ATTRIBUTE_PATTERN = "/^xmlns:[:A-Z_a-z-.0-9]+$/";
/**
* Tells escapeUrlForHtml() to encode the ID using the wiki's primary encoding.
*
* @since 1.30
*/
const ID_PRIMARY = 0;
public const ID_PRIMARY = 0;
/**
* Tells escapeUrlForHtml() to encode the ID using the fallback encoding, or return false
@ -71,7 +71,7 @@ class Sanitizer {
*
* @since 1.30
*/
const ID_FALLBACK = 1;
public const ID_FALLBACK = 1;
/**
* List of all named character entities defined in HTML 4.01