MediaWiki-CodeSniffer
MediaWiki CodeSniffer Standards
Loading...
Searching...
No Matches
MediaWiki\Sniffs\Usage Namespace Reference

Sniff to suppress the use of: Fail: return $a = 0; Pass: return $a == 0. More...

Classes

class  AssignmentInReturnSniff
 
class  DbrQueryUsageSniff
 
class  DeprecatedConstantUsageSniff
 
class  DeprecatedGlobalVariablesSniff
 
class  DirUsageSniff
 
class  ExtendClassUsageSniff
 
class  FinalPrivateSniff
 
class  ForbiddenFunctionsSniff
 Use e.g. More...
 
class  InArrayUsageSniff
 Custom sniff that finds unnecessary slow in_array() that can be replaced with array_key_exists() or isset(). More...
 
class  IsNullSniff
 Identify usage of is_null and replace it with a comparison against null. More...
 
class  MagicConstantClosureSniff
 
class  NestedFunctionsSniff
 
class  NestedInlineTernarySniff
 
class  NullableTypeSniff
 Enforce use of ?MyClass $x instead of MyClass $x = null, which is (correctly) misinterpreted as optional by IDEs and static analysis tools. More...
 
class  PlusStringConcatSniff
 
class  ReferenceThisSniff
 Disallows usage of &$this, which results in warnings since PHP 7.1. More...
 
class  StaticClosureSniff
 
class  SuperGlobalsUsageSniff
 

Detailed Description

Sniff to suppress the use of: Fail: return $a = 0; Pass: return $a == 0.

Do not access php superglobals like $__GET,$__POST,$__SERVER.

Copyright (C) 2017 Kunal Mehta legok.nosp@m.tm@m.nosp@m.ember.nosp@m..fsf.nosp@m..org

Sniff to suppress the use of final on private methods.

Report warnings when a global variable or function is used where there's a better context-aware alternative.

Report error when dirname(FILE) is used instead of DIR

Report warnings when $dbr->query() is used instead of $dbr->select()

Fail: dirname( FILE ) Pass: dirname( FILE . "/.." ) Pass: dirname( FILE, 2 ) Pass: dirname( joinpaths( FILE, ".." ) ) Pass: $abc->dirname( FILE ) Pass: parent::dirname( FILE )

Should use $this->msg() rather than wfMessage() on ContextSource extend. Should use $this->getUser() rather than $wgUser on ContextSource extend. Should use $this->getRequest() rather than $wgRequest on ContextSource extend.

Once PHP 8 is required, using both final and private on a function will produce a warning, and this sniff should be removed.

Author
DannyS712

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Fail: $_GET['id'] Fail: $_POST['user'] Fail: $_SERVER['ip']