1--TEST-- 2runkit7_function_rename() function with large switch statements 3--SKIPIF-- 4<?php if(!extension_loaded("runkit7") || !RUNKIT7_FEATURE_MANIPULATION) print "skip"; ?> 5--FILE-- 6<?php 7// See https://derickrethans.nl/php7.2-switch.html for an explanation of this optimization. 8// This test checks that renamed functions with large switch cases continue to work properly. 9function runkitNSwitch(int $n) { 10 switch ($n) { 11 case 1: echo "one\n"; break; 12 case 2: echo "two\n"; // fallthrough 13 case 3: echo "three\n"; break; 14 case 4: echo "four\n"; break; 15 case 5: echo "five\n"; break; 16 case 6: echo "six\n"; break; 17 case 7: echo "seven\n"; break; 18 case 8: echo "eight\n"; break; 19 } 20} 21 22function runkitSSwitch(string $n) { 23 switch ($n) { 24 case "one": echo "1\n"; break; 25 case "two": echo "2\n"; // fallthrough 26 case "three": echo "3\n"; break; 27 case "four": echo "4\n"; break; 28 case "five": echo "5\n"; break; 29 case "six": echo "6\n"; break; 30 case "seven": echo "7\n"; break; 31 case "eight": echo "8\n"; break; 32 } 33} 34$oldName = 'runkitNSwitch'; 35$newName = 'runkitNewIntName'; 36runkitNSwitch(2); 37runkit7_function_rename($oldName, $newName); 38runkitNewIntName(1); 39runkitNewIntName(2); 40runkitNewIntName(8); 41runkitNewIntName(10); 42runkitNewIntName(7); 43runkitNewIntName(8); 44 45if (function_exists('runkitNSwitch')) { 46 echo "Old function name still exists!\n"; 47} 48 49$oldName = 'runkitSSwitch'; 50$newName = 'runkitNewStringName'; 51runkitSSwitch("one"); 52runkit7_function_rename($oldName, $newName); 53if (function_exists('runkitSSwitch')) { 54 echo "Old function name still exists!\n"; 55} 56runkitNewStringName("one"); 57runkitNewStringName("one"); 58runkitNewStringName("missing"); 59runkitNewStringName("eight"); 60?> 61--EXPECT-- 62two 63three 64one 65two 66three 67eight 68seven 69eight 701 711 721 738 74