From 2ebec3bf1a75d1572e405b63215faa01a137be31 Mon Sep 17 00:00:00 2001 From: Issam KHADIRI Date: Sun, 20 Feb 2022 11:40:50 +0100 Subject: [PATCH] Update filesystem.rst Hello, According to the `getLongestCommonBasePath` signature, the method accepts a variadic string parameter $paths and not an array. It means when calling the `Path::getLongestCommonBasePath` with an array, a `TypeError` occurs. I think even the PHPDoc of the `Path::getLongestCommonBasePath` should be updated too as it is mentionned that it can accept an array argument. --- components/filesystem.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/components/filesystem.rst b/components/filesystem.rst index e60e0b389af..091c42c5df3 100644 --- a/components/filesystem.rst +++ b/components/filesystem.rst @@ -438,15 +438,13 @@ Especially when storing many paths, the amount of duplicated information is noticeable. You can use :method:`Symfony\\Component\\Filesystem\\Path::getLongestCommonBasePath` to check a list of paths for a common base path:: - $paths = [ + Path::getLongestCommonBasePath( '/var/www/vhosts/project/httpdocs/config/config.yaml', '/var/www/vhosts/project/httpdocs/config/routing.yaml', '/var/www/vhosts/project/httpdocs/config/services.yaml', '/var/www/vhosts/project/httpdocs/images/banana.gif', - '/var/www/vhosts/project/httpdocs/uploads/images/nicer-banana.gif', - ]; - - Path::getLongestCommonBasePath($paths); + '/var/www/vhosts/project/httpdocs/uploads/images/nicer-banana.gif' + ); // => /var/www/vhosts/project/httpdocs Use this path together with :method:`Symfony\\Component\\Filesystem\\Path::makeRelative`