Skip to content

Fix the Collator return types in phpdoc #460

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

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Intl/Icu/Collator.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function asort(array &$array, int $flags = self::SORT_REGULAR)
/**
* Not supported. Compare two Unicode strings.
*
* @return bool|int
* @return int|false
*
* @see https://php.net/collator.compare
*
Expand All @@ -134,7 +134,7 @@ public function compare(string $string1, string $string2)
/**
* Not supported. Get a value of an integer collator attribute.
*
* @return bool|int The attribute value on success or false on error
* @return int|false The attribute value on success or false on error
*
* @see https://php.net/collator.getattribute
*
Expand All @@ -148,7 +148,7 @@ public function getAttribute(int $attribute)
/**
* Returns collator's last error code. Always returns the U_ZERO_ERROR class constant value.
*
* @return int The error code from last collator call
* @return int|false The error code from last collator call
*/
public function getErrorCode()
{
Expand All @@ -158,7 +158,7 @@ public function getErrorCode()
/**
* Returns collator's last error message. Always returns the U_ZERO_ERROR_MESSAGE class constant value.
*
* @return string The error message from last collator call
* @return string|false The error message from last collator call
*/
public function getErrorMessage()
{
Expand All @@ -168,8 +168,8 @@ public function getErrorMessage()
/**
* Returns the collator's locale.
*
* @return string The locale used to create the collator. Currently always
* returns "en".
* @return string|false The locale used to create the collator. Currently
* always returns "en".
*/
public function getLocale(int $type = Locale::ACTUAL_LOCALE)
{
Expand All @@ -179,7 +179,7 @@ public function getLocale(int $type = Locale::ACTUAL_LOCALE)
/**
* Not supported. Get sorting key for a string.
*
* @return string The collation key for $string
* @return string|false The collation key for $string
*
* @see https://php.net/collator.getsortkey
*
Expand All @@ -193,7 +193,7 @@ public function getSortKey(string $string)
/**
* Not supported. Get current collator's strength.
*
* @return bool|int The current collator's strength or false on failure
* @return int The current collator's strength or false on failure
Copy link
Author

Choose a reason for hiding this comment

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

I didn't change the comment because the PHP documentation itself is incoherent (the return type is int, but the doc mentions a false value), see https://www.php.net/manual/en/collator.getstrength.php

Copy link
Member

Choose a reason for hiding this comment

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

could it be that older PHP versions can return false for failures while new versions throw exceptions ?

Copy link
Author

Choose a reason for hiding this comment

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

*
* @see https://php.net/collator.getstrength
*
Expand Down