<?php
//"Grammar Nazi" с функцией-обёрткой
    error_reporting(-1);
    mb_internal_encoding('utf-8');

    function fixGrammar($regexp, $callback, $text){
        $text = preg_replace_callback($regexp, $callback, $text);
        return $text;
    }

    function copyCase($neededLetter, $symbol){
        if (preg_match('/[А-ЯЁ]/u', $symbol)){
                return mb_strtoupper($neededLetter);
        }
        return $neededLetter;
    }

	$text = "ЗДЕЛАЛ СДЕСЬ КООРДИНАЛЬНО Привет,Жырный!труд:Шырокий?пассаЖЫР;зделаю Координально но, например СДЕСЬ сдесь решена проблема ушыбов.
		ЗДЕЛАНО многое а? ведь эти ушы зделали мы. Один ананас    но зато как ЗДЕЛАННЫЙ";

    $simpleReplace = ['/(к)оординально/ui' => '$1ардинально',        //кардинально
                      '/([,;!?:])([^,;!?:\\s]+)/u' => '$1 $2',       //пробелы после знаков препинания
                      '/([а-яё]+)\\s+((?:а|но)\\b)/ui' => '$1, $2']; //знаки препинания

    foreach ($simpleReplace as $pattern => $replacement){
        $text = preg_replace($pattern, $replacement, $text);
    }

    $text = fixGrammar('/(с)(десь)/ui', 
                        function($matches){
                            $letter = copyCase('з', $matches[1]);
                            $word = "{$letter}{$matches[2]}";
                            return $word;
                        }, $text);

    $text = fixGrammar('/(з)(дела)((?:ю|л|н)\\s*)/ui', 
                        function ($matches){
                            $letter = copyCase('с', $matches[1]);
                            $word = "{$letter}{$matches[2]}{$matches[3]}";
                            return $word;
                        }, $text);

    $text = fixGrammar('/([а-яё]*(?:ж|ш))(ы)([а-яё]*)/ui', 
                        function ($matches){
                            $letter = copyCase('и', $matches[2]);
                            $word = "{$matches[1]}{$letter}{$matches[3]}";
                            return $word;
                        }, $text);

    echo $text;
?>