@@ -2025,34 +2025,30 @@ static bool spl_filesystem_file_is_empty_line(spl_filesystem_object *intern) /*
20252025 if (intern -> u .file .current_line ) {
20262026 return intern -> u .file .current_line_len == 0 ;
20272027 } 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 ++ ;
20492039 }
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 ;
20552050 }
2051+ return zend_hash_num_elements (Z_ARRVAL (intern -> u .file .current_zval )) == 0 ;
20562052 } else {
20572053 return 1 ;
20582054 }
@@ -2248,6 +2244,7 @@ PHP_METHOD(SplFileObject, current)
22482244 RETURN_STRINGL (intern -> u .file .current_line , intern -> u .file .current_line_len );
22492245 } else if (!Z_ISUNDEF (intern -> u .file .current_zval )) {
22502246 ZEND_ASSERT (!Z_ISREF (intern -> u .file .current_zval ));
2247+ ZEND_ASSERT (Z_TYPE (intern -> u .file .current_zval ) == IS_ARRAY );
22512248 RETURN_COPY (& intern -> u .file .current_zval );
22522249 }
22532250 RETURN_FALSE ;
0 commit comments