1--TEST-- 2grapheme_* functions with out-of-bounds offsets 3--EXTENSIONS-- 4intl 5--FILE-- 6<?php 7 8// Offset == Length is legal. 9var_dump(grapheme_strpos("foo", "bar", 3)); 10var_dump(grapheme_stripos("foo", "bar", 3)); 11var_dump(grapheme_strrpos("foo", "bar", 3)); 12var_dump(grapheme_strripos("foo", "bar", 3)); 13var_dump(grapheme_strpos("äöü", "bar", 3)); 14var_dump(grapheme_stripos("äöü", "bar", 3)); 15var_dump(grapheme_strrpos("äöü", "bar", 3)); 16var_dump(grapheme_strripos("äöü", "bar", 3)); 17echo "\n"; 18 19// Offset == -Length is legal. 20var_dump(grapheme_strpos("foo", "bar", -3)); 21var_dump(grapheme_stripos("foo", "bar", -3)); 22var_dump(grapheme_strrpos("foo", "bar", -3)); 23var_dump(grapheme_strripos("foo", "bar", -3)); 24var_dump(grapheme_strpos("äöü", "bar", -3)); 25var_dump(grapheme_stripos("äöü", "bar", -3)); 26var_dump(grapheme_strrpos("äöü", "bar", -3)); 27var_dump(grapheme_strripos("äöü", "bar", -3)); 28echo "\n"; 29 30// Offset == Length is legal. 31var_dump(grapheme_strpos("", "bar", 0)); 32var_dump(grapheme_stripos("", "bar", 0)); 33var_dump(grapheme_strrpos("", "bar", 0)); 34var_dump(grapheme_strripos("", "bar", 0)); 35echo "\n"; 36 37// Positive out of bounds. 38try { 39 var_dump(grapheme_strpos("foo", "bar", 4)); 40} catch (ValueError $e) { 41 echo $e->getMessage(), "\n"; 42} 43try { 44 var_dump(grapheme_stripos("foo", "bar", 4)); 45} catch (ValueError $e) { 46 echo $e->getMessage(), "\n"; 47} 48try { 49 var_dump(grapheme_strrpos("foo", "bar", 4)); 50} catch (ValueError $e) { 51 echo $e->getMessage(), "\n"; 52} 53try { 54 var_dump(grapheme_strripos("foo", "bar", 4)); 55} catch (ValueError $e) { 56 echo $e->getMessage(), "\n"; 57} 58try { 59 var_dump(grapheme_strpos("äöü", "bar", 4)); 60} catch (ValueError $e) { 61 echo $e->getMessage(), "\n"; 62} 63try { 64 var_dump(grapheme_stripos("äöü", "bar", 4)); 65} catch (ValueError $e) { 66 echo $e->getMessage(), "\n"; 67} 68try { 69 var_dump(grapheme_strrpos("äöü", "bar", 4)); 70} catch (ValueError $e) { 71 echo $e->getMessage(), "\n"; 72} 73try { 74 var_dump(grapheme_strripos("äöü", "bar", 4)); 75} catch (ValueError $e) { 76 echo $e->getMessage(), "\n"; 77} 78echo "\n"; 79 80// Negative out of bounds. 81try { 82 var_dump(grapheme_strpos("foo", "bar", -4)); 83} catch (ValueError $e) { 84 echo $e->getMessage(), "\n"; 85} 86try { 87 var_dump(grapheme_stripos("foo", "bar", -4)); 88} catch (ValueError $e) { 89 echo $e->getMessage(), "\n"; 90} 91try { 92 var_dump(grapheme_strrpos("foo", "bar", -4)); 93} catch (ValueError $e) { 94 echo $e->getMessage(), "\n"; 95} 96try { 97 var_dump(grapheme_strripos("foo", "bar", -4)); 98} catch (ValueError $e) { 99 echo $e->getMessage(), "\n"; 100} 101try { 102 var_dump(grapheme_strpos("äöü", "bar", -4)); 103} catch (ValueError $e) { 104 echo $e->getMessage(), "\n"; 105} 106try { 107 var_dump(grapheme_stripos("äöü", "bar", -4)); 108} catch (ValueError $e) { 109 echo $e->getMessage(), "\n"; 110} 111try { 112 var_dump(grapheme_strrpos("äöü", "bar", -4)); 113} catch (ValueError $e) { 114 echo $e->getMessage(), "\n"; 115} 116try { 117 var_dump(grapheme_strripos("äöü", "bar", -4)); 118} catch (ValueError $e) { 119 echo $e->getMessage(), "\n"; 120} 121echo "\n"; 122 123// Empty needle + out of bounds 124try { 125 var_dump(grapheme_strpos("äöü", "", 4)); 126} catch (ValueError $e) { 127 echo $e->getMessage(), "\n"; 128} 129try { 130 var_dump(grapheme_stripos("äöü", "", 4)); 131} catch (ValueError $e) { 132 echo $e->getMessage(), "\n"; 133} 134try { 135 var_dump(grapheme_strrpos("äöü", "", 4)); 136} catch (ValueError $e) { 137 echo $e->getMessage(), "\n"; 138} 139try { 140 var_dump(grapheme_strripos("äöü", "", 4)); 141} catch (ValueError $e) { 142 echo $e->getMessage(), "\n"; 143} 144try { 145 var_dump(grapheme_strpos("äöü", "", -4)); 146} catch (ValueError $e) { 147 echo $e->getMessage(), "\n"; 148} 149try { 150 var_dump(grapheme_stripos("äöü", "", -4)); 151} catch (ValueError $e) { 152 echo $e->getMessage(), "\n"; 153} 154try { 155 var_dump(grapheme_strrpos("äöü", "", -4)); 156} catch (ValueError $e) { 157 echo $e->getMessage(), "\n"; 158} 159try { 160 var_dump(grapheme_strripos("äöü", "", -4)); 161} catch (ValueError $e) { 162 echo $e->getMessage(), "\n"; 163} 164echo "\n"; 165 166var_dump(grapheme_substr("foo", 3)); 167var_dump(grapheme_substr("foo", -3)); 168var_dump(grapheme_substr("foo", 4)); 169var_dump(grapheme_substr("foo", -4)); 170var_dump(grapheme_substr("äöü", 3)); 171var_dump(grapheme_substr("äöü", -3)); 172var_dump(grapheme_substr("äöü", 4)); 173var_dump(grapheme_substr("äöü", -4)); 174var_dump(grapheme_substr("foo", 0, 3)); 175var_dump(grapheme_substr("foo", 0, -3)); 176var_dump(grapheme_substr("foo", 0, 4)); 177var_dump(grapheme_substr("foo", 0, -4)); 178var_dump(grapheme_substr("äöü", 0, 3)); 179var_dump(grapheme_substr("äöü", 0, -3)); 180var_dump(grapheme_substr("äöü", 0, 4)); 181var_dump(grapheme_substr("äöü", 0, -4)); 182var_dump(grapheme_substr("äöü", -4, 1)); 183var_dump(grapheme_substr("äöü", -4, -1)); 184var_dump(grapheme_substr("äöü", 2, -2)); 185 186?> 187--EXPECT-- 188bool(false) 189bool(false) 190bool(false) 191bool(false) 192bool(false) 193bool(false) 194bool(false) 195bool(false) 196 197bool(false) 198bool(false) 199bool(false) 200bool(false) 201bool(false) 202bool(false) 203bool(false) 204bool(false) 205 206bool(false) 207bool(false) 208bool(false) 209bool(false) 210 211grapheme_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 212grapheme_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 213grapheme_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 214grapheme_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 215grapheme_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 216grapheme_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 217grapheme_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 218grapheme_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 219 220grapheme_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 221grapheme_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 222grapheme_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 223grapheme_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 224grapheme_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 225grapheme_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 226grapheme_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 227grapheme_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 228 229grapheme_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 230grapheme_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 231grapheme_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 232grapheme_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 233grapheme_strpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 234grapheme_stripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 235grapheme_strrpos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 236grapheme_strripos(): Argument #3 ($offset) must be contained in argument #1 ($haystack) 237 238string(0) "" 239string(3) "foo" 240string(0) "" 241string(3) "foo" 242string(0) "" 243string(6) "äöü" 244string(0) "" 245string(6) "äöü" 246string(3) "foo" 247string(0) "" 248string(3) "foo" 249string(0) "" 250string(6) "äöü" 251string(0) "" 252string(6) "äöü" 253string(0) "" 254string(2) "ä" 255string(4) "äö" 256string(0) "" 257