<commit_before><?php declare(strict_types=1);

namespace Rector\Printer;

use PhpParser\Node;
use PhpParser\PrettyPrinter\Standard;
use SplFileInfo;

final class FormatPerservingPrinter
{
    /**
     * @var BetterStandardPrinter|Standard
     */
    private $betterStandardPrinter;

    public function __construct(BetterStandardPrinter $betterStandardPrinter)
    {
        $this->betterStandardPrinter = $betterStandardPrinter;
    }

    /**
     * @param Node[] $newStmts
     * @param Node[] $oldStmts
     * @param Node[] $oldTokens
     */
    public function printToFile(SplFileInfo $fileInfo, array $newStmts, array $oldStmts, array $oldTokens): bool
    {
        $oldContent = file_get_contents($fileInfo->getRealPath());
        $newContent = $this->printToString($newStmts, $oldStmts, $oldTokens);

        if ($oldContent === $newContent) {
            return false;
        }

        return file_put_contents($fileInfo->getRealPath(), $newContent);
    }

    /**
     * @param Node[] $newStmts
     * @param Node[] $oldStmts
     * @param Node[] $oldTokens
     */
    public function printToString(array $newStmts, array $oldStmts, array $oldTokens): string
    {
        return $this->betterStandardPrinter->printFormatPreserving($newStmts, $oldStmts, $oldTokens);
    }
}<commit_msg>Force boolean<commit_after><?php declare(strict_types=1);

namespace Rector\Printer;

use PhpParser\Node;
use PhpParser\PrettyPrinter\Standard;
use SplFileInfo;

final class FormatPerservingPrinter
{
    /**
     * @var BetterStandardPrinter|Standard
     */
    private $betterStandardPrinter;

    public function __construct(BetterStandardPrinter $betterStandardPrinter)
    {
        $this->betterStandardPrinter = $betterStandardPrinter;
    }

    /**
     * @param Node[] $newStmts
     * @param Node[] $oldStmts
     * @param Node[] $oldTokens
     */
    public function printToFile(SplFileInfo $fileInfo, array $newStmts, array $oldStmts, array $oldTokens): bool
    {
        $oldContent = file_get_contents($fileInfo->getRealPath());
        $newContent = $this->printToString($newStmts, $oldStmts, $oldTokens);

        if ($oldContent === $newContent) {
            return false;
        }

        return (bool) file_put_contents($fileInfo->getRealPath(), $newContent);
    }

    /**
     * @param Node[] $newStmts
     * @param Node[] $oldStmts
     * @param Node[] $oldTokens
     */
    public function printToString(array $newStmts, array $oldStmts, array $oldTokens): string
    {
        return $this->betterStandardPrinter->printFormatPreserving($newStmts, $oldStmts, $oldTokens);
    }
}
{'fraction_non_alphanumeric': 0.12160611854684512, 'fraction_numerical': 0.0007648183556405354, 'mean_word_length': 3.3527454242928454, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7544127', 'n_tokens_mistral': 841, 'n_tokens_neox': 821, 'n_words': 160}