$key)!==serialize($before->$key))throw new RuntimeException('Изменён соседний JSON тип'); if(isset($actual->utm->registration,$actual->utm->bchoice))throw new RuntimeException('Остались старые имена'); if(json_encode($actual->utm->reg)!=='{"weights":{"1":3,"2":7},"default":"2"}'||json_encode($actual->utm->chob)!=='{"weights":{"2":8,"1":2},"default":"1"}')throw new RuntimeException('Изменён смысл reg/chob'); if($actual->utm->theme->default!=='2'||$actual->utm->focus->default!=='1'||serialize($actual->utm->custom)!==serialize($before->utm->custom))throw new RuntimeException('Неверная миграция enum'); $first=file_get_contents($file);exec(PHP_BINARY.' '.escapeshellarg($script).' '.escapeshellarg($file),$out,$code); if($code!==0||file_get_contents($file)!==$first)throw new RuntimeException('Patch не идемпотентен'); file_put_contents($file,'{"utm":{"theme":{"weights":{"1":0,"2":1},"default":2}}}'); $numeric=file_get_contents($file);exec(PHP_BINARY.' '.escapeshellarg($script).' '.escapeshellarg($file),$out,$code); if($code!==0||file_get_contents($file)!==$numeric)throw new RuntimeException('Уже числовой integer default должен сохраняться'); file_put_contents($file,'{"utm":{"registration":{"weights":{"before":1},"default":"before"},"reg":{"weights":{"1":1},"default":"1"}}}'); $conflict=file_get_contents($file);exec(PHP_BINARY.' '.escapeshellarg($script).' '.escapeshellarg($file).' 2>/dev/null',$out,$code); if($code!==2||file_get_contents($file)!==$conflict)throw new RuntimeException('Неоднозначный config должен блокировать patch без записи'); echo "OK: numeric config migration preserves weights/default/foreign JSON types\n"; }finally{unlink($file);}