PhpCsFixer\Fixer\StringNotation\SingleQuoteFixer::fix PHP Method

fix() public method

public fix ( SplFileInfo $file, Tokens $tokens )
$file SplFileInfo
$tokens PhpCsFixer\Tokenizer\Tokens
    public function fix(\SplFileInfo $file, Tokens $tokens)
    {
        foreach ($tokens as $token) {
            if (!$token->isGivenKind(T_CONSTANT_ENCAPSED_STRING)) {
                continue;
            }
            $content = $token->getContent();
            if ('"' === $content[0] && false === strpos($content, "'") && !preg_match('/(?<!\\\\)(?:\\\\{2})*\\\\(?!["$\\\\])/', $content)) {
                $content = substr($content, 1, -1);
                $content = str_replace(array('\\"', '\\$'), array('"', '$'), $content);
                $token->setContent('\'' . $content . '\'');
            }
        }
    }