mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-11-13 17:56:59 +00:00
Replace isset() with null check
isset() should only be used to suppress errors, not for null check. When the variable is always defined, there is no need to use isset. Found by a new phan plugin (2efea9f989) https://www.mediawiki.org/wiki/Manual:Coding_conventions/PHP#isset Change-Id: I4e797c539d8d7868bfac63fcac6b2f78463f6475
This commit is contained in:
parent
5c6bc704a2
commit
cf6271fa06
|
@ -24,7 +24,7 @@ class MathoidChecker extends BaseChecker {
|
|||
private $type;
|
||||
/** @var LoggerInterface */
|
||||
private $logger;
|
||||
/** @var int */
|
||||
/** @var int|null */
|
||||
private $statusCode;
|
||||
/** @var string */
|
||||
private $response;
|
||||
|
@ -52,7 +52,7 @@ class MathoidChecker extends BaseChecker {
|
|||
* @return array
|
||||
*/
|
||||
public function getCheckResponse(): array {
|
||||
if ( !isset( $this->statusCode ) ) {
|
||||
if ( $this->statusCode === null ) {
|
||||
$cacheInputKey = $this->getCacheKey();
|
||||
if ( $this->purge ) {
|
||||
$this->cache->delete( $cacheInputKey, WANObjectCache::TTL_INDEFINITE );
|
||||
|
|
|
@ -1097,14 +1097,14 @@ class BaseParsing {
|
|||
$intentParams = MMLParsingUtil::getIntentParams( $intentContent );
|
||||
// Sometimes the intent has additioargs = {array[3]} nal args in the same string
|
||||
$intentArg = MMLParsingUtil::getIntentArgs( $intentStr );
|
||||
if ( !$intentContent && !$intentParams && isset( $intentArg ) ) {
|
||||
if ( !$intentContent && !$intentParams && $intentArg !== null ) {
|
||||
// explicit args annotation parsing in literal
|
||||
// return $arg1->renderMML([],["intent-params-expl"=>$intentArg]);
|
||||
// alternative just add the arg here
|
||||
return $arg1->renderMML( [ "arg" => $intentArg ] );
|
||||
}
|
||||
$intentContentAtr = [ "intent" => $intentContent ];
|
||||
if ( isset( $intentArg ) ) {
|
||||
if ( $intentArg !== null ) {
|
||||
$intentContentAtr["arg"] = $intentArg;
|
||||
}
|
||||
// tbd refine intent params and operator content merging (does it overwrite ??)
|
||||
|
|
|
@ -226,7 +226,7 @@ class MMLParsingUtil {
|
|||
}
|
||||
if ( $useFoundNodes ) {
|
||||
$foundNodes = $xml->xpath( $elementTag );
|
||||
if ( !( isset( $foundNodes ) && count( $foundNodes ) >= 1 ) ) {
|
||||
if ( !( $foundNodes !== null && count( $foundNodes ) >= 1 ) ) {
|
||||
return $renderedMML;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -452,7 +452,7 @@ class MhchemStateMachines {
|
|||
$c4 = $this->mhchemParser->getPatterns()->match( '$one lowercase latin letter$ $',
|
||||
$buffer["o"] ?? "" );
|
||||
$hyphenFollows = $m === "-" && ( ( isset( $c1["remainder"] ) && $c1["remainder"] === "" )
|
||||
|| isset( $c2 ) || isset( $c3 ) || isset( $c4 ) );
|
||||
|| $c2 !== null || $c3 !== null || $c4 !== null );
|
||||
if ( $hyphenFollows && !isset( $buffer["a"] ) && !isset( $buffer["b"] )
|
||||
&& !isset( $buffer["p"] ) && !isset( $buffer["d"] )
|
||||
&& !isset( $buffer["q"] ) && !$c1 && $c3 ) {
|
||||
|
|
|
@ -227,7 +227,7 @@ class MhchemTexify {
|
|||
default:
|
||||
$res = null;
|
||||
}
|
||||
if ( isset( $res ) ) {
|
||||
if ( $res !== null ) {
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue