MaxSem has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/359369 )
Change subject: Add Phan config/make it pass
......................................................................
Add Phan config/make it pass
Test with
phan -k tests/phan/config.php
Change-Id: I1d567e2a3b4e4834fd2bcf964d40c39740618122
---
M .gitignore
M includes/PresentationModel.php
A tests/phan/config.php
A tests/phan/stubs/hhvm.php
4 files changed, 142 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LoginNotify
refs/changes/69/359369/1
diff --git a/.gitignore b/.gitignore
index 8aa2a07..c222fee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
node_modules/
vendor/
composer.lock
+tests/phan/issues
# Editors
*.kate-swp
diff --git a/includes/PresentationModel.php b/includes/PresentationModel.php
index 43c4ccb..e359e99 100644
--- a/includes/PresentationModel.php
+++ b/includes/PresentationModel.php
@@ -32,7 +32,7 @@
/**
* Define the email subject string
*
- * @return string Message string for email subject
+ * @return Message Email subject
*/
public function getSubjectMessage() {
switch ( $this->event->getType() ) {
diff --git a/tests/phan/config.php b/tests/phan/config.php
new file mode 100644
index 0000000..3571023
--- /dev/null
+++ b/tests/phan/config.php
@@ -0,0 +1,126 @@
+<?php
+
+$directoryList = [];
+$excludeAnalysisDirectoryList = [];
+
+$IP = getenv( 'MW_INSTALL_PATH' );
+if ( $IP === false ) {
+ $IP = realpath( __DIR__ . '/../../../..' );
+}
+
+$cirrusDirs = ['includes', 'tests/phan/stubs'];
+$otherDirs = [
+ 'includes', 'vendor', 'maintenance', 'languages',
+ 'extensions/Echo', 'extensions/CentralAuth',
+];
+// Use '.' if possible as the path to LoginNotify to keep output filenames
short
+if ( getcwd() === realpath( __DIR__ . '/../../' ) ) {
+ $ourIP = '.';
+} else {
+ $ourIP = "$IP/extensions/LoginNotify";
+}
+foreach ( $cirrusDirs as $dir ) {
+ $directoryList[] = "$ourIP/$dir";
+}
+foreach ( $otherDirs as $dir ) {
+ $fullpath = "$IP/$dir";
+ // Some directories, like `vendor`, are optional. The
+ // required deps may have been installed at the top level of mediawiki
+ // or some such
+ if ( is_dir( $fullpath ) ) {
+ $directoryList[] = $fullpath;
+ $excludeAnalysisDirectoryList[] = $fullpath;
+ }
+}
+
+/**
+ * This configuration will be read and overlaid on top of the
+ * default configuration. Command line arguments will be applied
+ * after this file is read.
+ *
+ * @see src/Phan/Config.php
+ * See Config for all configurable options.
+ */
+return [
+ // A list of directories that should be parsed for class and
+ // method information. After excluding the directories
+ // defined in exclude_analysis_directory_list, the remaining
+ // files will be statically analyzed for errors.
+ //
+ // Thus, both first-party and third-party code being used by
+ // your application should be included in this list.
+ 'directory_list' => $directoryList,
+
+ // A directory list that defines files that will be excluded
+ // from static analysis, but whose class and method
+ // information should be included.
+ //
+ // Generally, you'll want to include the directories for
+ // third-party code (such as "vendor/") in this list.
+ //
+ // n.b.: If you'd like to parse but not analyze 3rd
+ // party code, directories containing that code
+ // should be added to the `directory_list` as
+ // to `excluce_analysis_directory_list`.
+ "exclude_analysis_directory_list" => $excludeAnalysisDirectoryList,
+
+ // Backwards Compatibility Checking. This is slow
+ // and expensive, but you should consider running
+ // it before upgrading your version of PHP to a
+ // new version that has backward compatibility
+ // breaks.
+ 'backward_compatibility_checks' => false,
+
+ // Run a quick version of checks that takes less
+ // time at the cost of not running as thorough
+ // an analysis. You should consider setting this
+ // to true only when you wish you had more issues
+ // to fix in your code base.
+ 'quick_mode' => false,
+
+ // If enabled, check all methods that override a
+ // parent method to make sure its signature is
+ // compatible with the parent's. This check
+ // can add quite a bit of time to the analysis.
+ 'analyze_signature_compatibility' => true,
+
+ // The minimum severity level to report on. This can be
+ // set to Issue::SEVERITY_LOW, Issue::SEVERITY_NORMAL or
+ // Issue::SEVERITY_CRITICAL. Setting it to only
+ // critical issues is a good place to start on a big
+ // sloppy mature code base.
+ 'minimum_severity' => 0,
+
+ // If true, missing properties will be created when
+ // they are first seen. If false, we'll report an
+ // error message if there is an attempt to write
+ // to a class property that wasn't explicitly
+ // defined.
+ 'allow_missing_properties' => false,
+
+ // Allow null to be cast as any type and for any
+ // type to be cast to null. Setting this to false
+ // will cut down on false positives.
+ 'null_casts_as_any_type' => false,
+
+ // If enabled, scalars (int, float, bool, string, null)
+ // are treated as if they can cast to each other.
+ 'scalar_implicit_cast' => false,
+
+ // If true, seemingly undeclared variables in the global
+ // scope will be ignored. This is useful for projects
+ // with complicated cross-file globals that you have no
+ // hope of fixing.
+ 'ignore_undeclared_variables_in_global_scope' => true,
+
+ // Add any issue types (such as 'PhanUndeclaredMethod')
+ // to this black-list to inhibit them from being reported.
+ 'suppress_issue_types' => [
+ ],
+
+ // If empty, no filter against issues types will be applied.
+ // If this white-list is non-empty, only issues within the list
+ // will be emitted by Phan.
+ 'whitelist_issue_types' => [
+ ],
+];
diff --git a/tests/phan/stubs/hhvm.php b/tests/phan/stubs/hhvm.php
new file mode 100644
index 0000000..28c1e8c
--- /dev/null
+++ b/tests/phan/stubs/hhvm.php
@@ -0,0 +1,14 @@
+<?php
+
+/**
+ * Stub methods from hhvm that phan doesn't know about
+ */
+
+/**
+ * @param string $poolName
+ * @param string|null $url
+ * @return resource|false
+ */
+//function curl_init_pooled( $poolName, $url = null ) {
+// return false;
+//}
--
To view, visit https://gerrit.wikimedia.org/r/359369
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d567e2a3b4e4834fd2bcf964d40c39740618122
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LoginNotify
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits