Page MenuHomePhabricator

Small improve on autofix of MediaWiki.Usage.IsNullSniff possible to avoid unneeded parenthesis
Closed, InvalidPublic

Description

While reviewing the autofix I have seen a place where the parenthesis could be removed from the autofix.

Before
if ( is_null( $parser->getUser()->getOption( self::PREF_NAME ) ) ) {
Current auto-fix
if ( ( $parser->getUser()->getOption( self::PREF_NAME ) ) === null ) {
Expected
if ( $parser->getUser()->getOption( self::PREF_NAME ) === null ) {

https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/CategoryTagSorter/+/564304/1..2/CategoryTagSorter_body.php

If that makes it to complex to detect than I have no problem to make this invalid.
Just want leave a note.

Event Timeline

It seems the following code does not take function call in account

		$innerParenthesis = $phpcsFile->findNext(
			T_OPEN_PARENTHESIS,
			$stackPtrFirstExpressionToken,
			$stackPtrLastExpressionToken
		);

		// Something has been wrapped in parentheses ending just before the ending parenthesis of
		// the is_null statement.
DannyS712 subscribed.

I tried to figure this out but I think it would be too complex, and there isn't any harm in having the extra (), better to have them when not needed than risk removing them when needed, so marking as invalid per @Umherirrender