v1.1.4
This commit is contained in:
parent
d6e6011c3d
commit
1dd5809016
5 changed files with 21760 additions and 3778 deletions
97
vendor/symfony/filesystem/CHANGELOG.md
vendored
Normal file
97
vendor/symfony/filesystem/CHANGELOG.md
vendored
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
8.1
|
||||
---
|
||||
|
||||
* Deprecate calling `Filesystem::mirror()` with option `copy_on_windows`, use option `follow_symlinks` instead.
|
||||
|
||||
7.1
|
||||
---
|
||||
|
||||
* Add the `Filesystem::readFile()` method
|
||||
|
||||
7.0
|
||||
---
|
||||
|
||||
* Add argument `$lock` to `Filesystem::appendToFile()`
|
||||
|
||||
5.4
|
||||
---
|
||||
|
||||
* Add `Path` class
|
||||
* Add `$lock` argument to `Filesystem::appendToFile()`
|
||||
|
||||
5.0.0
|
||||
-----
|
||||
|
||||
* `Filesystem::dumpFile()` and `appendToFile()` don't accept arrays anymore
|
||||
|
||||
4.4.0
|
||||
-----
|
||||
|
||||
* support for passing a `null` value to `Filesystem::isAbsolutePath()` is deprecated and will be removed in 5.0
|
||||
* `tempnam()` now accepts a third argument `$suffix`.
|
||||
|
||||
4.3.0
|
||||
-----
|
||||
|
||||
* support for passing arrays to `Filesystem::dumpFile()` is deprecated and will be removed in 5.0
|
||||
* support for passing arrays to `Filesystem::appendToFile()` is deprecated and will be removed in 5.0
|
||||
|
||||
4.0.0
|
||||
-----
|
||||
|
||||
* removed `LockHandler`
|
||||
* Support for passing relative paths to `Filesystem::makePathRelative()` has been removed.
|
||||
|
||||
3.4.0
|
||||
-----
|
||||
|
||||
* support for passing relative paths to `Filesystem::makePathRelative()` is deprecated and will be removed in 4.0
|
||||
|
||||
3.3.0
|
||||
-----
|
||||
|
||||
* added `appendToFile()` to append contents to existing files
|
||||
|
||||
3.2.0
|
||||
-----
|
||||
|
||||
* added `readlink()` as a platform independent method to read links
|
||||
|
||||
3.0.0
|
||||
-----
|
||||
|
||||
* removed `$mode` argument from `Filesystem::dumpFile()`
|
||||
|
||||
2.8.0
|
||||
-----
|
||||
|
||||
* added tempnam() a stream aware version of PHP's native tempnam()
|
||||
|
||||
2.6.0
|
||||
-----
|
||||
|
||||
* added LockHandler
|
||||
|
||||
2.3.12
|
||||
------
|
||||
|
||||
* deprecated dumpFile() file mode argument.
|
||||
|
||||
2.3.0
|
||||
-----
|
||||
|
||||
* added the dumpFile() method to atomically write files
|
||||
|
||||
2.2.0
|
||||
-----
|
||||
|
||||
* added a delete option for the mirror() method
|
||||
|
||||
2.1.0
|
||||
-----
|
||||
|
||||
* 24eb396 : BC Break : mkdir() function now throws exception in case of failure instead of returning Boolean value
|
||||
* created the component
|
||||
28
vendor/symfony/filesystem/Filesystem.php
vendored
28
vendor/symfony/filesystem/Filesystem.php
vendored
|
|
@ -69,8 +69,8 @@ class Filesystem
|
|||
}
|
||||
|
||||
if ($originIsLocal) {
|
||||
// Like `cp`, preserve executable permission bits
|
||||
self::box('chmod', $targetFile, fileperms($targetFile) | (fileperms($originFile) & 0o111));
|
||||
// Like `cp`, preserve the source mode masked by the umask
|
||||
self::box('chmod', $targetFile, fileperms($originFile) & 0o777 & ~umask());
|
||||
|
||||
// Like `cp`, preserve the file modification time
|
||||
self::box('touch', $targetFile, filemtime($originFile));
|
||||
|
|
@ -443,17 +443,19 @@ class Filesystem
|
|||
throw new InvalidArgumentException(\sprintf('The end path "%s" is not absolute.', $endPath));
|
||||
}
|
||||
|
||||
$originalEndPath = $endPath;
|
||||
|
||||
// Normalize separators on Windows
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$endPath = str_replace('\\', '/', $endPath);
|
||||
$startPath = str_replace('\\', '/', $startPath);
|
||||
}
|
||||
|
||||
$splitDriveLetter = fn ($path) => (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0]))
|
||||
$splitDriveLetter = static fn ($path) => (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0]))
|
||||
? [substr($path, 2), strtoupper($path[0])]
|
||||
: [$path, null];
|
||||
|
||||
$splitPath = function ($path) {
|
||||
$splitPath = static function ($path) {
|
||||
$result = [];
|
||||
|
||||
foreach (explode('/', trim($path, '/')) as $segment) {
|
||||
|
|
@ -499,6 +501,11 @@ class Filesystem
|
|||
// Construct $endPath from traversing to the common path, then to the remaining $endPath
|
||||
$relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
|
||||
|
||||
// Remove ending "/" if $endPath points to an existing file
|
||||
if (str_ends_with($relativePath, '/') && is_file($originalEndPath)) {
|
||||
$relativePath = substr($relativePath, 0, -1);
|
||||
}
|
||||
|
||||
return '' === $relativePath ? './' : $relativePath;
|
||||
}
|
||||
|
||||
|
|
@ -514,13 +521,18 @@ class Filesystem
|
|||
* @param array $options An array of boolean options
|
||||
* Valid options are:
|
||||
* - $options['override'] If true, target files newer than origin files are overwritten (see copy(), defaults to false)
|
||||
* - $options['copy_on_windows'] Whether to copy files instead of links on Windows (see symlink(), defaults to false)
|
||||
* - $options['follow_symlinks'] Whether to copy files instead of links, esp. useful on Windows (see symlink(), defaults to false)
|
||||
* - $options['copy_on_windows'] @deprecated since Symfony 8.1, use $options['follow_symlinks'] instead
|
||||
* - $options['delete'] Whether to delete files that are not in the source directory (defaults to false)
|
||||
*
|
||||
* @throws IOException When file type is unknown
|
||||
*/
|
||||
public function mirror(string $originDir, string $targetDir, ?\Traversable $iterator = null, array $options = []): void
|
||||
{
|
||||
if (isset($options['copy_on_windows'])) {
|
||||
trigger_deprecation('symfony/filesystem', '8.1', 'Calling "%s()" with option "copy_on_windows" is deprecated, use option "follow_symlinks" instead.', __METHOD__);
|
||||
}
|
||||
|
||||
$targetDir = rtrim($targetDir, '/\\');
|
||||
$originDir = rtrim($originDir, '/\\');
|
||||
$originDirLen = \strlen($originDir);
|
||||
|
|
@ -545,10 +557,10 @@ class Filesystem
|
|||
}
|
||||
}
|
||||
|
||||
$copyOnWindows = $options['copy_on_windows'] ?? false;
|
||||
$followSymlinks = $options['follow_symlinks'] ?? $options['copy_on_windows'] ?? false;
|
||||
|
||||
if (null === $iterator) {
|
||||
$flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
|
||||
$flags = $followSymlinks ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
|
||||
}
|
||||
|
||||
|
|
@ -563,7 +575,7 @@ class Filesystem
|
|||
$target = $targetDir.substr($file->getPathname(), $originDirLen);
|
||||
$filesCreatedWhileMirroring[$target] = true;
|
||||
|
||||
if (!$copyOnWindows && is_link($file)) {
|
||||
if (!$followSymlinks && is_link($file)) {
|
||||
$this->symlink($file->getLinkTarget(), $target);
|
||||
} elseif (is_dir($file)) {
|
||||
$this->mkdir($target);
|
||||
|
|
|
|||
88
vendor/symfony/filesystem/Path.php
vendored
88
vendor/symfony/filesystem/Path.php
vendored
|
|
@ -17,9 +17,10 @@ use Symfony\Component\Filesystem\Exception\RuntimeException;
|
|||
/**
|
||||
* Contains utility methods for handling path strings.
|
||||
*
|
||||
* The methods in this class are able to deal with both UNIX and Windows paths
|
||||
* with both forward and backward slashes. All methods return normalized parts
|
||||
* containing only forward slashes and no excess "." and ".." segments.
|
||||
* The methods in this class are able to deal with both UNIX and Windows paths.
|
||||
* On Windows, backward slashes are normalized to forward slashes. On UNIX,
|
||||
* backward slashes are treated as valid filename characters and are not replaced.
|
||||
* All methods return normalized parts with no excess "." and ".." segments.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
* @author Thomas Schulz <mail@king2500.net>
|
||||
|
|
@ -49,14 +50,11 @@ final class Path
|
|||
/**
|
||||
* Canonicalizes the given path.
|
||||
*
|
||||
* During normalization, all slashes are replaced by forward slashes ("/").
|
||||
* Furthermore, all "." and ".." segments are removed as far as possible.
|
||||
* ".." segments at the beginning of relative paths are not removed.
|
||||
* During normalization, all "." and ".." segments are removed as far as
|
||||
* possible. ".." segments at the beginning of relative paths are not removed.
|
||||
* On Windows, backward slashes are replaced by forward slashes ("/").
|
||||
*
|
||||
* ```php
|
||||
* echo Path::canonicalize("\symfony\puli\..\css\style.css");
|
||||
* // => /symfony/css/style.css
|
||||
*
|
||||
* echo Path::canonicalize("../css/./style.css");
|
||||
* // => ../css/style.css
|
||||
* ```
|
||||
|
|
@ -103,17 +101,16 @@ final class Path
|
|||
/**
|
||||
* Normalizes the given path.
|
||||
*
|
||||
* During normalization, all slashes are replaced by forward slashes ("/").
|
||||
* On Windows, backward slashes are replaced by forward slashes ("/").
|
||||
* On UNIX, backward slashes are preserved as they are valid filename characters.
|
||||
* Contrary to {@link canonicalize()}, this method does not remove invalid
|
||||
* or dot path segments. Consequently, it is much more efficient and should
|
||||
* be used whenever the given path is known to be a valid, absolute system
|
||||
* path.
|
||||
*
|
||||
* This method is able to deal with both UNIX and Windows paths.
|
||||
*/
|
||||
public static function normalize(string $path): string
|
||||
{
|
||||
return str_replace('\\', '/', $path);
|
||||
return '\\' === \DIRECTORY_SEPARATOR ? str_replace('\\', '/', $path) : $path;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -225,8 +222,15 @@ final class Path
|
|||
|
||||
$firstCharacter = $path[0];
|
||||
|
||||
// UNIX root "/" or "\" (Windows style)
|
||||
if ('/' === $firstCharacter || '\\' === $firstCharacter) {
|
||||
if ('/' === $firstCharacter) {
|
||||
return $scheme.'/';
|
||||
}
|
||||
|
||||
if ('\\' !== \DIRECTORY_SEPARATOR) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ('\\' === $firstCharacter) {
|
||||
return $scheme.'/';
|
||||
}
|
||||
|
||||
|
|
@ -239,7 +243,7 @@ final class Path
|
|||
return $scheme.$path.'/';
|
||||
}
|
||||
|
||||
// Normal case: "C:/ or "C:\"
|
||||
// Normal case: "C:/" or "C:\"
|
||||
if ('/' === $path[2] || '\\' === $path[2]) {
|
||||
return $scheme.$firstCharacter.$path[1].'/';
|
||||
}
|
||||
|
|
@ -363,13 +367,41 @@ final class Path
|
|||
*/
|
||||
public static function isAbsolute(string $path): bool
|
||||
{
|
||||
return '' !== $path && (strspn($path, '/\\', 0, 1)
|
||||
|| (\strlen($path) > 3 && ctype_alpha($path[0])
|
||||
&& ':' === $path[1]
|
||||
&& strspn($path, '/\\', 2, 1)
|
||||
)
|
||||
|| null !== parse_url($path, \PHP_URL_SCHEME)
|
||||
);
|
||||
if ('' === $path) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// URLs and stream wrappers are considered absolute
|
||||
if (str_contains($path, '://') && null !== parse_url($path, \PHP_URL_SCHEME)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ('/' === $path[0]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ('\\' !== \DIRECTORY_SEPARATOR) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ('\\' === $path[0]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Windows root
|
||||
if (\strlen($path) > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
|
||||
// Special case: "C:"
|
||||
if (2 === \strlen($path)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Normal case: "C:/" or "C:\"
|
||||
if ('/' === $path[2] || '\\' === $path[2]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function isRelative(string $path): bool
|
||||
|
|
@ -435,7 +467,7 @@ final class Path
|
|||
$scheme = '';
|
||||
}
|
||||
|
||||
return $scheme.self::canonicalize(rtrim($basePath, '/\\').'/'.$path);
|
||||
return $scheme.self::canonicalize(rtrim($basePath, '/'.\DIRECTORY_SEPARATOR).'/'.$path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -502,7 +534,7 @@ final class Path
|
|||
if ('' === $root && '' !== $baseRoot) {
|
||||
// If base path is already in its root
|
||||
if ('' === $relativeBasePath) {
|
||||
$relativePath = ltrim($relativePath, './\\');
|
||||
$relativePath = ltrim($relativePath, './'.\DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
return $relativePath;
|
||||
|
|
@ -647,8 +679,8 @@ final class Path
|
|||
continue;
|
||||
}
|
||||
|
||||
// Only add slash if previous part didn't end with '/' or '\'
|
||||
if (!\in_array(substr($finalPath, -1), ['/', '\\'], true)) {
|
||||
// Only add slash if previous part didn't end with '/' or '\' (Windows)
|
||||
if ('/' !== substr($finalPath, -1) && \DIRECTORY_SEPARATOR !== substr($finalPath, -1)) {
|
||||
$finalPath .= '/';
|
||||
}
|
||||
|
||||
|
|
@ -766,7 +798,7 @@ final class Path
|
|||
if (str_starts_with($path, '/')) {
|
||||
$root .= '/';
|
||||
$path = $length > 1 ? substr($path, 1) : '';
|
||||
} elseif ($length > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
|
||||
} elseif ('\\' === \DIRECTORY_SEPARATOR && $length > 1 && ctype_alpha($path[0]) && ':' === $path[1]) {
|
||||
if (2 === $length) {
|
||||
// Windows special case: "C:"
|
||||
$root .= $path.'/';
|
||||
|
|
|
|||
23
vendor/symfony/filesystem/README.md
vendored
Normal file
23
vendor/symfony/filesystem/README.md
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
Filesystem Component
|
||||
====================
|
||||
|
||||
The Filesystem component provides basic utilities for the filesystem.
|
||||
|
||||
Sponsor
|
||||
-------
|
||||
|
||||
This package is looking for a [backer][1].
|
||||
|
||||
Help Symfony by [sponsoring][3] its development!
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
* [Documentation](https://symfony.com/doc/current/components/filesystem.html)
|
||||
* [Contributing](https://symfony.com/doc/current/contributing/index.html)
|
||||
* [Report issues](https://github.com/symfony/symfony/issues) and
|
||||
[send Pull Requests](https://github.com/symfony/symfony/pulls)
|
||||
in the [main Symfony repository](https://github.com/symfony/symfony)
|
||||
|
||||
[1]: https://symfony.com/backers
|
||||
[3]: https://symfony.com/sponsor
|
||||
33
vendor/symfony/filesystem/composer.json
vendored
33
vendor/symfony/filesystem/composer.json
vendored
|
|
@ -1,33 +0,0 @@
|
|||
{
|
||||
"name": "symfony/filesystem",
|
||||
"type": "library",
|
||||
"description": "Provides basic utilities for the filesystem",
|
||||
"keywords": [],
|
||||
"homepage": "https://symfony.com",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
},
|
||||
{
|
||||
"name": "Symfony Community",
|
||||
"homepage": "https://symfony.com/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.2",
|
||||
"symfony/polyfill-ctype": "~1.8",
|
||||
"symfony/polyfill-mbstring": "~1.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/process": "^6.4|^7.0|^8.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\Filesystem\\": "" },
|
||||
"exclude-from-classmap": [
|
||||
"/Tests/"
|
||||
]
|
||||
},
|
||||
"minimum-stability": "dev"
|
||||
}
|
||||
Loading…
Reference in a new issue