From 3607ba7fb04b1081629c2cd653df3c03e1b25c2e Mon Sep 17 00:00:00 2001 From: Robert O'Rourke Date: Thu, 25 Jul 2024 15:25:18 +0100 Subject: [PATCH] Fix PHPStan errors --- .github/workflows/php-standards.yml | 4 ++-- inc/cli/namespace.php | 1 - inc/namespace.php | 10 +++++----- phpstan.neon.dist | 3 +++ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/php-standards.yml b/.github/workflows/php-standards.yml index f9f9f9b..fbb7380 100644 --- a/.github/workflows/php-standards.yml +++ b/.github/workflows/php-standards.yml @@ -38,7 +38,7 @@ jobs: uses: actions/cache@v4 with: path: ${{ steps.composer-cache-dir.outputs.DIR }} - key: ${{ runner.os }}-composer-7.2-${{ hashFiles('composer.lock') }} + key: ${{ runner.os }}-composer-7.4-${{ hashFiles('composer.lock') }} - name: Install PHP Dependencies run: | @@ -48,7 +48,7 @@ jobs: uses: actions/cache@v4 with: path: tests/cache - key: ${{ runner.os }}-phpcs-7.2-${{ hashFiles('plugin.php') }} + key: ${{ runner.os }}-phpcs-7.4-${{ hashFiles('plugin.php') }} - name: Run the tests run: | diff --git a/inc/cli/namespace.php b/inc/cli/namespace.php index 35d70eb..5d5697e 100644 --- a/inc/cli/namespace.php +++ b/inc/cli/namespace.php @@ -17,6 +17,5 @@ * @return void */ function bootstrap() : void { - // @phpstan-ignore-next-line WP_CLI::add_command( 'authorship migrate', __NAMESPACE__ . '\\Migrate_Command' ); } diff --git a/inc/namespace.php b/inc/namespace.php index 6b5524d..f327cb5 100644 --- a/inc/namespace.php +++ b/inc/namespace.php @@ -760,11 +760,11 @@ function filter_comment_notification_recipients( array $emails, int $comment_id * Bit of a hack, but filter filter_quickedit_authors and include only author with ID 0. * Also hide if only one author just in case someone someone has created author with 0. * - * @param array $options Options. - * @return array Options. + * @param array $options Options. + * @return array Filtered options. */ function hide_quickedit_authors( array $options ) : array { - $users_opt['hide_if_only_one_author'] = true; - $users_opt['include'] = [ 0 ]; - return $users_opt; + $options['hide_if_only_one_author'] = true; + $options['include'] = [ 0 ]; + return $options; } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 360bc97..816da47 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -26,3 +26,6 @@ parameters: ignoreErrors: # Uses func_get_args() - '#^Function apply_filters invoked with [34567] parameters, 2 required\.$#' + # Cant declare types always because extended + # core parent class methods don't + checkGenericClassInNonGenericObjectType: false