Open main menu

Changes

no edit summary
Software development is writing code. Testing makes sure the code actually works, so in a nutshell: '''Testing is software development''' :-)
== Phan ==
Phan is a '''[[wp:Static program analysis|static analyzer]]''' for PHP. It will help you write better PHP code. Please note that your source code To use it, you'll need to install the [https://github.com/nikic/php-ast Abstract Syntax Tree] PHP extension. See the [https://github.com/phan/phan/wiki/Tutorial-for-Analyzing-a-Large-Sloppy-Code-Base tutorial for analyzing a large sloppy codebase]
|text=If your Extension '''does''' have dependencies on other extensions, '''and''' you are hosting your code in gerrit for automated CI checks and fixes (you should), you must create an entry in the so-called [https://gerrit.wikimedia.org/r/plugins/gitiles/integration/config/+/refs/heads/master/zuul/parameter_functions.py#558 parameter-functions.py] to declare those dependencies.}}
==== MediaWiki Phan Config ====
The bigger (unanswered) question is '''what does mediawiki-phan-config do?''' What is the compiled and complete configuration that you are "running" against your codebase?
 
<br />
 
{{Collapsible
|visible_text=Show the full configuration for MediaWiki phan
|collapsed_content=
 
 
<syntaxhighlight lang="php" line="1">
Array
(
[backward_compatibility_checks] =>
[parent_constructor_required] => Array
(
)
 
[quick_mode] =>
[analyze_signature_compatibility] => 1
[ignore_undeclared_variables_in_global_scope] => 1
[read_type_annotations] => 1
[disable_suppression] =>
[dump_ast] =>
[dump_signatures_file] =>
[processes] => 1
[whitelist_issue_types] => Array
(
)
 
[markdown_issue_messages] =>
[generic_types_enabled] => 1
[plugins] => Array
(
[0] => PregRegexCheckerPlugin
[1] => UnusedSuppressionPlugin
[2] => DuplicateExpressionPlugin
[3] => LoopVariableReusePlugin
[4] => RedundantAssignmentPlugin
[5] => UnreachableCodePlugin
[6] => SimplifyExpressionPlugin
[7] => DuplicateArrayKeyPlugin
[8] => UseReturnValuePlugin
[9] => AddNeverReturnTypePlugin
[10] => /opt/htdocs/mediawiki/vendor/mediawiki/mediawiki-phan-config/src/../../phan-taint-check-plugin/MediaWikiSecurityCheckPlugin.php
)
 
[plugin_config] => Array
(
)
 
[file_list] => Array
(
[0] => .phan/stubs/password.php
[1] => .phan/stubs/Socket.php
[2] => .phan/stubs/WeakMap.php
[3] => includes/Defines.php
[4] => tests/phpunit/MediaWikiIntegrationTestCase.php
[5] => tests/phpunit/includes/TestUser.php
)
 
[exclude_file_list] => Array
(
[0] => vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Methods/MethodDeclarationUnitTest.inc
[1] => vendor/php-parallel-lint/php-parallel-lint/src/polyfill.php
)
 
[exclude_analysis_directory_list] => Array
(
[0] => vendor/
[1] => .phan/
[2] => tests/phpunit/
[3] => includes/config-vars.php
[4] => includes/composer/
[5] => maintenance/language/
[6] => includes/libs/jsminplus.php
[7] => includes/libs/objectcache/utils/MemcachedClient.php
[8] => includes/PHPVersionCheck.php
)
 
[exclude_file_regex] => @vendor/((composer/installers|php-parallel-lint/php-console-color|php-parallel-lint/php-console-highlighter|php-parallel-lint/php-parallel-lint|mediawiki/mediawiki-codesniffer|microsoft/tolerant-php-parser|phan/phan|phpunit/php-code-coverage|squizlabs/php_codesniffer|[^/]+/[^/]+/\.phan)|.*/[Tt]ests?)/@
[minimum_severity] => 0
[allow_missing_properties] =>
[null_casts_as_any_type] =>
[scalar_implicit_cast] =>
[dead_code_detection] =>
[dead_code_detection_prefer_false_negative] => 1
[progress_bar] =>
[enable_class_alias_support] =>
[redundant_condition_detection] => 1
[minimum_target_php_version] => 7.4.3
[target_php_version] => 8.1
[directory_list] => Array
(
[0] => includes/
[1] => languages/
[2] => maintenance/
[3] => mw-config/
[4] => resources/
[5] => vendor/
[6] => tests/common/
[7] => tests/parser/
[8] => tests/phpunit/mocks/
)
 
[suppress_issue_types] => Array
(
[0] => PhanDeprecatedFunction
[1] => PhanDeprecatedClass
[2] => PhanDeprecatedClassConstant
[3] => PhanDeprecatedFunctionInternal
[4] => PhanDeprecatedInterface
[5] => PhanDeprecatedProperty
[6] => PhanDeprecatedTrait
[7] => PhanUnreferencedUseNormal
[8] => PhanUnreferencedUseFunction
[9] => PhanUnreferencedUseConstant
[10] => PhanDuplicateUseNormal
[11] => PhanDuplicateUseFunction
[12] => PhanDuplicateUseConstant
[13] => PhanUseNormalNoEffect
[14] => PhanUseNormalNamespacedNoEffect
[15] => PhanUseFunctionNoEffect
[16] => PhanUseConstantNoEffect
[17] => PhanDeprecatedCaseInsensitiveDefine
[18] => PhanAccessClassConstantInternal
[19] => PhanAccessClassInternal
[20] => PhanAccessConstantInternal
[21] => PhanAccessMethodInternal
[22] => PhanAccessPropertyInternal
[23] => PhanParamNameIndicatingUnused
[24] => PhanParamNameIndicatingUnusedInClosure
[25] => PhanProvidingUnusedParameter
[26] => PhanPluginMixedKeyNoKey
[27] => SecurityCheck-LikelyFalsePositive
[28] => SecurityCheck-PHPSerializeInjection
[29] => PhanPluginDuplicateExpressionAssignmentOperation
[30] => PhanPluginDuplicateExpressionAssignmentOperation
)
 
[globals_type_map] => Array
(
[wgContLang] => \Language
[wgParser] => \Parser
[wgTitle] => \Title
[wgMemc] => \BagOStuff
[wgUser] => \User
[wgConf] => \SiteConfiguration
[wgLang] => \Language
[wgOut] => OutputPage
[wgRequest] => \WebRequest
[IP] => string
[wgGalleryOptions] => array
[wgDummyLanguageCodes] => string[]
[wgNamespaceProtection] => array<int,string|string[]>
[wgNamespaceAliases] => array<string,int>
[wgLockManagers] => array[]
[wgForeignFileRepos] => array[]
[wgDefaultUserOptions] => array
[wgSkipSkins] => string[]
[wgLogTypes] => string[]
[wgLogNames] => array<string,string>
[wgLogHeaders] => array<string,string>
[wgLogActionsHandlers] => array<string,class-string>
[wgPasswordPolicy] => array<string,array<string,string|array>>
[wgVirtualRestConfig] => array<string,array>
[wgWANObjectCaches] => array[]
[wgLocalInterwikis] => string[]
[wgDebugLogGroups] => string|false|array{destination:string,sample?:int,level:int}
[wgCookiePrefix] => string|false
[wgExtraNamespaces] => string[]
)
 
[analyzed_file_extensions] => Array
(
[0] => php
[1] => inc
)
 
[autoload_internal_extension_signatures] => Array
(
[dom] => .phan/internal_stubs/dom.phan_php
[excimer] => .phan/internal_stubs/excimer.php
[imagick] => .phan/internal_stubs/imagick.phan_php
[memcached] => .phan/internal_stubs/memcached.phan_php
[oci8] => .phan/internal_stubs/oci8.phan_php
[pcntl] => .phan/internal_stubs/pcntl.phan_php
[pgsql] => .phan/internal_stubs/pgsql.phan_php
[redis] => .phan/internal_stubs/redis.phan_php
[sockets] => .phan/internal_stubs/sockets.phan_php
[sqlsrv] => .phan/internal_stubs/sqlsrv.phan_php
[tideways] => .phan/internal_stubs/tideways.phan_php
[wikidiff2] => .phan/internal_stubs/wikidiff.php
)
 
)
 
</syntaxhighlight>
 
}}
 
MediaWiki Phan Config has a [https://github.com/wikimedia/mediawiki-tools-phan/blob/master/src/ConfigBuilder.php#L8 ConfigBuilder.php] class that is used to build up the project's phan config. The goto file to see how it's configured is '''[https://github.com/wikimedia/mediawiki-tools-phan/blob/master/src/config.php config.php]'''
===Psalm===
https://psalm.dev/