Skip to content

Commit

Permalink
Merge pull request #563 from GoogleChromeLabs/improve/phpstan
Browse files Browse the repository at this point in the history
Improve PHPStan config
  • Loading branch information
westonruter authored Jul 14, 2021
2 parents a1f9125 + 9d10a31 commit ed653ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test-measure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
echo -e "Modified files:\n$MODIFIED_FILES\n"
FILE_COUNT=$(php -f bin/determine-modified-files-count.php "$IGNORE_PATH_REGEX" "$MODIFIED_FILES" --invert)
PHP_FILE_COUNT=$(php -f bin/determine-modified-files-count.php ".+\.php|composer\.(json|lock)" "$MODIFIED_FILES")
PHP_FILE_COUNT=$(php -f bin/determine-modified-files-count.php ".+\.php|composer\.(json|lock)|phpstan\.neon\.dist|phpunit\.xml" "$MODIFIED_FILES")
JS_FILE_COUNT=$(php -f bin/determine-modified-files-count.php ".+\.(js|snap)|package\.(json|lock)" "$MODIFIED_FILES")
echo "Changed file count: $FILE_COUNT"
Expand Down
18 changes: 4 additions & 14 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,18 @@ parameters:
level: 5
inferPrivatePropertyTypeFromConstructor: true
paths:
- %currentWorkingDirectory%/pwa.php
- %currentWorkingDirectory%/wp-admin
- %currentWorkingDirectory%/wp-includes
- %currentWorkingDirectory%/bundled-theme-support
- %currentWorkingDirectory%/integrations
bootstrapFiles:
- %currentWorkingDirectory%/tests/static-analysis-stubs/wordpress-defines.stub
autoload_files:
- %currentWorkingDirectory%/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
- %currentWorkingDirectory%/tests/static-analysis-stubs/wordpress-defines.stub
- %currentWorkingDirectory%/pwa.php
dynamicConstantNames:
- SCRIPT_DEBUG
ignoreErrors:
# Uses func_get_args()
- '#^Function apply_filters(_ref_array)? invoked with [34567] parameters, 2 required\.$#'
# Dynamically set attributes which will be eventually declared on WP_Query.
- '#^Access to an undefined property WP_Query::\$is_offline\.#'
- '#^Access to an undefined property WP_Query::\$is_500\.#'
-
message: '#^Negated boolean expression is always true\.#'
path: integrations/functions.php
-
message: '#^If condition is always false\.#'
path: wp-includes/components/class-wp-service-worker-configuration-component.php
-
message: '#Left side of \|\| is always false\.#'
path: wp-includes/components/class-wp-service-worker-precaching-routes.php
- '#^Access to an undefined property WP_Query::\$(is_offline|is_500)\.$#'
7 changes: 7 additions & 0 deletions tests/static-analysis-stubs/wordpress-defines.stub
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ define( 'ARRAY_N', 'ARRAY_N' );
// Theme constants.
define( 'STYLESHEETPATH', '/app/themes/child/' );
define( 'TEMPLATEPATH', '/app/themes/parent/' );

// PWA plugin.
define( 'PWA_VERSION', '0.7.0-alpha' );
define( 'PWA_PLUGIN_FILE', '/app/plugins/pwa.php' );
define( 'PWA_PLUGIN_DIR', '/app/plugins' );
define( 'PWA_WORKBOX_VERSION', '6.1.5' );
define( 'PWA_PLUGIN_URL', 'https://example.com/wp-content/plugins/pwa/' );

0 comments on commit ed653ce

Please sign in to comment.