Skip to content

Commit b4d9a0a

Browse files
TysonAndrecmb69
authored andcommitted
Link to SplFileInfo from is_file()/file_exists() docs
And update the list of values that can be returned by getType based on php 8.0 ext/standard/filestat.c SplFileInfo is the only way to do some things, such as 1. Check for the existence of a file that may or may not be readable without emitting a notice that is caught by whatever error handler the project uses. (e.g. file_exists can return false for unix sockets) 2. Check for file types such as unix sockets (e.g. `$info->getType() === 'socket'`) Recently, I was looking for how to check if a given path was a unix socket and the filesystem functions didn't have any links to that information. Closes GH-319.
1 parent 2bd21ff commit b4d9a0a

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

reference/filesystem/functions/file-exists.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ if (file_exists($filename)) {
9999
<member><function>is_writable</function></member>
100100
<member><function>is_file</function></member>
101101
<member><function>file</function></member>
102+
<member><classname>SplFileInfo</classname></member>
102103
</simplelist>
103104
</para>
104105
</refsect1>

reference/filesystem/functions/is-file.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ bool(false)
8383
<simplelist>
8484
<member><function>is_dir</function></member>
8585
<member><function>is_link</function></member>
86+
<member><classname>SplFileInfo</classname></member>
8687
</simplelist>
8788
</para>
8889
</refsect1>

reference/spl/splfileinfo/gettype.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
<para>
2929
A <type>string</type> representing the type of the entry.
3030
May be one of <literal>file</literal>, <literal>link</literal>,
31-
or <literal>dir</literal>
31+
<literal>dir</literal>, <literal>block</literal>, <literal>fifo</literal>,
32+
<literal>char</literal>, <literal>socket</literal>, or <literal>unknown</literal>
3233
</para>
3334
</refsect1>
3435

0 commit comments

Comments
 (0)