|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-10-12 06:59 UTC] dontspamwespls at example dot org
Description: ------------ once valid() becomes false, previous() stops working https://3v4l.org/A125P Test script: --------------- <?php $iteratorx = IntlCodePointBreakIterator::createCodePointInstance(); $iteratorx->setText("abc"); $iterator = $iteratorx->getPartsIterator(); $iterator->rewind(); $iterator->next(); $iteratorx->previous(); // previous works $iterator->next(); $iterator->next(); echo $iterator->current() . "\n"; // c... all fine $iterator->next(); // no more code points, so it's invalid var_dump($iterator->valid()); // false var_dump($iterator->current()); // prints weird stuff... whatever... $iteratorx->previous(); // cannot go back var_dump($iterator->valid()); // broken var_dump($iterator->current()); // broken Expected result: ---------------- I expect valid() to be true after previous(), and current() set to the last code point PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 15:00:01 2025 UTC |
> var_dump($iterator->current()); // prints weird stuff... whatever... That is because an IS_UNDEF value is returned. Possible fix: ext/intl/common/common_enum.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/intl/common/common_enum.cpp b/ext/intl/common/common_enum.cpp index adc7034d36..1e1b5ecb50 100644 --- a/ext/intl/common/common_enum.cpp +++ b/ext/intl/common/common_enum.cpp @@ -218,7 +218,7 @@ static PHP_METHOD(IntlIterator, current) INTLITERATOR_METHOD_FETCH_OBJECT; data = ii->iterator->funcs->get_current_data(ii->iterator); - if (data) { + if (data && Z_TYPE_P(data) != IS_UNDEF) { ZVAL_COPY_DEREF(return_value, data); } }