Skip to content

Comments

fix: phan and psalm and PHPStan issues#497

Open
Apoorva64 wants to merge 7 commits intoopen-telemetry:mainfrom
Apoorva64:fix/psalm-and-phan-issues
Open

fix: phan and psalm and PHPStan issues#497
Apoorva64 wants to merge 7 commits intoopen-telemetry:mainfrom
Apoorva64:fix/psalm-and-phan-issues

Conversation

@Apoorva64
Copy link

@Apoorva64 Apoorva64 commented Jan 7, 2026

This PR fixes the current PHP Psalm and Phan issues on main.


1. Psalm: src/Sampler/RuleBased/psalm.xml.dist

  • Issue: UndefinedInterfaceMethod is needed only for PHP 8.1. For newer PHP versions, Psalm reports:

    ERROR: UnusedIssueHandlerSuppression - /opentelemetry-php-contrib/src/Sampler/RuleBased/psalm.xml.dist:0:0 - Suppressed issue type "UndefinedInterfaceMethod" for /src/ComponentProvider/ was not thrown. (see https://psalm.dev/326)
    
  • Fix: Disable findUnusedIssueHandlerSuppression to prevent the “Suppression not used” error.
    Reference: [Psalm docs](https://psalm.dev/docs/running_psalm/issues/UnusedIssueHandlerSuppression/)


2. PHPStan: src/Sampler/RuleBased/phpstan.neon.dist

  • Issue: NodeParentInterface suppression is needed for PHP 8.1, but for newer versions, PHPStan reports:

    Error: Ignored error pattern #Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::.*# in path /home/runner/work/opentelemetry-php-contrib/opentelemetry-php-contrib/src/Sampler/RuleBased/src was not matched in reported errors.
    
  • Fix: Add reportUnmatchedIgnoredErrors: false.
    Reference: [PHPStan ignoring errors guide](https://phpstan.org/user-guide/ignoring-errors#reporting-unused-ignores)


3. Phan: src/SymfonyInstrumentation.php

  • Remove deprecated constant:

    TraceAttributes::EXCEPTION_ESCAPED => true
  • Reason:

    src/SymfonyInstrumentation.php:104 PhanDeprecatedClassConstant Reference to deprecated class constant \OpenTelemetry\SemConv\TraceAttributes::EXCEPTION_ESCAPED defined at vendor/open-telemetry/sem-conv/TraceAttributes.php:1492 (Deprecated because: {"note": "It's no longer recommended to record exceptions that are handled and do not escape the scope of a span.\n", "reason": "obsoleted"})
    

4. Psalm: Suppress unused function call

  • Issue: Psalm reports an unused function call for the terminate hook:

    src/SymfonyInstrumentation.php:110:9: UnusedFunctionCall: The call to opentelemetry\instrumentation\hook is not used (see https://psalm.dev/206)
    
  • Fix: Add an UnusedFunctionCall suppression for this line.


5. Dev Dependencies

  • Issue: Psalm cannot see certain classes in tests:

    Error: tests/Integration/SymfonyInstrumentationTest.php:37:13: UndefinedClass: Class, interface or enum named OpenTelemetry\Tests\Instrumentation\Symfony\tests\Integration\TraceResponsePropagator does not exist (see https://psalm.dev/019)
    
  • Fix: Add open-telemetry/opentelemetry-propagation-traceresponse as a dev dependency.

@Apoorva64 Apoorva64 marked this pull request as ready for review January 7, 2026 14:51
@Apoorva64 Apoorva64 requested a review from a team as a code owner January 7, 2026 14:51
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.48%. Comparing base (a3c02c8) to head (e7291e3).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #497      +/-   ##
============================================
- Coverage     83.46%   82.48%   -0.98%     
- Complexity     2330     2383      +53     
============================================
  Files           149      162      +13     
  Lines          8791     8959     +168     
============================================
+ Hits           7337     7390      +53     
- Misses         1454     1569     +115     
Flag Coverage Δ
Aws 93.37% <ø> (ø)
Context/Swoole 0.00% <ø> (ø)
Exporter/Instana 49.80% <ø> (ø)
Instrumentation/AwsSdk 82.00% <ø> (ø)
Instrumentation/CakePHP 20.42% <ø> (ø)
Instrumentation/CodeIgniter 79.31% <ø> (ø)
Instrumentation/Curl 86.88% <ø> (-0.28%) ⬇️
Instrumentation/Doctrine 92.82% <ø> (ø)
Instrumentation/ExtAmqp 88.80% <ø> (ø)
Instrumentation/ExtRdKafka 86.13% <ø> (ø)
Instrumentation/Guzzle 76.25% <ø> (ø)
Instrumentation/HttpAsyncClient 78.94% <ø> (ø)
Instrumentation/IO 0.00% <ø> (ø)
Instrumentation/Laravel 71.65% <ø> (ø)
Instrumentation/MongoDB 76.84% <ø> (ø)
Instrumentation/MySqli 93.39% <ø> (ø)
Instrumentation/OpenAIPHP 86.71% <ø> (ø)
Instrumentation/PDO 85.67% <ø> (ø)
Instrumentation/PostgreSql 91.36% <ø> (ø)
Instrumentation/Psr14 77.41% <ø> (ø)
Instrumentation/Psr15 89.74% <ø> (ø)
Instrumentation/Psr16 97.43% <ø> (ø)
Instrumentation/Psr18 79.41% <ø> (ø)
Instrumentation/Psr3 67.70% <ø> (ø)
Instrumentation/Psr6 97.56% <ø> (ø)
Instrumentation/ReactPHP 99.41% <ø> (ø)
Instrumentation/Session 94.28% <ø> (ø)
Instrumentation/Slim 84.21% <ø> (ø)
Instrumentation/Yii 83.33% <ø> (ø)
Logs/Monolog 100.00% <ø> (ø)
Propagation/CloudTrace 90.69% <ø> (ø)
Propagation/Instana 98.07% <ø> (ø)
Propagation/ServerTiming 94.73% <ø> (ø)
Propagation/TraceResponse 94.73% <ø> (ø)
ResourceDetectors/Azure 91.66% <ø> (ø)
ResourceDetectors/Container 93.02% <ø> (ø)
ResourceDetectors/DigitalOcean 100.00% <ø> (ø)
Sampler/RuleBased 32.14% <ø> (?)
Sampler/Xray 78.38% <ø> (ø)
Shims/OpenTracing 92.99% <ø> (ø)
SqlCommenter 95.58% <ø> (ø)
Symfony 88.14% <ø> (ø)
Utils/Test 87.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.
see 14 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a3c02c8...e7291e3. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

```
Error: Ignored error pattern #Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::.*# in path /home/runner/work/opentelemetry-php-contrib/opentelemetry-php-contrib/src/Sampler/RuleBased/src was not matched in reported errors.
```
@Apoorva64 Apoorva64 marked this pull request as draft January 7, 2026 15:23
@Apoorva64 Apoorva64 marked this pull request as ready for review January 7, 2026 16:21
@Apoorva64
Copy link
Author

Is it possible to enable auto approve for the workflows for this PR ?

@Apoorva64 Apoorva64 changed the title fix: phan and psalm issues fix: phan and psalm and PHPStan issues Jan 7, 2026
@Apoorva64
Copy link
Author

all php phan and psalm and PHPStan have been fixed. The remaning errors are phpunit tests to be fixed by #494

@Apoorva64
Copy link
Author

@bobstrecansky Can we merge this one? or should we include #494 in the current PR

@brettmc
Copy link
Contributor

brettmc commented Jan 14, 2026

Hi @Apoorva64 are the failing symfony tests related to these changes? Asking because I see some symfony changes...

@Apoorva64
Copy link
Author

@brettmc no the current changes in this PR are not related, you can run the symfony tests on current main to confirm this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants