@@ -195,6 +195,40 @@ support symbolic links, a third boolean argument is available::
195
195
// does not support symbolic links
196
196
$fs->symlink('/path/to/source', '/path/to/destination', true);
197
197
198
+ readlink
199
+ ~~~~~~~~
200
+
201
+ .. versionadded :: 3.2
202
+ The :method: `Symfony\\ Component\\ Filesystem\\ Filesystem::readlink ` method was introduced in Symfony 3.2.
203
+
204
+ :method: `Symfony\\ Component\\ Filesystem\\ Filesystem::readlink ` read links targets.
205
+
206
+ PHP's ``readlink() `` function returns the target of a symbolic link. However, its behavior
207
+ is completely different under Windows and Unix. On Windows systems, ``readlink() ``
208
+ resolves recursively the children links of a link until a final target is found. On
209
+ Unix-based systems ``readlink() `` only resolves the next link.
210
+
211
+ The :method: `Symfony\\ Component\\ Filesystem\\ Filesystem::readlink ` method provided
212
+ by the Filesystem component always behaves in the same way::
213
+
214
+ // returns the next direct target of the link without considering the existence of the target
215
+ $fs->readlink('/path/to/link');
216
+
217
+ // returns its absolute fully resolved final version of the target (if there are nested links, they are resolved)
218
+ $fs->readlink('/path/to/link', true);
219
+
220
+ Its behavior is the following::
221
+
222
+ public function readlink($path, $canonicalize = false)
223
+
224
+ * When ``$canonicalize `` is ``false ``:
225
+ * if ``$path `` does not exist or is not a link, it returns ``null ``.
226
+ * if ``$path `` is a link, it returns the next direct target of the link without considering the existence of the target.
227
+
228
+ * When ``$canonicalize `` is ``true ``:
229
+ * if ``$path `` does not exist, it returns null.
230
+ * if ``$path `` exists, it returns its absolute fully resolved final version.
231
+
198
232
makePathRelative
199
233
~~~~~~~~~~~~~~~~
200
234
0 commit comments