mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-11-15 10:15:24 +00:00
7c1d1c6d7d
This commit introduces some boilerplate for emitting warnings from the AbuseFilter parser, and also code for showing these warnings in the ace editor. Adding new warnings should be as simple as appending to AbuseFilterParser::warnings (and adding the relevant i18n). Bug: T264768 Bug: T269770 Change-Id: Ic11021b379f997a89f59c8c0572338d957e089a6
56 lines
1.1 KiB
PHP
56 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\AbuseFilter\Parser;
|
|
|
|
class ParserStatus {
|
|
/** @var bool */
|
|
private $result;
|
|
/** @var bool */
|
|
private $warmCache;
|
|
/** @var AFPException|null */
|
|
private $excep;
|
|
/** @var UserVisibleWarning[] */
|
|
private $warnings;
|
|
|
|
/**
|
|
* @param bool $result A generic operation result
|
|
* @param bool $warmCache Whether we retrieved the AST from cache
|
|
* @param AFPException|null $excep An exception thrown while parsing, or null if it parsed correctly
|
|
* @param UserVisibleWarning[] $warnings
|
|
*/
|
|
public function __construct( bool $result, bool $warmCache, ?AFPException $excep, array $warnings ) {
|
|
$this->result = $result;
|
|
$this->warmCache = $warmCache;
|
|
$this->excep = $excep;
|
|
$this->warnings = $warnings;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function getResult() : bool {
|
|
return $this->result;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
public function getWarmCache() : bool {
|
|
return $this->warmCache;
|
|
}
|
|
|
|
/**
|
|
* @return AFPException|null
|
|
*/
|
|
public function getException() : ?AFPException {
|
|
return $this->excep;
|
|
}
|
|
|
|
/**
|
|
* @return UserVisibleWarning[]
|
|
*/
|
|
public function getWarnings() : array {
|
|
return $this->warnings;
|
|
}
|
|
}
|