Skip to content

Avoid change chmod by using Nette\Utils\FileSystem with pass null on 3rd argument on write #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Caching/ValueObject/Storage/FileCacheStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Symplify\EasyCodingStandard\Caching\ValueObject\Storage;

use Nette\Utils\FileSystem as UtilsFileSystem;
Copy link
Collaborator Author

@samsonasik samsonasik May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vasilvestre for manual test, with directly change on vendor, change it with prefixed use statement:

use ECSPrefix202405\Nette\Utils\FileSystem as UtilsFileSystem;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try soon

use Symfony\Component\Filesystem\Filesystem;
use Symplify\EasyCodingStandard\Caching\ValueObject\CacheFilePaths;
use Symplify\EasyCodingStandard\Caching\ValueObject\CacheItem;
Expand Down Expand Up @@ -63,19 +64,19 @@ public function save(string $key, string $variableKey, string $data): void
}

$variableFileContent = sprintf("<?php declare(strict_types = 1);\n\nreturn %s;", $exported);
$this->fileSystem->dumpFile($cacheFilePaths->getFilePath(), $variableFileContent);
UtilsFileSystem::write($cacheFilePaths->getFilePath(), $variableFileContent, null);
}

public function clean(string $cacheKey): void
{
$cacheFilePaths = $this->getCacheFilePaths($cacheKey);

$this->fileSystem->remove($cacheFilePaths->getFilePath());
UtilsFileSystem::delete($cacheFilePaths->getFilePath());
}

public function clear(): void
{
$this->fileSystem->remove($this->directory);
UtilsFileSystem::delete($this->directory);
}

private function getCacheFilePaths(string $key): CacheFilePaths
Expand Down
2 changes: 1 addition & 1 deletion src/Configuration/ConfigInitializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function createConfig(string $projectDirectory): void
$templateFileContents = str_replace('__PATHS__', $projectPhpDirectoriesContents, $templateFileContents);

// create the ecs.php file
FileSystem::write(getcwd() . '/ecs.php', $templateFileContents);
FileSystem::write(getcwd() . '/ecs.php', $templateFileContents, null);

$this->symfonyStyle->success('The ecs.php config was generated! Re-run the command to tidy your code');
}
Expand Down
2 changes: 1 addition & 1 deletion src/FileSystem/JsonFileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public static function readFilePath(string $filePath): array
public static function writeFilePath(string $filePath, array $data): void
{
$jsonContents = Json::encode($data, Json::PRETTY);
FileSystem::write($filePath, $jsonContents);
FileSystem::write($filePath, $jsonContents, null);
}
}
3 changes: 1 addition & 2 deletions src/FixerRunner/Application/FixerFileProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function __construct(
private readonly Skipper $skipper,
private readonly DifferInterface $differ,
private readonly EasyCodingStandardStyle $easyCodingStandardStyle,
private readonly \Symfony\Component\Filesystem\Filesystem $filesystem,
private readonly FileDiffFactory $fileDiffFactory,
array $fixers
) {
Expand Down Expand Up @@ -91,7 +90,7 @@ public function processFile(string $filePath, Configuration $configuration): arr

$tokenGeneratedCode = $tokens->generateCode();
if ($configuration->isFixer()) {
$this->filesystem->dumpFile($filePath, $tokenGeneratedCode);
FileSystem::write($filePath, $tokenGeneratedCode, null);
}

Tokens::clearCache();
Expand Down
3 changes: 1 addition & 2 deletions src/SniffRunner/Application/SniffFileProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public function __construct(
private readonly FileFactory $fileFactory,
private readonly DifferInterface $differ,
private readonly SniffMetadataCollector $sniffMetadataCollector,
private readonly \Symfony\Component\Filesystem\Filesystem $filesystem,
private readonly FileDiffFactory $fileDiffFactory,
array $sniffs
) {
Expand Down Expand Up @@ -117,7 +116,7 @@ public function processFile(string $filePath, Configuration $configuration): arr
}

if ($configuration->isFixer()) {
$this->filesystem->dumpFile($file->getFilename(), $this->fixer->getContents());
FileSystem::write($file->getFilename(), $this->fixer->getContents(), null);
}

return $errorsAndDiffs;
Expand Down
2 changes: 1 addition & 1 deletion src/Testing/PHPUnit/AbstractCheckerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected function doTestFile(string $filePath): void
}

$inputFilePath = sys_get_temp_dir() . '/ecs_tests/' . md5((string) $inputContents) . '.php';
FileSystem::write($inputFilePath, $inputContents);
FileSystem::write($inputFilePath, $inputContents, null);

// 1. process php-cs-fixer
if ($this->fixerFileProcessor->getCheckers() !== []) {
Expand Down
Loading