Skip to content

Adds optional description to providers#210

Open
JasonTheAdams wants to merge 2 commits intotrunkfrom
add/provider-description
Open

Adds optional description to providers#210
JasonTheAdams wants to merge 2 commits intotrunkfrom
add/provider-description

Conversation

@JasonTheAdams
Copy link
Member

This adds "description" as an optional field for providers. This is useful in contexts where providers are being listed out for users.

@JasonTheAdams JasonTheAdams self-assigned this Feb 25, 2026
@github-actions
Copy link

github-actions bot commented Feb 25, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: JasonTheAdams <jason_the_adams@git.wordpress.org>
Co-authored-by: felixarntz <flixos90@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

❌ Patch coverage is 86.11111% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.41%. Comparing base (c23867f) to head (b2228bd).

Files with missing lines Patch % Lines
src/Providers/DTO/ProviderMetadata.php 86.11% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk     #210      +/-   ##
============================================
+ Coverage     87.38%   87.41%   +0.02%     
- Complexity     1188     1196       +8     
============================================
  Files            60       60              
  Lines          3837     3862      +25     
============================================
+ Hits           3353     3376      +23     
- Misses          484      486       +2     
Flag Coverage Δ
unit 87.41% <86.11%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@felixarntz felixarntz added the [Type] Enhancement A suggestion for improvement. label Feb 25, 2026
@felixarntz felixarntz added this to the 1.2.0 milestone Feb 25, 2026
Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

Looks great! Though this prompts for a slight refactoring of ProviderMetadata constructor.

Comment on lines 85 to 87
?string $credentialsUrl = null,
?RequestAuthenticationMethod $authenticationMethod = null
?RequestAuthenticationMethod $authenticationMethod = null,
?string $description = null
Copy link
Member

@felixarntz felixarntz Feb 25, 2026

Choose a reason for hiding this comment

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

This is getting out of hand in terms of parameters :)

Can we change this to a single param? Either some value object with these, or just the basic $args pattern. Don't love the latter, but would be fine - another class for this seems overkill. I think the first 3 parameters should remain as-is, but the optional ones should be combined.

We can make it backward compatible by supporting either an array for the 4th parameter, or what we currently have for the 4th and 5th parameter. And use a trigger_error for deprecation warning if the old way is used.

Then 2-3 releases later we can remove the old way.

Please make sure to keep tests around for both behaviors to have BC covered but also the new correct way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hahah! Yeah... what we really want here is PHP 8.0 named parameters. In the meantime, I think I'd prefer $args. I don't love it, but I find VO instantiation to be even more awkward, especially for a DTO like this. It makes the parameters feel weirdly complicated.

So how about this as the new signature: __construct(string $id, string $name, array $args = [])

Copy link
Member

Choose a reason for hiding this comment

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

Works for me, I think. So that means we'll have a default type of Cloud provider then, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops! Missed that... I mean, yeah, default cloud provider. That's why I left that out... 😁

Copy link
Member Author

Choose a reason for hiding this comment

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

@felixarntz Tentatively resolved in b2228bd

I'm honestly not convinced that I like this better. It's awkward having a growing list of parameters, for sure, but if we eventually bump to 8.0 I'd actually want to go back to pure parameters as it is now. Types and stuff get really goofy. It feels like we're temporarily weakening types to make the DX slightly better. I'm tempted to revert this and just live with it until named parameters are an option.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, fair point. Current DX is IMO worse without the array (functions with more than 2-3 params are generally a problematic pattern for DX). Though you can also argue against the array of $args because a lack of auto-completion, and less idiomatic for future PHP compat indeed.

Let's revert - you have me convinced :)

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

Almost good to go! Preemptively approving, but please address the remaining feedback before merge.

}
if (isset($allArgs[5])) {
$args[self::KEY_DESCRIPTION] = $allArgs[5];
}
Copy link
Member

Choose a reason for hiding this comment

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

This last one is unnecessary. It was never possible in the old way to pass a description anyway. We should not add support for it in the wrong way that we want to discourage anyway.

/**
* Gets the provider's description.
*
* @since 0.5.0
Copy link
Member

Choose a reason for hiding this comment

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

n.e.x.t - please double check that throughout the PR

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

Labels

[Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants