Skip to content

Commit 5396b85

Browse files
neildanielsclaude
andcommitted
Use baseline reportUnmatched for both method_exists outcomes
PHPStan analyzes against the single installed OptionsResolver version on each CI job, so the method_exists() guard appears tautological as either "always true" (>= 7.3 on PHP 8.2+) or "always false" (< 7.3 on PHP 7.4- 8.1) with different identifiers per outcome. Inline @PHPStan-Ignore treats every listed identifier as required, so the non-firing one trips reportUnmatchedIgnoredErrors. Use the baseline form with reportUnmatched: false on both entries, so whichever fires gets silenced and the other entry quietly does nothing. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4802c97 commit 5396b85

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

lib/Tmdb/Client.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,9 @@ protected function configureOptions(array $options)
146146

147147
// symfony/options-resolver 8.0 removed nested-options-via-Closure passed to setDefaults();
148148
// setOptions() is the replacement, available from 7.3. The runtime guard supports older
149-
// versions still allowed by composer.json; PHPStan resolves against the installed version.
150-
// @phpstan-ignore function.alreadyNarrowedType, function.impossibleType
149+
// versions still allowed by composer.json; PHPStan tautology errors are silenced in
150+
// phpstan-baseline.neon for both true and false outcomes (analysis runs against a single
151+
// installed OptionsResolver version, but the guard is genuine across the supported range).
151152
if (method_exists($resolver, 'setOptions')) {
152153
$resolver->setOptions('http', $http);
153154
$resolver->setOptions('hydration', $hydration);

phpstan-baseline.neon

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ parameters:
1818
count: 1
1919
path: lib/Tmdb/Event/Listener/Logger/LogHttpMessageListener.php
2020

21+
# The method_exists(setOptions) guard supports symfony/options-resolver versions both
22+
# with and without the method. PHPStan resolves against the installed version on each
23+
# CI job, so exactly one of these two outcomes fires per job; reportUnmatched silences
24+
# the other.
25+
-
26+
rawMessage: "Call to function method_exists() with Symfony\\Component\\OptionsResolver\\OptionsResolver and 'setOptions' will always evaluate to true."
27+
identifier: function.alreadyNarrowedType
28+
reportUnmatched: false
29+
path: lib/Tmdb/Client.php
30+
31+
-
32+
rawMessage: "Call to function method_exists() with Symfony\\Component\\OptionsResolver\\OptionsResolver and 'setOptions' will always evaluate to false."
33+
identifier: function.impossibleType
34+
reportUnmatched: false
35+
path: lib/Tmdb/Client.php
36+
2137
-
2238
rawMessage: 'Parameter #3 $first of method Http\Client\Common\Plugin\AbstractCachePlugin::handleRequest() expects callable(Psr\Http\Message\RequestInterface): Http\Promise\Promise, Closure(): void given.'
2339
identifier: argument.type

0 commit comments

Comments
 (0)