Skip to content

Conversation

@daledupreez
Copy link
Contributor

Changes proposed in this Pull Request:

This PR works around a bug or limitation in PHPStan where it does not recognise constants defined using the return value from a function. The issue was resulting in the WC_STRIPE_PLUGIN_URL and WC_STRIPE_PLUGIN_PATH constants not being found/seen by PHPStan. To work around the issue, I've added conditional definitions for those two constants in phpstan-stubs/wc_stripe_constants.php so they get picked up during PHPStan analysis runs. Note that the values are not correct, as we need to use constant values for both.

I have also updated the PHPStan baseline to remove the previously tracked errors stemming from the "missing" constants.

Testing instructions

Code review should be good enough on this one, and the PHPStan analysis should be clean.


  • [N/A] Covered with tests (or have a good reason not to test in description ☝️)
  • [N/A] Tested on mobile (or does not apply)

Changelog entry

  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Comment

Comment

Post merge

@daledupreez daledupreez requested review from a team and malithsen and removed request for a team December 24, 2025 10:04
@daledupreez daledupreez self-assigned this Dec 24, 2025
Copy link
Contributor

@malithsen malithsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

* @see https://github.com/phpstan/phpstan/issues/11210
*/

if ( ! defined( 'ABSPATH' ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this check needed for PHPStan? It might give the impression that this is a WP runtime file.

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.

3 participants