1--TEST--
2UConverter::convert() w/ Callback Reasons
3--EXTENSIONS--
4intl
5--SKIPIF--
6<?php if (version_compare(INTL_ICU_VERSION, '58.1') >= 0) die('skip for ICU <= 57.1'); ?>
7--FILE--
8<?php
9class MyConverter extends UConverter {
10  /**
11   * Called during conversion from source encoding to internal UChar representation
12   */
13  public function toUCallback($reason, $source, $codeUnits, &$error): string|int|array|null {
14    echo "toUCallback(", UConverter::reasonText($reason), ", ...)\n";
15    return parent::toUCallback($reason, $source, $codeUnits, $error);
16  }
17
18  /**
19   * Called during conversion from internal UChar to destination encoding
20   */
21  public function fromUCallback($reason, $source, $codePoint, &$error): string|int|array|null {
22    echo "fromUCallback(", UConverter::reasonText($reason), ", ...)\n";
23    return parent::fromUCallback($reason, $source, $codePoint, $error);
24  }
25
26}
27
28$c = new MyConverter('ascii', 'utf-8');
29foreach(array("regular", "irregul\xC1\xA1r", "\xC2\xA1unsupported!") as $word) {
30  $c->convert($word);
31}
32?>
33--EXPECT--
34toUCallback(REASON_RESET, ...)
35toUCallback(REASON_RESET, ...)
36fromUCallback(REASON_RESET, ...)
37fromUCallback(REASON_RESET, ...)
38toUCallback(REASON_RESET, ...)
39toUCallback(REASON_ILLEGAL, ...)
40toUCallback(REASON_RESET, ...)
41toUCallback(REASON_ILLEGAL, ...)
42fromUCallback(REASON_RESET, ...)
43fromUCallback(REASON_UNASSIGNED, ...)
44fromUCallback(REASON_RESET, ...)
45fromUCallback(REASON_UNASSIGNED, ...)
46toUCallback(REASON_RESET, ...)
47toUCallback(REASON_RESET, ...)
48fromUCallback(REASON_RESET, ...)
49fromUCallback(REASON_UNASSIGNED, ...)
50fromUCallback(REASON_RESET, ...)
51fromUCallback(REASON_UNASSIGNED, ...)
52toUCallback(REASON_CLOSE, ...)
53fromUCallback(REASON_CLOSE, ...)
54toUCallback(REASON_CLOSE, ...)
55fromUCallback(REASON_CLOSE, ...)
56