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: Closed Package: Documentation problem
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
 [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.
 [2019-06-26 07:56 UTC] nikic@php.net
Automatic comment from SVN on behalf of nikic
Revision: http://svn.php.net/viewvc/?view=revision&revision=347670
Log: Fix bug #65269: SplFileObject::__construct() throws LogicException as well

Fix for [bug 65269](https://bugs.php.net/bug.php?id=65269).

Patch by BenMorel.

Closes GH-3.
 [2019-06-26 08:00 UTC] salathe@php.net
Automatic comment on behalf of nikic
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=a609fed7da9bfe11fb9c03e448281279f74b660b
Log: Fix bug #65269: SplFileObject::__construct() throws LogicException as well
 [2019-06-26 08:00 UTC] salathe@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 17:01:25 2019 UTC