Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve PHPStan config #563

Merged
merged 5 commits into from
Jul 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-test-measure.yml
Original file line number Diff line number Diff line change
@@ -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"
18 changes: 4 additions & 14 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

@szepeviktor szepeviktor Jul 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- %currentWorkingDirectory%/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php is necessary if you don't use my package

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@westonruter Now we are here :)

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
@@ -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/' );