@@ -1836,34 +1836,6 @@ zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zva
1836
1836
}
1837
1837
/* }}} */
1838
1838
1839
- /* {{{ spl_filesystem_object_cast */
1840
- static int spl_filesystem_object_cast (zend_object * readobj , zval * writeobj , int type )
1841
- {
1842
- spl_filesystem_object * intern = spl_filesystem_from_obj (readobj );
1843
-
1844
- if (type == IS_STRING ) {
1845
- if (readobj -> ce -> __tostring ) {
1846
- return zend_std_cast_object_tostring (readobj , writeobj , type );
1847
- }
1848
-
1849
- switch (intern -> type ) {
1850
- case SPL_FS_INFO :
1851
- case SPL_FS_FILE :
1852
- ZVAL_STR_COPY (writeobj , intern -> file_name );
1853
- return SUCCESS ;
1854
- case SPL_FS_DIR :
1855
- ZVAL_STRING (writeobj , intern -> u .dir .entry .d_name );
1856
- return SUCCESS ;
1857
- }
1858
- } else if (type == _IS_BOOL ) {
1859
- ZVAL_TRUE (writeobj );
1860
- return SUCCESS ;
1861
- }
1862
- ZVAL_NULL (writeobj );
1863
- return FAILURE ;
1864
- }
1865
- /* }}} */
1866
-
1867
1839
static zend_result spl_filesystem_file_read_ex (spl_filesystem_object * intern , bool silent , zend_long line_add ) /* {{{ */
1868
1840
{
1869
1841
char * buf ;
@@ -2744,6 +2716,23 @@ PHP_METHOD(SplFileObject, seek)
2744
2716
}
2745
2717
} /* }}} */
2746
2718
2719
+ PHP_METHOD (SplFileObject , __toString )
2720
+ {
2721
+ if (zend_parse_parameters_none () == FAILURE ) {
2722
+ RETURN_THROWS ();
2723
+ }
2724
+
2725
+ spl_filesystem_object * intern = Z_SPLFILESYSTEM_P (ZEND_THIS );
2726
+
2727
+ CHECK_SPL_FILE_OBJECT_IS_INITIALIZED (intern );
2728
+
2729
+ if (!intern -> u .file .current_line && Z_ISUNDEF (intern -> u .file .current_zval )) {
2730
+ spl_filesystem_file_read_line (ZEND_THIS , intern , 1 );
2731
+ }
2732
+
2733
+ RETURN_STRINGL (intern -> u .file .current_line , intern -> u .file .current_line_len );
2734
+ }
2735
+
2747
2736
/* {{{ PHP_MINIT_FUNCTION(spl_directory) */
2748
2737
PHP_MINIT_FUNCTION (spl_directory )
2749
2738
{
@@ -2753,7 +2742,6 @@ PHP_MINIT_FUNCTION(spl_directory)
2753
2742
memcpy (& spl_filesystem_object_handlers , & std_object_handlers , sizeof (zend_object_handlers ));
2754
2743
spl_filesystem_object_handlers .offset = XtOffsetOf (spl_filesystem_object , std );
2755
2744
spl_filesystem_object_handlers .clone_obj = spl_filesystem_object_clone ;
2756
- spl_filesystem_object_handlers .cast_object = spl_filesystem_object_cast ;
2757
2745
spl_filesystem_object_handlers .dtor_obj = spl_filesystem_object_destroy_object ;
2758
2746
spl_filesystem_object_handlers .free_obj = spl_filesystem_object_free_storage ;
2759
2747
0 commit comments