@@ -2025,34 +2025,30 @@ static bool spl_filesystem_file_is_empty_line(spl_filesystem_object *intern) /*
2025
2025
if (intern -> u .file .current_line ) {
2026
2026
return intern -> u .file .current_line_len == 0 ;
2027
2027
} else if (!Z_ISUNDEF (intern -> u .file .current_zval )) {
2028
- switch (Z_TYPE (intern -> u .file .current_zval )) {
2029
- case IS_STRING :
2030
- return Z_STRLEN (intern -> u .file .current_zval ) == 0 ;
2031
- case IS_ARRAY :
2032
- if (SPL_HAS_FLAG (intern -> flags , SPL_FILE_OBJECT_READ_CSV )
2033
- && zend_hash_num_elements (Z_ARRVAL (intern -> u .file .current_zval )) == 1 ) {
2034
- uint32_t idx = 0 ;
2035
- zval * first ;
2036
-
2037
- if (HT_IS_PACKED (Z_ARRVAL (intern -> u .file .current_zval ))) {
2038
- while (Z_ISUNDEF (Z_ARRVAL (intern -> u .file .current_zval )-> arPacked [idx ])) {
2039
- idx ++ ;
2040
- }
2041
- first = & Z_ARRVAL (intern -> u .file .current_zval )-> arPacked [idx ];
2042
- } else {
2043
- while (Z_ISUNDEF (Z_ARRVAL (intern -> u .file .current_zval )-> arData [idx ].val )) {
2044
- idx ++ ;
2045
- }
2046
- first = & Z_ARRVAL (intern -> u .file .current_zval )-> arData [idx ].val ;
2047
- }
2048
- return Z_TYPE_P (first ) == IS_STRING && Z_STRLEN_P (first ) == 0 ;
2028
+ ZEND_ASSERT (Z_TYPE (intern -> u .file .current_zval ) == IS_ARRAY );
2029
+ /* TODO Figure out when this branch can happen... */
2030
+ if (SPL_HAS_FLAG (intern -> flags , SPL_FILE_OBJECT_READ_CSV )
2031
+ && zend_hash_num_elements (Z_ARRVAL (intern -> u .file .current_zval )) == 1 ) {
2032
+ ZEND_ASSERT (false && "Can this happen?" );
2033
+ uint32_t idx = 0 ;
2034
+ zval * first ;
2035
+
2036
+ if (HT_IS_PACKED (Z_ARRVAL (intern -> u .file .current_zval ))) {
2037
+ while (Z_ISUNDEF (Z_ARRVAL (intern -> u .file .current_zval )-> arPacked [idx ])) {
2038
+ idx ++ ;
2049
2039
}
2050
- return zend_hash_num_elements (Z_ARRVAL (intern -> u .file .current_zval )) == 0 ;
2051
- case IS_NULL :
2052
- return 1 ;
2053
- default :
2054
- return 0 ;
2040
+ first = & Z_ARRVAL (intern -> u .file .current_zval )-> arPacked [idx ];
2041
+ ZEND_ASSERT (Z_TYPE_P (first ) == IS_STRING );
2042
+ } else {
2043
+ while (Z_ISUNDEF (Z_ARRVAL (intern -> u .file .current_zval )-> arData [idx ].val )) {
2044
+ idx ++ ;
2045
+ }
2046
+ first = & Z_ARRVAL (intern -> u .file .current_zval )-> arData [idx ].val ;
2047
+ ZEND_ASSERT (Z_TYPE_P (first ) == IS_STRING );
2048
+ }
2049
+ return Z_STRLEN_P (first ) == 0 ;
2055
2050
}
2051
+ return zend_hash_num_elements (Z_ARRVAL (intern -> u .file .current_zval )) == 0 ;
2056
2052
} else {
2057
2053
return 1 ;
2058
2054
}
@@ -2248,6 +2244,7 @@ PHP_METHOD(SplFileObject, current)
2248
2244
RETURN_STRINGL (intern -> u .file .current_line , intern -> u .file .current_line_len );
2249
2245
} else if (!Z_ISUNDEF (intern -> u .file .current_zval )) {
2250
2246
ZEND_ASSERT (!Z_ISREF (intern -> u .file .current_zval ));
2247
+ ZEND_ASSERT (Z_TYPE (intern -> u .file .current_zval ) == IS_ARRAY );
2251
2248
RETURN_COPY (& intern -> u .file .current_zval );
2252
2249
}
2253
2250
RETURN_FALSE ;
0 commit comments