php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77006 reaching the end of a intliterator makes it unusable
Submitted: 2018-10-12 06:59 UTC Modified: -
From: dontspamwespls at example dot org Assigned:
Status: Open Package: intl (PECL)
PHP Version: 7.3.0RC3 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
2 + 16 = ?
Subscribe to this entry?

 
 [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


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Mar 08 08:01:24 2021 UTC