1--TEST--
2UConverter::convert() w/ Callback Reasons
3--EXTENSIONS--
4intl
5--SKIPIF--
6<?php if (version_compare(INTL_ICU_VERSION, '60.1') < 0) die('skip for ICU >= 60.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_ILLEGAL, ...)
41toUCallback(REASON_RESET, ...)
42toUCallback(REASON_ILLEGAL, ...)
43toUCallback(REASON_ILLEGAL, ...)
44fromUCallback(REASON_RESET, ...)
45fromUCallback(REASON_UNASSIGNED, ...)
46fromUCallback(REASON_UNASSIGNED, ...)
47fromUCallback(REASON_RESET, ...)
48fromUCallback(REASON_UNASSIGNED, ...)
49fromUCallback(REASON_UNASSIGNED, ...)
50toUCallback(REASON_RESET, ...)
51toUCallback(REASON_RESET, ...)
52fromUCallback(REASON_RESET, ...)
53fromUCallback(REASON_UNASSIGNED, ...)
54fromUCallback(REASON_RESET, ...)
55fromUCallback(REASON_UNASSIGNED, ...)
56toUCallback(REASON_CLOSE, ...)
57fromUCallback(REASON_CLOSE, ...)
58toUCallback(REASON_CLOSE, ...)
59fromUCallback(REASON_CLOSE, ...)
60