php.net |  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
Votes:2
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
Description:
------------
The documentation page for SplFileObject::__construct():
http://uk1.php.net/manual/en/splfileobject.construct.php

Says:
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:
----------------
RuntimeException

Actual result:
--------------
LogicException: Cannot use SplFileObject with directories

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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