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

NEW action PHPStan & 36 little 🐛 fixes #931

Merged
merged 40 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c2a12ea
NEW static analyze test PHPStan (for WordPress)
carstingaxion Oct 1, 2024
c9517df
NEW Github actions workflowe to run PHPStan
carstingaxion Oct 1, 2024
05d247c
Minor fix to prevent phpdoc.parseError
carstingaxion Oct 1, 2024
63b20e6
Use additional bleedingEdge config
carstingaxion Oct 1, 2024
6dab970
Fix: Parameter #1 $version1 of function version_compare expects strin…
carstingaxion Oct 3, 2024
7bdf65a
Fix: Parameter #1 $term_id of function wp_update_term expects int, st…
carstingaxion Oct 3, 2024
90b8a0b
Fix: Path in require_once() "./wp-admin/includes/upgrade.php" is not …
carstingaxion Oct 3, 2024
ffeecba
Fix: Call to sprintf contains 1 placeholder, 2 values given.
carstingaxion Oct 3, 2024
dd691e4
Fix: Parameter #1 $new_blog_id of function switch_to_blog expects int…
carstingaxion Oct 3, 2024
3a57156
Fix: Parameter #1 $term_id of function wp_update_term expects int, st…
carstingaxion Oct 3, 2024
e4ea845
Fix: Variable $suffix might not be defined.
carstingaxion Oct 3, 2024
684d1ec
Fix & Unit test: Method GatherPress\Core\Settings::sort_sub_pages_by_…
carstingaxion Oct 3, 2024
968ac3b
Fix: Parameter #3 $group of function wp_cache_set expects string, int…
carstingaxion Oct 3, 2024
3242163
Parameter #2 $callback of function usort expects callable(array, arra…
carstingaxion Oct 3, 2024
2ed2443
Revert "Fix: Parameter #3 $group of function wp_cache_set expects str…
carstingaxion Oct 3, 2024
c86472d
Fix: One or more @ param tags has an invalid name or invalid syntax.
carstingaxion Oct 3, 2024
0d4b8fd
Fix: Callback expects 1 parameter, $accepted_args is set to 2.
carstingaxion Oct 3, 2024
b237d92
Fix: Expression on left side of ?? is not nullable. (Because get_perm…
carstingaxion Oct 3, 2024
f0e15db
Fix: Parameter #1 $string of function str_pad expects string, int given.
carstingaxion Oct 3, 2024
b754286
Fix: Class WP_Comment referenced with incorrect case: WP_comment.
carstingaxion Oct 3, 2024
4125173
Fix: Filter callback return statement is missing.
carstingaxion Oct 3, 2024
511330d
Ignore CS warning: Universal.Operators.DisallowShortTernary.Found
carstingaxion Oct 3, 2024
33fcfeb
Fix: Instanceof between WP_Comment_Query and WP_Comment_Query will al…
carstingaxion Oct 3, 2024
df75ff9
Fix: Access to an undefined property WP_Comment_Query::$tax_query.
carstingaxion Oct 3, 2024
8b82f0f
Fix: Function wxr_cdata not found.
carstingaxion Oct 3, 2024
575719b
Add shortcut to run phpstan
carstingaxion Oct 3, 2024
ca595d5
Fix: Variable $option might not be defined.
carstingaxion Oct 3, 2024
6f36dc1
Fix: Result of function selected (void) is used. AND (Parameter #1 (v…
carstingaxion Oct 3, 2024
5685aad
Fix: Expression on left side of ?? is not nullable.
carstingaxion Oct 4, 2024
4b7c27f
Fix: Expression "$blocks" on a separate line does not do anything.
carstingaxion Oct 4, 2024
e58785e
Fix: Parameter #1 $comment_id of function get_comment_meta expects in…
carstingaxion Oct 4, 2024
0ad3a3e
Fix: Call to function is_wp_error() with int|string|false will always…
carstingaxion Oct 4, 2024
9d967fb
Fix: Offset 'approved' on array{approved: int, awaiting_moderation: i…
carstingaxion Oct 4, 2024
64f0271
Fix: Property WP_Query::$queried_object_id (int) does not accept string.
carstingaxion Oct 4, 2024
2c3585c
Fix: Property WP_Query::$is_post_type_archive (bool) does not accept …
carstingaxion Oct 4, 2024
ea4466e
Fix wp_cache_set argument.
mauteri Oct 4, 2024
30599f2
Fix return on method, fix cache bug, update unit tests.
mauteri Oct 4, 2024
b47a6ca
Small fixes.
mauteri Oct 4, 2024
aa69812
Name change.
mauteri Oct 4, 2024
c615cd5
Add ignore.
mauteri Oct 4, 2024
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
3 changes: 3 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ package-lock.json
phpcs.xml
phpcs.xml.dist
phpcs.ruleset.xml
phpstan.neon
phpstan.neon.dist
phpstan.stubs
phpunit.xml
phpunit.xml.dist
playwright.config.js
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/phpstan-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PHPStan Tests
on:
push:
branches:
- main
pull_request:
paths:
- '.github/workflows/phpstan-tests.yml'
- 'includes/**'
# - 'test/unit/php**'
# - '*.php'
- 'phpstan.neon.dist'
- 'composer.*'
jobs:
test-phpstan:
name: PHPStan for WordPress
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
# phpstan requires PHP 7.1+.
php-version: 7.4
extensions: dom, iconv, json, libxml, zip
coverage: none
tools: cs2pr

- name: Composer Install
run: composer install --optimize-autoloader --prefer-dist

- name: Log debug information
run: |
git --version
php --version
composer --version

- name: Running PHPStan Analyze
if: ${{ success() || failure() }}
run: |
vendor/bin/phpstan --version
vendor/bin/phpstan analyze -vv --memory-limit=2G --error-format=checkstyle | cs2pr
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typings
# Composer #
##########
vendor
phpstan.neon

# .wp-env #
##########
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"wp-coding-standards/wpcs": "*",
"phpcompatibility/phpcompatibility-wp": "*",
"phpunit/phpunit": "*",
"yoast/phpunit-polyfills": "*"
"yoast/phpunit-polyfills": "*",
"szepeviktor/phpstan-wordpress": "^1.3"
},
"suggest": {
"wp-cli/wp-cli-bundle": "Combines the most common WP-CLI commands, including the wp-cli/i18n-command which should be used to create translation-files."
Expand All @@ -28,7 +29,8 @@
"format": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --report=summary,source",
"lint": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --report=summary,source",
"lint:errors": "@lint -n",
"test": "@php ./vendor/phpunit/phpunit/phpunit"
"test": "@php ./vendor/phpunit/phpunit/phpunit",
"test:phpstan": "@php ./vendor/bin/phpstan analyze -vv --memory-limit=2G"
},
"config": {
"allow-plugins": {
Expand Down
247 changes: 246 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions gatherpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore

// Constants.
define( 'GATHERPRESS_CACHE_GROUP', 'gatherpress_cache' );
define( 'GATHERPRESS_CORE_FILE', __FILE__ );
define( 'GATHERPRESS_CORE_PATH', __DIR__ );
define( 'GATHERPRESS_CORE_URL', plugin_dir_url( __FILE__ ) );
Expand Down
3 changes: 1 addition & 2 deletions includes/core/classes/class-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ protected function setup_hooks(): void {
*/
public function add_global_object(): void {
?>
<script>window.GatherPress = <?php echo wp_json_encode( $this->localize( get_the_ID() ?? 0 ) ); ?></script>
<script>window.GatherPress = <?php echo wp_json_encode( $this->localize( intval( get_the_ID() ) ) ); ?></script>
<?php
}

Expand Down Expand Up @@ -385,7 +385,6 @@ protected function unregister_blocks(): array {

switch ( get_post_type() ) {
case Event::POST_TYPE:
$blocks;
break;
case Venue::POST_TYPE:
$blocks = array(
Expand Down
Loading
Loading