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

Fix tests for php 5.5.35/5.6.21/7.0.6 #62

Merged
merged 1 commit into from
May 18, 2016
Merged

Fix tests for php 5.5.35/5.6.21/7.0.6 #62

merged 1 commit into from
May 18, 2016

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas
Copy link
Member Author

See also https://3v4l.org/Svk6W

@stof
Copy link
Member

stof commented May 18, 2016

We should keep a test covering negative indexes, to ensure they produce the same behavior than PHP for each version (being accepted silently as 0, being rejected, or being taken from the end in PHP 7.1)

@nicolas-grekas
Copy link
Member Author

@stof fixed

@@ -177,7 +177,11 @@ private static function grapheme_position($s, $needle, $offset, $mode)
if ($offset > 0) {
$s = self::grapheme_substr($s, $offset);
} elseif ($offset < 0) {
$offset = 0;
if (PHP_VERSION_ID < 50535 || PHP_VERSION_ID < 50621 || PHP_VERSION_ID < 70006) {
Copy link
Member

Choose a reason for hiding this comment

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

this is wrong, as it will also match PHP 5.6.22 (as 50622 is smaller than 70006). It should be this:

if (PHP_VERSION_ID < 50535 || (PHP_VERSION_ID >= 50600 && PHP_VERSION_ID < 50621) || (PHP_VERSION_ID >= 70000 && PHP_VERSION_ID < 70006)) {
    $offset = 0;
} else {
    return false;
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Pff indeed, fixed

@stof
Copy link
Member

stof commented May 18, 2016

👍

@fabpot
Copy link
Member

fabpot commented May 18, 2016

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 99a2aeb into symfony:master May 18, 2016
fabpot added a commit that referenced this pull request May 18, 2016
This PR was merged into the 1.1-dev branch.

Discussion
----------

Fix tests for php 5.5.35/5.6.21/7.0.6

See tchwork/utf8#59

Commits
-------

99a2aeb Fix tests for php 5.5.35/5.6.21/7.0.6
@nicolas-grekas nicolas-grekas deleted the fix-neg-offsets branch August 17, 2016 06:27
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.

4 participants