Skip to content

Commit 139aa4f

Browse files
committed
fix: #243
1 parent cd3be80 commit 139aa4f

File tree

2 files changed

+72
-18
lines changed

2 files changed

+72
-18
lines changed

kernel/read.c

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -198,30 +198,35 @@ void data_to_custom_type(const char *string_value, const size_t string_value_len
198198
STRING:
199199

200200
{
201-
zend_long _long = 0; double _double = 0;
202-
203201
if (!(type & READ_TYPE_STRING)) {
202+
zend_long _long = 0; double _double = 0;
204203
is_numeric_string(string_value, string_value_length, &_long, &_double, 0);
205-
}
206204

207-
if (Z_TYPE_P(zv_result_t) == IS_ARRAY) {
208-
if (_double > 0) {
209-
add_index_double(zv_result_t, zv_hashtable_index, _double);
210-
return;
211-
} else if (_long > 0) {
212-
add_index_long(zv_result_t, zv_hashtable_index, _long);
213-
return;
214-
}
205+
if (Z_TYPE_P(zv_result_t) == IS_ARRAY) {
206+
if (_double > 0) {
207+
add_index_double(zv_result_t, zv_hashtable_index, _double);
208+
return;
209+
}
215210

216-
add_index_stringl(zv_result_t, zv_hashtable_index, string_value, string_value_length);
217-
return;
211+
if (_long > 0) {
212+
add_index_long(zv_result_t, zv_hashtable_index, _long);
213+
return;
214+
}
215+
} else {
216+
if (_double > 0) {
217+
ZVAL_DOUBLE(zv_result_t, _double);
218+
return;
219+
}
220+
221+
if (_long > 0) {
222+
ZVAL_LONG(zv_result_t, _long);
223+
return;
224+
}
225+
}
218226
}
219227

220-
if (_double > 0) {
221-
ZVAL_DOUBLE(zv_result_t, _double);
222-
return;
223-
} else if (_long > 0) {
224-
ZVAL_LONG(zv_result_t, _long);
228+
if (Z_TYPE_P(zv_result_t) == IS_ARRAY) {
229+
add_index_stringl(zv_result_t, zv_hashtable_index, string_value, string_value_length);
225230
return;
226231
}
227232

tests/fix-243.phpt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
Check for vtiful presence
3+
--SKIPIF--
4+
<?php
5+
require __DIR__ . '/include/skipif.inc';
6+
skip_disable_reader();
7+
?>
8+
--FILE--
9+
<?php
10+
$config = ['path' => './tests'];
11+
$excel = new \Vtiful\Kernel\Excel($config);
12+
13+
$filePath = $excel->fileName('tutorial.xlsx')
14+
->header(['NumberToString', 'Number'])
15+
->data([
16+
['01234567', '01234567']
17+
])
18+
->output();
19+
20+
$data = $excel->openFile('tutorial.xlsx')
21+
->openSheet()
22+
->setType([
23+
\Vtiful\Kernel\Excel::TYPE_STRING,
24+
])
25+
->getSheetData();
26+
27+
var_dump($data);
28+
?>
29+
--CLEAN--
30+
<?php
31+
@unlink(__DIR__ . '/tutorial.xlsx');
32+
?>
33+
--EXPECT--
34+
array(2) {
35+
[0]=>
36+
array(2) {
37+
[0]=>
38+
string(14) "NumberToString"
39+
[1]=>
40+
string(6) "Number"
41+
}
42+
[1]=>
43+
array(2) {
44+
[0]=>
45+
string(8) "01234567"
46+
[1]=>
47+
int(1234567)
48+
}
49+
}

0 commit comments

Comments
 (0)