From cd7acd26143eb4094ddd9562f9df22226d6132ea Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 13 Jul 2021 16:19:22 -0700 Subject: [PATCH 1/5] Improve PHPStan config --- phpstan.neon.dist | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 7ab289eb4..f7b2599b5 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -5,28 +5,17 @@ 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)\.$#' From 2ebcd0299a2fda89ace675af03ddab71b8dc6358 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 13 Jul 2021 18:14:16 -0700 Subject: [PATCH 2/5] Check static analysis when phpstan or phpunit configs change --- .github/workflows/build-test-measure.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-test-measure.yml b/.github/workflows/build-test-measure.yml index 54d74ccdb..05717da4a 100644 --- a/.github/workflows/build-test-measure.yml +++ b/.github/workflows/build-test-measure.yml @@ -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" From 9f27e0b20b27202974449c789cc2c8400c7b8a6e Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 13 Jul 2021 21:59:56 -0700 Subject: [PATCH 3/5] Add missing php-stubs --- phpstan.neon.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index f7b2599b5..6833fe575 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -12,6 +12,7 @@ parameters: - %currentWorkingDirectory%/integrations bootstrapFiles: - %currentWorkingDirectory%/tests/static-analysis-stubs/wordpress-defines.stub + - %currentWorkingDirectory%/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php dynamicConstantNames: - SCRIPT_DEBUG ignoreErrors: From 51d6667e0ae366862ba4cce89e8e70aa162d2f48 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 13 Jul 2021 22:05:29 -0700 Subject: [PATCH 4/5] Add pwa.php to bootstrapFiles --- phpstan.neon.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 6833fe575..9be1b3648 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -11,6 +11,7 @@ parameters: - %currentWorkingDirectory%/bundled-theme-support - %currentWorkingDirectory%/integrations bootstrapFiles: + - %currentWorkingDirectory%/pwa.php - %currentWorkingDirectory%/tests/static-analysis-stubs/wordpress-defines.stub - %currentWorkingDirectory%/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php dynamicConstantNames: From 9d10a31ca82c9ced468689cee837cbf9a3d11fc4 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 13 Jul 2021 22:18:57 -0700 Subject: [PATCH 5/5] Move constants from pwa.php to wordpress-defines.stub --- phpstan.neon.dist | 1 - tests/static-analysis-stubs/wordpress-defines.stub | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 9be1b3648..6833fe575 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -11,7 +11,6 @@ parameters: - %currentWorkingDirectory%/bundled-theme-support - %currentWorkingDirectory%/integrations bootstrapFiles: - - %currentWorkingDirectory%/pwa.php - %currentWorkingDirectory%/tests/static-analysis-stubs/wordpress-defines.stub - %currentWorkingDirectory%/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php dynamicConstantNames: diff --git a/tests/static-analysis-stubs/wordpress-defines.stub b/tests/static-analysis-stubs/wordpress-defines.stub index a326c6c05..e1efd3beb 100644 --- a/tests/static-analysis-stubs/wordpress-defines.stub +++ b/tests/static-analysis-stubs/wordpress-defines.stub @@ -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/' );