Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using deprecated defaultOption method #228

Merged
merged 1 commit into from
Dec 10, 2024
Merged

Conversation

JeroenDeDauw
Copy link
Member

@JeroenDeDauw JeroenDeDauw commented Dec 9, 2024

This fixes the build, because Psalm gets angry when you use deprecated methods.

Copy link
Contributor

@codders codders left a comment

Choose a reason for hiding this comment

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

Looks good - just a couple of questions.

@@ -38,9 +38,8 @@ class GlobeCoordinateParser implements ValueParser {

public function __construct( ?ParserOptions $options = null ) {
$this->options = $options ?: new ParserOptions();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not:

$this->options = ($options ?: new ParserOptions())
   ->withDefaultOption(...)
   ->withDefaultOption(...);

Copy link
Member Author

Choose a reason for hiding this comment

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

Also works, but I couldn't be bothered in this case


public function __construct( ?ParserOptions $options = null ) {
$this->options = $options ?: new ParserOptions();

$this->options->defaultOption( ValueParser::OPT_LANG, 'en' );
$this->defaultOption( ValueParser::OPT_LANG, 'en' );
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for preferring the private defaultOption method here to repeated calls to withDefaultOption? Is it a wish to avoid repeated re-allocation of the options object?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was the quickest fix

@JeroenDeDauw JeroenDeDauw merged commit db55b2a into master Dec 10, 2024
8 of 9 checks passed
@JeroenDeDauw JeroenDeDauw deleted the defaultOption branch December 10, 2024 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants