Skip to content

Fix GH-9421 Incorrect argument number for ValueError in NumberFormatter #9453

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

Closed
wants to merge 1 commit into from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Aug 30, 2022

No description provided.

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

Thank you! Looks overall good to me, but some details might be re-considered.


case FORMAT_TYPE_CURRENCY:
if (getThis()) {
zend_argument_value_error(2, "cannot use NumberFormatter::TYPE_CURRENCY constant, use formatCurrency() method instead");
Copy link
Member

Choose a reason for hiding this comment

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

Not sure about the formatCurrency(); shouldn't that better be ::formatCurrency()? cc @kocsismate

Copy link
Member

Choose a reason for hiding this comment

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

My preference would be to prepend the class name before the method name, just like in case of the constant name.

Copy link
Member

Choose a reason for hiding this comment

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

Otherwise Argument #2 ($type) cannot use NumberFormatter::TYPE_CURRENCY... sounds a bit unnatural to me. What about Argument #2 ($type) cannot be NumberFormatter::TYPE_CURRENCY...?

Copy link
Member

Choose a reason for hiding this comment

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

What about Argument #2 ($type) cannot be NumberFormatter::TYPE_CURRENCY...?

Yeah, that's better, in my opinion.

And maybe we should print the actual class name, since NumberFormatter is not final, nor are its class constants.

Copy link
Member Author

Choose a reason for hiding this comment

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

ACK

Comment on lines +107 to +111
if (getThis()) {
zend_argument_value_error(2, "cannot use NumberFormatter::TYPE_CURRENCY constant, use formatCurrency() method instead");
} else {
zend_argument_value_error(3, "cannot use NumberFormatter::TYPE_CURRENCY constant, use numfmt_format_currency() function instead");
}
Copy link
Member

Choose a reason for hiding this comment

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

IMO, referring to NumberFormatter::formatCurrency() in both cases should be sufficient. After all, they can be used interchangeably, and if it was for me, we would deprecate the procedural API anyway.

@TimWolla
Copy link
Member

Note sure if this is relevant for this PR when merging manually, but I'd like to point out that the target branch likely is incorrectly set to master (based on the name of the source branch).

@Girgias
Copy link
Member Author

Girgias commented Sep 6, 2022

Closing in favour of #9489 because I forgot to use a feature branch

@Girgias Girgias closed this Sep 6, 2022
@Girgias Girgias deleted the PHP-8.0 branch September 6, 2022 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants