Continuous integration/Phan/Plugins
Appearance
- These plugins are part of
mediawiki/mediawiki-phan-configand run automatically when you run Phan with the standard MediaWiki configuration. For the separate security/taint plugin, see Phan-taint-check-plugin.
In addition to Phan's built-in checks, the MediaWiki configuration adds several project-specific plugins (in the src/Plugin directory of mediawiki/mediawiki-phan-config). Each emits its own issue type, listed below. As with any Phan issue, individual instances can be suppressed.
NoBaseExceptionPlugin
[edit]MediaWikiNoBaseException- Emitted when code instantiates the base
\Exceptionclass directly (new Exception( ... )), which is disallowed by MediaWiki code conventions. See Manual:Coding conventions/PHP#Exception handling for advice on what to do instead.
RedundantExistenceChecksPlugin
[edit]MediaWikiNoIssetIfDefined- Emitted when
isset()is used on an expression that appears to be always set.isset()should only be used to suppress "undefined" errors; check whether the expression isnullinstead. See Manual:Coding conventions/PHP#isset(). MediaWikiNoEmptyIfDefined- Emitted when
empty()is used on an expression that appears to be always set.empty()should only be used to suppress "undefined" errors. See Manual:Coding conventions/PHP#empty().
FirstClassCallableRecommendPlugin
[edit]MediaWikiUseFirstClassCallableMediaWikiUseFirstClassCallableInternalFunc- Emitted when a callable is written as a string or array (e.g.
'foo'or[ $obj, 'method' ]) where the first-class callable syntax (foo(...),$obj->method(...)) could be used instead. The...InternalFuncvariant is for built-in PHP functions. Supports--automatic-fix.
CrossComponentInternalPlugin
[edit]This plugin is proposed and not yet merged. |
MediaWikiCrossComponentInternalAccess- Emitted when code accesses a class member marked
@internalfrom a different component than the one that declares it; see Stable interface policy#Remove guarantees. A component is identified as the directory containing the nearestextension.json,skin.json, orcomposer.json, so each extension, skin, repository, and library undervendor/are considered separate components. The check covers method calls, property reads/writes, class-constant references, andnewinstantiation; a class-level@internalannotation implicitly marks every method, property, and constant declared in that class. It replaces Phan's built-in, namespace-scoped@internalchecks (PhanAccessMethodInternal,PhanAccessPropertyInternal,PhanAccessClassConstantInternal, etc.), which are disabled in the MediaWiki configuration. MediaWikiInternalNoComponent- A low-severity diagnostic emitted once per file when no
extension.json,skin.json, orcomposer.jsoncan be found above it, which means we can not confidently identify the component for theMediaWikiCrossComponentInternalAccesscheck; the file's own directory is then treated as a singleton "component".
RequireInternalPlugin
[edit]This plugin is proposed and not yet merged. |
MediaWikiMissingInternalAnnotation- Emitted when a non-anonymous class, interface, trait, or enum declared in a configured "internal" namespace is missing an
@internalannotation. This helps enforce access conventions in a given package. This is opt-in per package: list the internal namespaces underplugin_configin your.phan/config.php(the default is none, so the check does nothing by default):
return [
// ... rest of config ...
'plugin_config' => [
'require_internal_namespaces' => [
'Wikimedia\\Parsoid\\Wt2Html', // exact namespace
'Wikimedia\\Parsoid\\*', // and all sub-namespaces
],
],
];
- A trailing
\*matches sub-namespaces only, soWikimedia\Parsoid\*matchesWikimedia\Parsoid\Wt2Htmlbut notWikimedia\Parsoiditself (list both if an inclusive match is wanted). Suppress the issue on an individual class to keep it part of the public API despite its namespace. Supports--automatic-fix(which adds the missing@internaltag).