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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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-2018 The PHP Group
All rights reserved.
Last updated: Mon Dec 10 08:01:24 2018 UTC