Edit report at https://bugs.php.net/bug.php?id=44392&edit=1
ID: 44392
Comment by: drgomesp at gmail dot com
Reported by: php at benjaminschulz dot com
Summary: getFilePointer() for Childs of SplFileObject
Status: Open
Type: Feature/Change Request
Package: SPL related
PHP Version: 5.3CVS-2008-03-10 (CVS)
Block user comment: N
Private report: N
New Comment:
Any updates on this? It would be really useful to change the visibility of this method to public.
Previous Comments:
------------------------------------------------------------------------
[2012-12-12 16:12:02] mattsch at gmail dot com
I agree that this method should also be public. Please implement this method ASAP.
------------------------------------------------------------------------
[2012-12-09 01:26:59] levim@php.net
I don't see why this method shouldn't be public. I vote for extending its
visibility to public.
------------------------------------------------------------------------
[2012-11-20 23:38:18] mattsch at gmail dot com
What's the status of this bug? SplFileObject is supposed to be an OO version of fopen but
it's quite useless to pass into other functions like curl when those functions expect a
resource.
Example:
$splFileObject = new SplFileObject('/tmp/foo', 'r');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'sftp://server.com/folder/');
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $splFileObject); # <-- won't work, must be file resource
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($localfile));
curl_exec ($ch);
curl_close($ch);
------------------------------------------------------------------------
[2008-11-14 23:49:33] jordan dot raub at dataxltd dot com
add a protected member function to SplFileObject so that extending classes can have more control of
the file handle... patch included against php5.2.6..
--- php-5.2.6/ext/spl/spl_directory.c 2008-02-13 04:23:26.000000000 -0800
+++ php52GetResource/ext/spl/spl_directory.c 2008-11-14 13:22:17.000000000 -0800
@@ -2218,6 +2218,15 @@
}
} /* }}} */
+/* {{{ proto void SplFileObject::getFileResource()
+ Seek to specified line */
+SPL_METHOD(SplFileObject, getFileResource)
+{
+ spl_filesystem_object *intern =
(spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
+
+ php_stream_to_zval(intern->u.file.stream, return_value);
+} /* }}} */
+
/* {{{ Function/Class/Method definitions */
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object___construct, 0, 0, 1)
@@ -2310,6 +2319,7 @@
SPL_ME(SplFileObject, getMaxLineLen, NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileObject, hasChildren, NULL, ZEND_ACC_PUBLIC)
SPL_ME(SplFileObject, getChildren, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(SplFileObject, getFileResource,NULL, ZEND_ACC_PROTECTED)
SPL_ME(SplFileObject, seek, arginfo_file_object_seek, ZEND_ACC_PUBLIC)
/* mappings */
SPL_MA(SplFileObject, getCurrentLine, SplFileObject, fgets, NULL, ZEND_ACC_PUBLIC)
------------------------------------------------------------------------
[2008-03-10 14:45:49] php at benjaminschulz dot com
Description:
------------
It would be nice if it would be possible to get the underlying resource handle of an SplFileObject
to be able to add stream filters on the file. Sadly the URI parser in PHP seems to be broken and
URIs with filters like php://filter/read=convert.iconv.ISO-8859-15/UTF-8/resource=... cannot be used
(encoding the slash doesn't work either (%2F)) therefore it would be nice if one could access
the underlying resource handle f.e. by providing a protected $fp in SplFileObject one could use in a
child class then and do the stream_filter_append() there.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=44392&edit=1