|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65269 SplFileObject::__construct() throws LogicException as well
Submitted: 2013-07-16 12:15 UTC Modified: 2017-10-24 09:21 UTC
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: benjamin dot morel at gmail dot com Assigned: salathe (profile)
Status: Assigned Package: Documentation problem
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2013-07-16 12:15 UTC] benjamin dot morel at gmail dot com
The documentation page for SplFileObject::__construct():

Throws a RuntimeException if the filename cannot be opened.

Which is true as long as the file does not exist.
However, the test script below shows that when $filename is a directory, it's 
actually a LogicException that's thrown.

The documentation thus needs to be changed as follows:

Throws a RuntimeException if the filename cannot be opened.
Throws a LogicException if the filename is a directory.

Test script:
new SplFileObject('.');

Expected result:

Actual result:
LogicException: Cannot use SplFileObject with directories


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-16 13:50 UTC]
-Assigned To: +Assigned To: salathe
 [2017-10-24 08:02 UTC]
-Status: Assigned +Status: Open -Assigned To: salathe +Assigned To:
 [2017-10-24 09:21 UTC]
-Status: Open +Status: Assigned -Assigned To: +Assigned To: salathe
 [2017-10-24 09:21 UTC]
Re-assigning to me to keep visibility.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Jun 24 17:01:25 2019 UTC