mediawiki-extensions-AbuseF.../includes/Parser/ParserStatus.php
Daimona Eaytoy 3e0c30ff92 Allow the parsers to return extra info
This is achieved by creating a new ParserStatus class. Aside from the
result of parse(), it contains whether the cache was warm. This can be
used to differentiate profiling data as part of T231112.

Another use case is returning non-fatal warnings (T269770).

Change-Id: Ifcbda861ce1a44bbe9bffba5b83cd9ef338a8dba
2020-12-11 15:03:23 +00:00

45 lines
918 B
PHP

<?php
namespace MediaWiki\Extension\AbuseFilter\Parser;
class ParserStatus {
/** @var bool */
private $result;
/** @var bool */
private $warmCache;
/** @var AFPException|null */
private $excep;
/**
* @param bool $result Whether the filter matched
* @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
*/
public function __construct( bool $result, bool $warmCache, ?AFPException $excep ) {
$this->result = $result;
$this->warmCache = $warmCache;
$this->excep = $excep;
}
/**
* @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;
}
}