From 7eca763fda036dbe7d84308e7d3fc7e4dc9a96bd Mon Sep 17 00:00:00 2001 From: MDW Date: Wed, 18 Oct 2023 15:54:01 +0200 Subject: [PATCH] Add phan flow --- .github/workflows/phan.yml | 32 + .phan/baseline.txt | 78 ++ .phan/config.php | 363 +++++++ .phan/stubs/Core.phan_php | 333 ++++++ .phan/stubs/FFI.phan_php | 116 ++ .phan/stubs/PDO.phan_php | 190 ++++ .phan/stubs/Phar.phan_php | 199 ++++ .phan/stubs/README.md | 2 + .phan/stubs/Reflection.phan_php | 358 ++++++ .phan/stubs/SPL.phan_php | 948 ++++++++++++++++ .phan/stubs/SimpleXML.phan_php | 43 + .phan/stubs/apc.phan_php | 24 + .phan/stubs/apcu.phan_php | 49 + .phan/stubs/ast.phan_php | 242 +++++ .phan/stubs/bcmath.phan_php | 16 + .phan/stubs/brotli.phan_php | 29 + .phan/stubs/calendar.phan_php | 45 + .phan/stubs/ctype.phan_php | 17 + .phan/stubs/curl.phan_php | 616 +++++++++++ .phan/stubs/date.phan_php | 247 +++++ .phan/stubs/dom.phan_php | 420 +++++++ .phan/stubs/exif.phan_php | 11 + .phan/stubs/fileinfo.phan_php | 30 + .phan/stubs/filter.phan_php | 71 ++ .phan/stubs/ftp.phan_php | 53 + .phan/stubs/gd.phan_php | 189 ++++ .phan/stubs/gettext.phan_php | 16 + .phan/stubs/hash.phan_php | 65 ++ .phan/stubs/iconv.phan_php | 20 + .phan/stubs/igbinary.phan_php | 8 + .phan/stubs/imap.phan_php | 149 +++ .phan/stubs/intl.phan_php | 1807 +++++++++++++++++++++++++++++++ .phan/stubs/json.phan_php | 53 + .phan/stubs/ldap.phan_php | 155 +++ .phan/stubs/libxml.phan_php | 51 + .phan/stubs/mailparse.phan_php | 39 + .phan/stubs/mbstring.phan_php | 91 ++ .phan/stubs/mcrypt.phan_php | 79 ++ .phan/stubs/memcache.phan_php | 72 ++ .phan/stubs/memcached.phan_php | 180 +++ .phan/stubs/mongodb.phan_php | 553 ++++++++++ .phan/stubs/mysqli.phan_php | 397 +++++++ .phan/stubs/mysqlnd.phan_php | 4 + .phan/stubs/openssl.phan_php | 111 ++ .phan/stubs/pcntl.phan_php | 153 +++ .phan/stubs/pcre.phan_php | 35 + .phan/stubs/pdo_cubrid.phan_php | 4 + .phan/stubs/pdo_mysql.phan_php | 4 + .phan/stubs/pdo_pgsql.phan_php | 4 + .phan/stubs/pdo_sqlite.phan_php | 4 + .phan/stubs/pgsql.phan_php | 189 ++++ .phan/stubs/posix.phan_php | 69 ++ .phan/stubs/random.phan_php | 115 ++ .phan/stubs/readline.phan_php | 20 + .phan/stubs/redis.phan_php | 490 +++++++++ .phan/stubs/session.phan_php | 68 ++ .phan/stubs/shmop.phan_php | 15 + .phan/stubs/soap.phan_php | 220 ++++ .phan/stubs/sockets.phan_php | 260 +++++ .phan/stubs/sodium.phan_php | 186 ++++ .phan/stubs/sqlite3.phan_php | 73 ++ .phan/stubs/standard.phan_php | 960 ++++++++++++++++ .phan/stubs/sysvmsg.phan_php | 21 + .phan/stubs/sysvsem.phan_php | 13 + .phan/stubs/sysvshm.phan_php | 16 + .phan/stubs/tokenizer.phan_php | 146 +++ .phan/stubs/xdebug.phan_php | 52 + .phan/stubs/xml.phan_php | 55 + .phan/stubs/xmlreader.phan_php | 76 ++ .phan/stubs/xmlwriter.phan_php | 95 ++ .phan/stubs/xsl.phan_php | 37 + .phan/stubs/yaml.phan_php | 36 + .phan/stubs/zip.phan_php | 161 +++ .phan/stubs/zlib.phan_php | 64 ++ runPhan.sh | 15 + 75 files changed, 12227 insertions(+) create mode 100644 .github/workflows/phan.yml create mode 100644 .phan/baseline.txt create mode 100644 .phan/config.php create mode 100644 .phan/stubs/Core.phan_php create mode 100644 .phan/stubs/FFI.phan_php create mode 100644 .phan/stubs/PDO.phan_php create mode 100644 .phan/stubs/Phar.phan_php create mode 100644 .phan/stubs/README.md create mode 100644 .phan/stubs/Reflection.phan_php create mode 100644 .phan/stubs/SPL.phan_php create mode 100644 .phan/stubs/SimpleXML.phan_php create mode 100644 .phan/stubs/apc.phan_php create mode 100644 .phan/stubs/apcu.phan_php create mode 100644 .phan/stubs/ast.phan_php create mode 100644 .phan/stubs/bcmath.phan_php create mode 100644 .phan/stubs/brotli.phan_php create mode 100644 .phan/stubs/calendar.phan_php create mode 100644 .phan/stubs/ctype.phan_php create mode 100644 .phan/stubs/curl.phan_php create mode 100644 .phan/stubs/date.phan_php create mode 100644 .phan/stubs/dom.phan_php create mode 100644 .phan/stubs/exif.phan_php create mode 100644 .phan/stubs/fileinfo.phan_php create mode 100644 .phan/stubs/filter.phan_php create mode 100644 .phan/stubs/ftp.phan_php create mode 100644 .phan/stubs/gd.phan_php create mode 100644 .phan/stubs/gettext.phan_php create mode 100644 .phan/stubs/hash.phan_php create mode 100644 .phan/stubs/iconv.phan_php create mode 100644 .phan/stubs/igbinary.phan_php create mode 100644 .phan/stubs/imap.phan_php create mode 100644 .phan/stubs/intl.phan_php create mode 100644 .phan/stubs/json.phan_php create mode 100644 .phan/stubs/ldap.phan_php create mode 100644 .phan/stubs/libxml.phan_php create mode 100644 .phan/stubs/mailparse.phan_php create mode 100644 .phan/stubs/mbstring.phan_php create mode 100644 .phan/stubs/mcrypt.phan_php create mode 100644 .phan/stubs/memcache.phan_php create mode 100644 .phan/stubs/memcached.phan_php create mode 100644 .phan/stubs/mongodb.phan_php create mode 100644 .phan/stubs/mysqli.phan_php create mode 100644 .phan/stubs/mysqlnd.phan_php create mode 100644 .phan/stubs/openssl.phan_php create mode 100644 .phan/stubs/pcntl.phan_php create mode 100644 .phan/stubs/pcre.phan_php create mode 100644 .phan/stubs/pdo_cubrid.phan_php create mode 100644 .phan/stubs/pdo_mysql.phan_php create mode 100644 .phan/stubs/pdo_pgsql.phan_php create mode 100644 .phan/stubs/pdo_sqlite.phan_php create mode 100644 .phan/stubs/pgsql.phan_php create mode 100644 .phan/stubs/posix.phan_php create mode 100644 .phan/stubs/random.phan_php create mode 100644 .phan/stubs/readline.phan_php create mode 100644 .phan/stubs/redis.phan_php create mode 100644 .phan/stubs/session.phan_php create mode 100644 .phan/stubs/shmop.phan_php create mode 100644 .phan/stubs/soap.phan_php create mode 100644 .phan/stubs/sockets.phan_php create mode 100644 .phan/stubs/sodium.phan_php create mode 100644 .phan/stubs/sqlite3.phan_php create mode 100644 .phan/stubs/standard.phan_php create mode 100644 .phan/stubs/sysvmsg.phan_php create mode 100644 .phan/stubs/sysvsem.phan_php create mode 100644 .phan/stubs/sysvshm.phan_php create mode 100644 .phan/stubs/tokenizer.phan_php create mode 100644 .phan/stubs/xdebug.phan_php create mode 100644 .phan/stubs/xml.phan_php create mode 100644 .phan/stubs/xmlreader.phan_php create mode 100644 .phan/stubs/xmlwriter.phan_php create mode 100644 .phan/stubs/xsl.phan_php create mode 100644 .phan/stubs/yaml.phan_php create mode 100644 .phan/stubs/zip.phan_php create mode 100644 .phan/stubs/zlib.phan_php create mode 100644 runPhan.sh diff --git a/.github/workflows/phan.yml b/.github/workflows/phan.yml new file mode 100644 index 0000000000000..8fdfeeb3ccfff --- /dev/null +++ b/.github/workflows/phan.yml @@ -0,0 +1,32 @@ +--- +on: [pull_request, push] +name: phan +jobs: + phan: + name: Run phan + runs-on: ubuntu-latest + container: + image: phanphp/phan:latest + steps: + - name: Link paths + shell: sh + run: | + ln -s $GITHUB_WORKSPACE /mnt/src + apk add git + + - name: Checkout + uses: actions/checkout@v4 + + - name: Run Phan + run: | + cd /mnt/src + set -o pipefail + /opt/phan/phan --quick -k .phan/config.php -B .phan/baseline.txt --analyze-twice --minimum-target-php-version 7.1 | tee phan.log + + - name: Provide phan log as artifact + uses: actions/upload-artifact@v3 + if: ${{ always() }} + with: + name: phan-srcrt + path: ${{ github.workspace }}/phan.log + retention-days: 5 diff --git a/.phan/baseline.txt b/.phan/baseline.txt new file mode 100644 index 0000000000000..dec9ff344ebce --- /dev/null +++ b/.phan/baseline.txt @@ -0,0 +1,78 @@ + [ + 'htdocs/core/lib/functions.lib.php' => ['PhanPluginDuplicateArrayKey',], + 'htdocs/core/lib/functions2.lib.php' => ['PhanParamSuspiciousOrder',], + 'htdocs/core/menus/standard/auguria_menu.php' => ['PhanParamSuspiciousOrder',], + 'htdocs/core/menus/standard/eldy_menu.php' => ['PhanParamSuspiciousOrder',], + 'htdocs/core/menus/standard/empty.php' => ['PhanParamSuspiciousOrder',], + 'htdocs/core/modules/syslog/mod_syslog_file.php' => ['PhanParamSuspiciousOrder',], + 'htdocs/accountancy/class/lettering.class.php' => ['PhanParamSuspiciousOrder',], + 'htdocs/install/fileconf.php' => ['PhanParamSuspiciousOrder',], + 'htdocs/expedition/class/expedition.class.php' => ['PhanUndeclaredVariable',], + 'htdocs/debugbar/class/DataCollector/DolPhpCollector.php' => ['PhanPowerOfZero',], + 'htdocs/core/db/DoliDB.class.php' => ['PhanUndeclaredTypeProperty',], + 'htdocs/public/payment/newpayment.php' => ['PhanUndeclaredClassCatch',], + 'htdocs/stripe/class/stripe.class.php' => ['PhanUndeclaredClassCatch',], + 'htdocs/core/class/dolgeoip.class.php' => ['PhanUndeclaredFunction',], + 'htdocs/bom/tpl/objectline_create.tpl.php'=>['PhanUndeclaredThis',], + 'htdocs/bom/tpl/objectline_edit.tpl.php'=>['PhanUndeclaredThis',], + 'htdocs/bom/tpl/objectline_view.tpl.php'=>['PhanUndeclaredThis',], + 'htdocs/core/commonfieldsinexport.inc.php'=>['PhanUndeclaredThis',], + 'htdocs/core/commonfieldsinimport.inc.php'=>['PhanUndeclaredThis',], + 'htdocs/core/extrafieldsinexport.inc.php'=>['PhanUndeclaredThis',], + 'htdocs/core/extrafieldsinimport.inc.php'=>['PhanUndeclaredThis',], + 'htdocs/core/tpl/objectline_create.tpl.php'=>['PhanUndeclaredThis',], + 'htdocs/core/tpl/objectline_edit.tpl.php'=>['PhanUndeclaredThis',], + 'htdocs/core/tpl/objectline_title.tpl.php'=>['PhanUndeclaredThis',], + 'htdocs/core/tpl/objectline_view.tpl.php'=>['PhanUndeclaredThis',], + 'htdocs/core/tpl/originproductline.tpl.php'=>['PhanUndeclaredThis',], + 'htdocs/hrm/core/tpl/objectline_view.tpl.php'=>['PhanUndeclaredThis',], + 'htdocs/mrp/tpl/originproductline.tpl.php'=>['PhanUndeclaredThis',], + 'htdocs/variants/tpl/productattributevalueline_create.tpl.php'=>['PhanUndeclaredThis',], + 'htdocs/variants/tpl/productattributevalueline_view.tpl.php'=>['PhanUndeclaredThis',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page179.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page180.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page181.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page182.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page183.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page184.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page185.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page186.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page187.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page188.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page189.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page190.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page191.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page192.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page193.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page194.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-corporate/containers/page195.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/page202.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-homesubmenu/containers/styles.css.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-noimg/containers/page80.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/page148.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-onepageblackpurple/containers/styles.css.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-restaurant/containers/page248.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-restaurant/containers/page249.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-restaurant/containers/page252.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-restaurant/containers/page253.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-restaurant/containers/styles.css.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-stellar/containers/page20.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-stellar/containers/page22.tpl.php'=>['PhanPluginWhitespaceTrailing',], + 'htdocs/install/doctemplates/websites/website_template-stellar/containers/styles.css.php'=>['PhanPluginWhitespaceTrailing',], + ], + // 'directory_suppressions' => ['src/directory_name' => ['PhanIssueName1', 'PhanIssueName2']] can be manually added if needed. + // (directory_suppressions will currently be ignored by subsequent calls to --save-baseline, but may be preserved in future Phan releases) +]; diff --git a/.phan/config.php b/.phan/config.php new file mode 100644 index 0000000000000..18643a4ae914f --- /dev/null +++ b/.phan/config.php @@ -0,0 +1,363 @@ + 6, + 'backward_compatibility_checks' => false, + 'simplify_ast'=>true, + 'analyzed_file_extensions' => ['php','inc'], + + // Supported values: `'5.6'`, `'7.0'`, `'7.1'`, `'7.2'`, `'7.3'`, `'7.4'`, `null`. + // If this is set to `null`, + // then Phan assumes the PHP version which is closest to the minor version + // of the php executable used to execute Phan. + //"target_php_version" => null, + "target_php_version" => '8.2', + //"target_php_version" => '7.3', + //"target_php_version" => '5.6', + + // 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' => [ + 'htdocs', + ], + + // 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 `exclude_analysis_directory_list`. + "exclude_analysis_directory_list" => [ + '.', + 'htdocs/includes/', + ], + //'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@', + 'exclude_file_regex' => '@^(' + .'dummy' + .'|htdocs/.*/class/api_.*' + .'|htdocs/.*/canvas/.*/tpl/.*.tpl.php' + .'|htdocs/modulebuilder/template/.*' + .')@', + + + + // A list of plugin files to execute. + // Plugins which are bundled with Phan can be added here by providing their name + // (e.g. 'AlwaysReturnPlugin') + // + // Documentation about available bundled plugins can be found + // at https://github.com/phan/phan/tree/master/.phan/plugins + // + // Alternately, you can pass in the full path to a PHP file + // with the plugin's implementation (e.g. 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php') + 'plugins' => [ + // checks if a function, closure or method unconditionally returns. + // can also be written as 'vendor/phan/phan/.phan/plugins/AlwaysReturnPlugin.php' + //'DeprecateAliasPlugin', + //'EmptyMethodAndFunctionPlugin', + 'InvalidVariableIssetPlugin', + //'MoreSpecificElementTypePlugin', + 'NoAssertPlugin', + 'NotFullyQualifiedUsagePlugin', + //'PHPDocRedundantPlugin', + 'PHPUnitNotDeadCodePlugin', + //'PossiblyStaticMethodPlugin', + 'PreferNamespaceUsePlugin', + 'PrintfCheckerPlugin', + 'RedundantAssignmentPlugin', + + 'ConstantVariablePlugin', // Warns about values that are actually constant + //'HasPHPDocPlugin', // Requires PHPDoc + 'InlineHTMLPlugin', // html in PHP file, or at end of file + //'NonBoolBranchPlugin', // Requires test on bool, nont on ints + //'NonBoolInLogicalArithPlugin', + 'NumericalComparisonPlugin', + //'PHPDocToRealTypesPlugin', + 'PHPDocInWrongCommentPlugin', // Missing /** (/* was used) + //'ShortArrayPlugin', // Checks that [] is used + //'StrictLiteralComparisonPlugin', + 'UnknownClassElementAccessPlugin', + 'UnknownElementTypePlugin', + 'WhitespacePlugin', + //'RemoveDebugStatementPlugin', // Reports echo, print, ... + //'SimplifyExpressionPlugin', + //'StrictComparisonPlugin', // Expects === + //'SuspiciousParamOrderPlugin', + 'UnsafeCodePlugin', + //'UnusedSuppressionPlugin', + + 'AlwaysReturnPlugin', + //'DollarDollarPlugin', + 'DuplicateArrayKeyPlugin', + 'DuplicateExpressionPlugin', + 'PregRegexCheckerPlugin', + 'PrintfCheckerPlugin', + 'SleepCheckerPlugin', + // Checks for syntactically unreachable statements in + // the global scope or function bodies. + 'UnreachableCodePlugin', + 'UseReturnValuePlugin', + 'EmptyStatementListPlugin', + 'LoopVariableReusePlugin', + ], + + // Add any issue types (such as 'PhanUndeclaredMethod') + // here to inhibit them from being reported + 'suppress_issue_types' => [ + // Dolibarr uses a lot of internal deprecated stuff, not reporting + 'PhanDeprecatedProperty', + 'PhanDeprecatedFunction', + // Nulls are likely mostly false positives + 'PhanPluginConstantVariableNull', + 'PhanTypeObjectUnsetDeclaredProperty', + 'PhanPluginComparisonNotStrictForScalar', + 'PhanPluginNonBoolBranch', + 'PhanPluginShortArray', + 'PhanPluginNumericalComparison', + 'PhanPluginUnknownObjectMethodCall', + 'PhanPluginCanUseParamType', + 'PhanPluginNonBoolInLogicalArith', + 'PhanPluginCanUseReturnType', + 'PhanPluginNotFullyQualifiedFunctionCall', + 'PhanPluginConstantVariableScalar', + 'PhanPluginNoCommentOnPublicProperty', + 'PhanPluginUnknownPropertyType', + 'PhanPluginUnknownMethodParamType', + 'PhanPluginNotFullyQualifiedOptimizableFunctionCall', + 'PhanPluginUnknownMethodReturnType', + 'PhanPluginUnknownArrayMethodParamType', + 'PhanPluginWhitespaceTab', + 'PhanPluginCanUsePHP71Void', + 'PhanPluginUnknownArrayMethodReturnType', + 'PhanTypeMismatchArgumentInternal', + 'PhanPluginDuplicateAdjacentStatement', + 'PhanPluginCanUseNullableParamType', + 'PhanTypeInvalidLeftOperandOfNumericOp', + 'PhanTypeMismatchProperty', + 'PhanPluginNoCommentOnPublicMethod', + 'PhanRedefinedClassReference', + 'PhanPluginNoCommentOnClass', + 'PhanPluginNotFullyQualifiedGlobalConstant', + 'PhanTypeMismatchDefault', + 'PhanPluginPHPDocHashComment', + 'PhanPluginShortArrayList', + 'PhanPluginUnknownArrayPropertyType', + 'PhanTypeInvalidDimOffset', + 'PhanPluginNoCommentOnProtectedProperty', + 'PhanPluginDescriptionlessCommentOnPublicMethod', + 'PhanPluginUnknownClosureParamType', + 'PhanPluginUnknownClosureReturnType', + 'PhanPluginNoCommentOnProtectedMethod', + 'PhanTypeArraySuspicious', + 'PhanTypeMismatchPropertyProbablyReal', + 'PhanPluginNoCommentOnPrivateMethod', + 'PhanPluginUnknownArrayFunctionReturnType', + 'PhanTypeInvalidLeftOperandOfAdd', + 'PhanPluginNoCommentOnPrivateProperty', + 'PhanPluginNoCommentOnFunction', + 'PhanPluginCanUseNullableReturnType', + 'PhanPluginUnknownArrayFunctionParamType', + 'PhanPluginDescriptionlessCommentOnPublicProperty', + 'PhanPluginUnknownFunctionParamType', + 'PhanTypeSuspiciousStringExpression', + 'PhanPluginRedundantAssignment', + 'PhanTypeExpectedObjectPropAccess', + 'PhanTypeInvalidRightOperandOfNumericOp', + 'PhanPluginInlineHTML', + 'PhanPluginUnknownFunctionReturnType', + 'PhanPluginDescriptionlessCommentOnProtectedProperty', + 'PhanPluginRedundantAssignmentInGlobalScope', + 'PhanTypeMismatchDeclaredParamNullable', + 'PhanTypeInvalidRightOperandOfAdd', + 'PhanPluginDescriptionlessCommentOnPrivateProperty', + 'PhanUndeclaredVariableDim', // Array initialisation on undeclared var: $abc['x']='ab' + 'PhanTypeInvalidPropertyName', + 'PhanPluginDuplicateCatchStatementBody', + 'PhanPluginUndeclaredVariableIsset', + 'PhanTypeInvalidUnaryOperandIncOrDec', + 'PhanPluginDescriptionlessCommentOnClass', + 'PhanPluginEmptyStatementIf', + 'PhanPluginInlineHTMLTrailing', + 'PhanUndeclaredStaticMethod', + 'PhanPluginDescriptionlessCommentOnPrivateMethod', + 'PhanPluginPrintfIncompatibleArgumentType', + 'PhanPossiblyNullTypeMismatchProperty', + 'PhanRedefineClass', + 'PhanRedefineFunction', + 'PhanTypeInvalidLeftOperandOfBitwiseOp', + 'PhanTypeMismatchDimAssignment', + 'PhanPluginDescriptionlessCommentOnProtectedMethod', + 'PhanPluginPrintfIncompatibleArgumentTypeWeak', + 'PhanUndeclaredVariableAssignOp', + 'PhanTypeExpectedObjectOrClassName', + 'PhanEmptyFQSENInClasslike', + 'PhanTypeMismatchArgumentInternalReal', + 'PhanUnextractableAnnotationElementName', + 'PhanCommentParamWithoutRealParam', + 'PhanRedefinedExtendedClass', + 'PhanTypeComparisonFromArray', + 'PhanPluginConstantVariableBool', + 'PhanPluginPrintfVariableFormatString', + 'PhanTypeMismatchDimFetch', + 'PhanTypeMismatchDimFetchNullable', + 'PhanTypeSuspiciousNonTraversableForeach', + 'PhanEmptyForeach', + 'PhanTypeInvalidRightOperandOfBitwiseOp', + 'PhanPluginDuplicateConditionalUnnecessary', + 'PhanTraitParentReference', + 'PhanPluginBothLiteralsBinaryOp', + 'PhanTypeMismatchDeclaredParam', + 'PhanCommentDuplicateMagicMethod', + 'PhanParamSpecial1', + 'PhanPluginInlineHTMLLeading', + 'PhanPluginUseReturnValueInternalKnown', + 'PhanRedefinedInheritedInterface', + 'PhanTypeComparisonToArray', + 'PhanTypeConversionFromArray', + 'PhanTypeInvalidLeftOperandOfIntegerOp', + 'PhanTypeMismatchArgumentInternalProbablyReal', + 'PhanTypeMismatchBitwiseBinaryOperands', + 'PhanTypeMismatchDimEmpty', + 'PhanTypeSuspiciousEcho', + 'PhanNoopBinaryOperator', + 'PhanTypeInvalidBitwiseBinaryOperator', + 'PhanPluginDescriptionlessCommentOnFunction', + 'PhanPluginPHPDocInWrongComment', + 'PhanRedefineClassInternal', + 'PhanTypeInvalidThrowsIsInterface', + 'PhanPluginRedundantAssignmentInLoop', + 'PhanInvalidCommentForDeclarationType', + 'PhanParamSignatureMismatchInternal', + 'PhanPluginEmptyStatementForeachLoop', + 'PhanCompatibleDimAlternativeSyntax', + 'PhanInvalidFQSENInClasslike', + 'PhanMismatchVariadicComment', + 'PhanNoopConstant', + 'PhanPluginUnknownArrayClosureParamType', + 'PhanTypeInstantiateAbstractStatic', + 'PhanEmptyForeachBody', + 'PhanPluginEmptyStatementWhileLoop', + 'PhanSyntaxReturnValueInVoid', + 'PhanTypeInstantiateTraitStaticOrSelf', + 'PhanUndeclaredInvokeInCallable', + 'PhanNoopProperty', + 'PhanNoopVariable', + 'PhanPluginPrintfUnusedArgument', + 'PhanSyntaxReturnExpectedValue', + 'PhanAccessClassInternal', + 'PhanCompatibleAccessMethodOnTraitDefinition', + 'PhanNoopSwitchCases', + 'PhanNoopTernary', + 'PhanNoopUnaryOperator', + 'PhanParamNameIndicatingUnusedInClosure', + 'PhanParamSignatureRealMismatchTooFewParametersInternal', + 'PhanPluginEmptyStatementSwitch', + 'PhanPossiblyUnsetPropertyOfThis', + 'PhanTypeInvalidLeftOperand', + 'PhanTypeInvalidRightOperand', + 'PhanTypeInvalidRightOperandOfIntegerOp', + 'PhanTypeMismatchArgumentReal', + 'PhanTypeMismatchDeclaredReturnNullable', + + //'PhanUndeclaredThis', + 'PhanPluginMixedKeyNoKey', + 'PhanPluginDuplicateConditionalNullCoalescing', // Suggests to optimize to ?? + //'PhanUnreferencedClosure', // False positives seen with closures in arrays, TODO: move closure checks closer to what is done by unused variable plugin + //'PhanPluginNoCommentOnProtectedMethod', + //'PhanPluginDescriptionlessCommentOnProtectedMethod', + //'PhanPluginNoCommentOnPrivateMethod', + //'PhanPluginDescriptionlessCommentOnPrivateMethod', + //'PhanPluginDescriptionlessCommentOnPrivateProperty', + // TODO: Fix edge cases in --automatic-fix for PhanPluginRedundantClosureComment + //'PhanPluginRedundantClosureComment', + 'PhanPluginPossiblyStaticPublicMethod', + //'PhanPluginPossiblyStaticProtectedMethod', + + // The types of ast\Node->children are all possibly unset. + 'PhanTypePossiblyInvalidDimOffset', // Also checks optional array keys and requires that they are checked for existence. + 'PhanUndeclaredGlobalVariable', + 'PhanUndeclaredProperty', + 'PhanPluginPrintfNotPercent', + 'PhanPossiblyUndeclaredGlobalVariable', + 'PhanPluginPossiblyStaticProtectedMethod', + 'PhanTypeMismatchReturn', + 'PhanPluginMoreSpecificActualReturnType', + 'PhanTypeMismatchReturnProbablyReal', + 'PhanPossiblyUndeclaredVariable', + 'PhanTypeMismatchArgument', + //'PhanPluginUnreachableCode', + //'PhanTypeMismatchArgumentInternal', + //'PhanPluginAlwaysReturnMethod', + 'PhanUndeclaredClassMethod', + 'PhanUndeclaredMethod', + 'PhanTypeMismatchArgumentProbablyReal', + 'PhanPluginDuplicateExpressionAssignmentOperation', + 'PhanTypeMismatchPropertyDefault', + 'PhanPluginAlwaysReturnMethod', + 'PhanPluginMissingReturnMethod', + 'PhanUndeclaredTypeReturnType', + 'PhanUndeclaredClassProperty', + 'PhanTypeArraySuspiciousNullable', + 'PhanPluginInconsistentReturnMethod', + 'PhanTypeExpectedObjectPropAccessButGotNull', + 'PhanUndeclaredClassAttribute', + 'PhanNonClassMethodCall', + 'PhanPluginNoAssert', + 'PhanTypeMismatchReturnSuperType', + 'PhanTypeMismatchArgumentSuperType', + 'PhanPluginDuplicateConditionalTernaryDuplication', + ], + // You can put relative paths to internal stubs in this config option. + // Phan will continue using its detailed type annotations, + // but load the constants, classes, functions, and classes (and their Reflection types) + // from these stub files (doubling as valid php files). + // Use a different extension from php (and preferably a separate folder) + // to avoid accidentally parsing these as PHP (includes projects depending on this). + // The 'mkstubs' script can be used to generate your own stubs (compatible with php 7.0+ right now) + // Note: The array key must be the same as the extension name reported by `php -m`, + // so that phan can skip loading the stubs if the extension is actually available. + 'autoload_internal_extension_signatures' => [ + // Xdebug stubs are bundled with Phan 0.10.1+/0.8.9+ for usage, + // because Phan disables xdebug by default. + //'xdebug' => 'vendor/phan/phan/.phan/internal_stubs/xdebug.phan_php', + //'memcached' => '.phan/your_internal_stubs_folder_name/memcached.phan_php', + 'PDO' => '.phan/stubs/PDO.phan_php', + 'brotli' => '.phan/stubs/brotli.phan_php', + 'curl' => '.phan/stubs/curl.phan_php', + 'calendar' => '.phan/stubs/calendar.phan_php', + 'fileinfo' => '.phan/stubs/fileinfo.phan_php', + 'ftp' => '.phan/stubs/ftp.phan_php', + 'gd' => '.phan/stubs/gd.phan_php', + 'imap' => '.phan/stubs/imap.phan_php', + 'intl' => '.phan/stubs/intl.phan_php', + 'ldap' => '.phan/stubs/ldap.phan_php', + 'mcrypt' => '.phan/stubs/mcrypt.phan_php', + 'memcache' => '.phan/stubs/memcache.phan_php', + 'mysqli' => '.phan/stubs/mysqli.phan_php', + 'pdo_cubrid' => '.phan/stubs/pdo_cubrid.phan_php', + 'pdo_mysql' => '.phan/stubs/pdo_mysql.phan_php', + 'pdo_pgsql' => '.phan/stubs/pdo_pgsql.phan_php', + 'pdo_sqlite' => '.phan/stubs/pdo_sqlite.phan_php', + 'session' => '.phan/stubs/session.phan_php', + 'simplexml' => '.phan/stubs/SimpleXML.phan_php', + 'soap' => '.phan/stubs/soap.phan_php', + 'sockets' => '.phan/stubs/sockets.phan_php', + 'zip' => '.phan/stubs/zip.phan_php', + ], + +]; diff --git a/.phan/stubs/Core.phan_php b/.phan/stubs/Core.phan_php new file mode 100644 index 0000000000000..d2f722d1762e5 --- /dev/null +++ b/.phan/stubs/Core.phan_php @@ -0,0 +1,333 @@ +