Minor PHPStan warnings in FilteredStorage and FilteredStorageTest

Created on 13 May 2025, 3 days ago

Problem/Motivation

Problem/Motivation

While running PHPStan with level max (or next minor), the following warnings were found in the config_filter module:

Line 47 - src/Config/FilteredStorage.php
Instanceof between Drupal\config_filter\Config\StorageFilterInterface and itself will always evaluate to true.
🪪 instanceof.alwaysTrue
šŸ’” This comes from a PHPDoc. To silence, set treatPhpDocTypesAsCertain: false in phpstan.neon.

Line 409 - src/Tests/FilteredStorageTest.php
Call to method PHPUnit\Framework\Assert::assertTrue() with true will always evaluate to true.
🪪 method.alreadyNarrowedType

These are not causing any runtime errors but may indicate unnecessary or redundant logic and could be cleaned up for better code quality and static analysis results.

Steps to reproduce

  1. Clone the config_filter module (latest dev version).
  2. Run PHPStan with a configuration level of max or enable next minor.
  3. Observe the warnings listed above in the output.

Proposed resolution

FilteredStorage.php:

  1. Remove the unnecessary instanceof check or clarify its purpose with an inline comment.

FilteredStorageTest.php:

  1. Remove or replace the assertTrue(true) line if it provides no additional value for the test.

Remaining tasks

  • Confirm that these changes do not affect existing test coverage.
  • Create merge request with the proposed fixes.
  • Ensure PHPStan and PHPUnit tests pass.

User interface changes

None.

API changes

None.

Data model changes

None.

šŸ“Œ Task
Status

Active

Version

2.0

Component

Code

Created by

šŸ‡§šŸ‡·Brazil brandonlira

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024