|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2015-03-22 19:23 UTC] danack@php.net
-Status: Open
+Status: Assigned
-Assigned To:
+Assigned To: danack
[2015-03-22 19:23 UTC] danack@php.net
[2015-03-24 05:44 UTC] laruence@php.net
[2015-03-24 13:15 UTC] danack@php.net
[2015-03-24 19:51 UTC] danack@php.net
[2018-08-19 09:30 UTC] stephen dot reay at me dot com
[2020-11-07 13:24 UTC] cmb@php.net
[2021-12-02 17:09 UTC] cmb@php.net
-Status: Assigned
+Status: Closed
-Package: *General Issues
+Package: SPL related
[2021-12-02 17:09 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 12:00:02 2025 UTC |
Description: ------------ A class that extends SplFileObject, specifies its own constructor and is registered with SplFileInfo::setFileClass() will only be instantiated with the first argument passed to SplFileInfo::openFile(). Test script: --------------- <?php class FileObject extends \SplFileObject { public function __construct($file_name, $open_mode = 'r', $use_include_path = false, $context = null) { if (is_resource($context)) { parent::__construct($file_name, $open_mode, $use_include_path, $context); } else { parent::__construct($file_name, $open_mode, $use_include_path); } } } $file = new \SplFileInfo(__DIR__ . DIRECTORY_SEPARATOR . 'foo'); $file->setFileClass('FileObject'); $file->openFile('w+'); Expected result: ---------------- File is created Actual result: -------------- Fatal error: Uncaught exception 'RuntimeException' with message 'SplFileObject::__construct(/Users/stephen/Projects/Koalephant/Bamboo/tests/foo): failed to open stream: No such file or directory' in /Users/stephen/Projects/Koalephant/Bamboo/tests/SplFileInfoTest.php:10 Stack trace: #0 /Users/stephen/Projects/Koalephant/Bamboo/tests/SplFileInfoTest.php(10): SplFileObject->__construct('/Users/stephen/...', 'r', false) #1 [internal function]: FileObject->__construct('/Users/stephen/...', 'r') #2 /Users/stephen/Projects/Koalephant/Bamboo/tests/SplFileInfoTest.php(19): SplFileInfo->openFile('w+') #3 {main} thrown in /Users/stephen/Projects/Koalephant/Bamboo/tests/SplFileInfoTest.php on line 10