Skip to content

Commit afa6b43

Browse files
committed
[Filesystem] Add the readFile() method
1 parent e868539 commit afa6b43

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

ResourceCheckerConfigCache.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function write(string $content, ?array $metadata = null): void
134134
private function safelyUnserialize(string $file): mixed
135135
{
136136
$meta = false;
137-
$content = file_get_contents($file);
137+
$content = (new Filesystem())->readFile($file);
138138
$signalingException = new \UnexpectedValueException();
139139
$prevUnserializeHandler = ini_set('unserialize_callback_func', self::class.'::handleUnserializeCallback');
140140
$prevErrorHandler = set_error_handler(function ($type, $msg, $file, $line, $context = []) use (&$prevErrorHandler, $signalingException) {

Util/XmlUtils.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Config\Util\Exception\InvalidXmlException;
1515
use Symfony\Component\Config\Util\Exception\XmlParsingException;
16+
use Symfony\Component\Filesystem\Filesystem;
1617

1718
/**
1819
* XMLUtils is a bunch of utility methods to XML operations.
@@ -79,7 +80,7 @@ public static function parse(string $content, string|callable|null $schemaOrCall
7980
$valid = false;
8081
}
8182
} elseif (is_file($schemaOrCallable)) {
82-
$schemaSource = file_get_contents((string) $schemaOrCallable);
83+
$schemaSource = (new Filesystem())->readFile((string) $schemaOrCallable);
8384
$valid = @$dom->schemaValidateSource($schemaSource);
8485
} else {
8586
libxml_use_internal_errors($internalErrors);
@@ -122,7 +123,7 @@ public static function loadFile(string $file, string|callable|null $schemaOrCall
122123
throw new \InvalidArgumentException(sprintf('File "%s" is not readable.', $file));
123124
}
124125

125-
$content = @file_get_contents($file);
126+
$content = (new Filesystem())->readFile($file);
126127

127128
if ('' === trim($content)) {
128129
throw new \InvalidArgumentException(sprintf('File "%s" does not contain valid XML, it is empty.', $file));

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"require": {
1919
"php": ">=8.2",
2020
"symfony/deprecation-contracts": "^2.5|^3",
21-
"symfony/filesystem": "^6.4|^7.0",
21+
"symfony/filesystem": "^7.1",
2222
"symfony/polyfill-ctype": "~1.8"
2323
},
2424
"require-dev": {

0 commit comments

Comments
 (0)