Open main menu

Changes

1,093 bytes added ,  19 February
link to new .phan/local-config.php
Phan is a '''[[wp:Static program analysis|static analyzer]]''' for PHP. It apparently originated from Etsy. It will help you write better PHP code. Please note that your source code should follow best practices for directory layout<ref>Essentially, code should live in a 'src' or 'includes' directory; tests go in 'tests' etc. https://www.mediawiki.org/wiki/Best_practices_for_extensions#File_structure</ref>. 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]
[https://github.com/phan/phan Phan project on GitHub]
 
The [[MediaWiki]] project uses Phan in its [[Continuous Integration]].
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?
For example, one basic attribute is the "severity level" or rigor of the analysis. What is that set to for MediaWiki code? Phan has a CLI option named <code>-y, --minimum-severity <level></code> The level can be any digit from 0-10, '''defaulting to 0. Zero means report every possible problem.''' Minimum severity of 10 would report only 'critical' problems.  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 main file to see how it's configured is '''[https://github.com/wikimedia/mediawiki-tools-phan/blob/master/src/config.php config.php]''' After reading that and [https://github.com/wikimedia/mediawiki/blob/d0dae26538d7c5e178de2406e88738933da05f58/.phan/config.php the source of <code>./phan/config.php</code>], we figured out the full configuration, '''and''' that you can create your own overrides/customizations in a file called <code>.[[phan/local-config.php]]</code><br />
=====Fully parsed configuration=====
{{Collapsible
|visible_text=Show the full configuration for MediaWiki phan
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]'''
 Phan has a ton of plugins - but their usage in the MediaWiki configuration is not mentioned or described anywhere (that I could find). I found a list in 'base-config-functions' [https://github.com/wikimedia/mediawiki-tools-phan/blob/master/src/base-config-functions.php#L68 mediawiki-tools-phan/blob/master/src/base-config-functions.php#L68], but why you need to read the entire source code to "reverse engineer" what is happening? It's not fun. So, again, refer to the fully parsed configuration in the collapsed section above.
===Phan Plugins===
https://github.com/phan/phan/tree/v5/tests/files/src
<br />  {{References}}
[[Category:Tools]]