PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
← All changes | libraries/excel-reader.class.php +111 -122 1.9.2 → 3.4 View file →
@@ -2,8 +2,9 @@
2 2 /**
3 3 * Excel 97/2003 Reader Class
4 4 *
5 5 * Based on PHP Excel Reader 2.21.
6 + *
6 7 * @link https://code.google.com/archive/p/php-excel-reader/
7 8 *
8 9 * @package TablePress
9 10 * @subpackage Import
@@ -10,8 +11,10 @@
10 11 * @author Matt Kruse, Matt Roxburgh, Vadim Tkachenko, Tobias Bäthge
11 12 * @since 1.1.0
12 13 */
13 14
15 +declare(strict_types=1);
16 +
14 17 // Prohibit direct script loading.
15 18 defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
16 19
17 20 /**
@@ -56,35 +59,31 @@
56 59 /**
57 60 * [$data description]
58 61 *
59 62 * @since 1.0.0
60 - * @var string
61 63 */
62 - protected $data = '';
64 + protected string $data = '';
63 65
64 66 /**
65 67 * [$error description]
66 68 *
67 69 * @since 1.0.0
68 - * @var int
69 70 */
70 - public $error;
71 + public int $error;
71 72
72 73 /**
73 74 * [$bigBlockChain description]
74 75 *
75 76 * @since 1.0.0
76 - * @var array
77 77 */
78 - protected $bigBlockChain = array();
78 + protected array $bigBlockChain = array();
79 79
80 80 /**
81 81 * [$smallBlockChain description]
82 82 *
83 83 * @since 1.0.0
84 - * @var array
85 84 */
86 - protected $smallBlockChain = array();
85 + protected array $smallBlockChain = array();
87 86
88 87 /**
89 88 * [$entry description]
90 89 *
@@ -130,9 +129,9 @@
130 129 * [read description]
131 130 *
132 131 * @since 1.0.0
133 132 *
134 - * @param [type] $data [description]
133 + * @param string $data [description]
135 134 * @return [type] [description]
136 135 */
137 136 public function read( $data ) {
138 137 $this->data = $data;
@@ -139,9 +138,9 @@
139 138 if ( ! $this->data ) {
140 139 $this->error = 1;
141 140 return false;
142 141 }
143 - if ( IDENTIFIER_OLE !== substr( $this->data, 0, 8 ) ) {
142 + if ( str_starts_with( $this->data, IDENTIFIER_OLE ) ) {
144 143 $this->error = 2;
145 144 return false;
146 145 }
147 146 $numBigBlockDepotBlocks = $this->_GetInt4d( $this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS );
@@ -185,9 +184,9 @@
185 184 $pos = ( $bigBlockDepotBlocks[ $i ] + 1 ) * BIG_BLOCK_SIZE;
186 185 for ( $j = 0; $j < BIG_BLOCK_SIZE / 4; $j++ ) {
187 186 $this->bigBlockChain[ $index ] = $this->_GetInt4d( $this->data, $pos );
188 187 $pos += 4;
189 - $index++;
188 + ++$index;
190 189 }
191 190 }
192 191
193 192 // readSmallBlockDepot();
@@ -199,9 +198,9 @@
199 198 $pos = ( $sbdBlock + 1 ) * BIG_BLOCK_SIZE;
200 199 for ( $j = 0; $j < BIG_BLOCK_SIZE / 4; $j++ ) {
201 200 $this->smallBlockChain[ $index ] = $this->_GetInt4d( $this->data, $pos );
202 201 $pos += 4;
203 - $index++;
202 + ++$index;
204 203 }
205 204 $sbdBlock = $this->bigBlockChain[ $sbdBlock ];
206 205 }
207 206
@@ -206,21 +205,21 @@
206 205 }
207 206
208 207 // readData(rootStartBlock)
209 208 $block = $rootStartBlock;
210 - $this->entry = $this->__readData( $block );
211 - $this->__readPropertySets();
209 + $this->entry = $this->_readData( $block );
210 + $this->_readPropertySets();
212 211 }
213 212
214 213 /**
215 - * [__readData description]
214 + * [_readData description]
216 215 *
217 216 * @since 1.0.0
218 217 *
219 218 * @param [type] $bl [description]
220 - * @return [type] [description]
219 + * @return string [description]
221 220 */
222 - protected function __readData( $bl ) {
221 + protected function _readData( $bl ): string {
223 222 $block = $bl;
224 223 $data = '';
225 224 while ( -2 !== $block ) {
226 225 $pos = ( $block + 1 ) * BIG_BLOCK_SIZE;
@@ -230,15 +229,15 @@
230 229 return $data;
231 230 }
232 231
233 232 /**
234 - * [__readPropertySets description]
233 + * [_readPropertySets description]
235 234 *
236 235 * @since 1.0.0
237 236 *
238 237 * @return [type] [description]
239 238 */
240 - protected function __readPropertySets() {
239 + protected function _readPropertySets() {
241 240 $offset = 0;
242 241 while ( $offset < strlen( $this->entry ) ) {
243 242 $d = substr( $this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE );
244 243 $nameSize = ord( $d[ SIZE_OF_NAME_POS ] ) | ( ord( $d[ SIZE_OF_NAME_POS + 1 ] ) << 8 );
@@ -274,9 +273,9 @@
274 273 * @return [type] [description]
275 274 */
276 275 public function getWorkBook() {
277 276 if ( $this->props[ $this->wrkbook ]['size'] < SMALL_BLOCK_THRESHOLD ) {
278 - $rootdata = $this->__readData( $this->props[ $this->rootentry ]['startBlock'] );
277 + $rootdata = $this->_readData( $this->props[ $this->rootentry ]['startBlock'] );
279 278 $streamData = '';
280 279 $block = $this->props[ $this->wrkbook ]['startBlock'];
281 280 while ( -2 !== $block ) {
282 281 $pos = $block * SMALL_BLOCK_SIZE;
@@ -286,9 +285,9 @@
286 285 return $streamData;
287 286 } else {
288 287 $numBlocks = $this->props[ $this->wrkbook ]['size'] / BIG_BLOCK_SIZE;
289 288 if ( 0 !== $this->props[ $this->wrkbook ]['size'] % BIG_BLOCK_SIZE ) {
290 - $numBlocks++;
289 + ++$numBlocks;
291 290 }
292 291
293 292 if ( 0 === $numBlocks ) {
294 293 return '';
@@ -310,11 +309,11 @@
310 309 * @since 1.0.0
311 310 *
312 311 * @param [type] $data [description]
313 312 * @param [type] $pos [description]
314 - * @return [type] [description]
313 + * @return int [description]
315 314 */
316 - protected function _GetInt4d( $data, $pos ) {
315 + protected function _GetInt4d( $data, $pos ): int {
317 316 $value = ord( $data[ $pos ] ) | ( ord( $data[ $pos + 1 ] ) << 8 ) | ( ord( $data[ $pos + 2 ] ) << 16 ) | ( ord( $data[ $pos + 3 ] ) << 24 );
318 317 if ( $value >= 4294967294 ) {
319 318 $value = -2;
320 319 }
@@ -368,11 +367,11 @@
368 367 define( 'SPREADSHEET_EXCEL_READER_TYPE_DEFCOLWIDTH', 0x55 );
369 368 define( 'SPREADSHEET_EXCEL_READER_TYPE_STANDARDWIDTH', 0x99 );
370 369 define( 'SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT', '%s' );
371 370
372 -/*
373 -* Main Class
374 -*/
371 +/**
372 + * Main Class
373 + */
375 374 class Spreadsheet_Excel_Reader {
376 375
377 376 /*
378 377 * The following four public constants were added to make data retrieval easier.
@@ -381,35 +380,31 @@
381 380 /**
382 381 * [$colnames description]
383 382 *
384 383 * @since 1.0.0
385 - * @var array
386 384 */
387 - public $colnames = array();
385 + public array $colnames = array();
388 386
389 387 /**
390 388 * [$colindexes description]
391 389 *
392 390 * @since 1.0.0
393 - * @var array
394 391 */
395 - public $colindexes = array();
392 + public array $colindexes = array();
396 393
397 394 /**
398 395 * [$standardColWidth description]
399 396 *
400 397 * @since 1.0.0
401 - * @var int
402 398 */
403 - public $standardColWidth = 0;
399 + public int $standardColWidth = 0;
404 400
405 401 /**
406 402 * [$defaultColWidth description]
407 403 *
408 404 * @since 1.0.0
409 - * @var int
410 405 */
411 - public $defaultColWidth = 0;
406 + public int $defaultColWidth = 0;
412 407
413 408 /**
414 409 * [$store_extended_info description]
415 410 *
@@ -447,11 +442,11 @@
447 442 *
448 443 * @since 1.0.0
449 444 *
450 445 * @param [type] $d [description]
451 - * @return [type] [description]
446 + * @return string [description]
452 447 */
453 - protected function myHex( $d ) {
448 + protected function myHex( $d ): string {
454 449 if ( $d < 16 ) {
455 450 return '0' . dechex( $d );
456 451 }
457 452 return dechex( $d );
@@ -464,11 +459,11 @@
464 459 *
465 460 * @param [type] $data [description]
466 461 * @param [type] $pos [description]
467 462 * @param [type] $length [description]
468 - * @return [type] [description]
463 + * @return string [description]
469 464 */
470 - protected function dumpHexData( $data, $pos, $length ) {
465 + protected function dumpHexData( $data, $pos, $length ): string {
471 466 $info = '';
472 467 for ( $i = 0; $i <= $length; $i++ ) {
473 468 if ( 0 !== $i ) {
474 469 $info .= ' ';
@@ -588,11 +583,11 @@
588 583 *
589 584 * @param [type] $row [description]
590 585 * @param [type] $col [description]
591 586 * @param int $sheet Optional. [description]
592 - * @return [type] [description]
587 + * @return int [description]
593 588 */
594 - public function rowspan( $row, $col, $sheet = 0 ) {
589 + public function rowspan( $row, $col, $sheet = 0 ): int {
595 590 $value = $this->info( $row, $col, 'rowspan', $sheet );
596 591 if ( '' === $value ) {
597 592 return 1;
598 593 } else {
@@ -608,11 +603,11 @@
608 603 *
609 604 * @param [type] $row [description]
610 605 * @param [type] $col [description]
611 606 * @param int $sheet Optional. [description]
612 - * @return [type] [description]
607 + * @return int [description]
613 608 */
614 - public function colspan( $row, $col, $sheet = 0 ) {
609 + public function colspan( $row, $col, $sheet = 0 ): int {
615 610 $value = $this->info( $row, $col, 'colspan', $sheet );
616 611 if ( '' === $value ) {
617 612 return 1;
618 613 } else {
@@ -683,11 +678,11 @@
683 678 * @since 1.0.0
684 679 *
685 680 * @param [type] $col [description]
686 681 * @param int $sheet Optional. [description]
687 - * @return [type] [description]
682 + * @return bool [description]
688 683 */
689 - public function colhidden( $col, $sheet = 0 ) {
684 + public function colhidden( $col, $sheet = 0 ): bool {
690 685 return (bool) $this->colInfo[ $sheet ][ $col ]['hidden'];
691 686 }
692 687
693 688 /**
@@ -709,11 +704,11 @@
709 704 * @since 1.0.0
710 705 *
711 706 * @param [type] $row [description]
712 707 * @param int $sheet Optional. [description]
713 - * @return [type] [description]
708 + * @return bool [description]
714 709 */
715 - public function rowhidden( $row, $sheet = 0 ) {
710 + public function rowhidden( $row, $sheet = 0 ): bool {
716 711 return (bool) $this->rowInfo[ $sheet ][ $row ]['hidden'];
717 712 }
718 713
719 714 // GET THE CSS FOR FORMATTING
@@ -726,11 +721,11 @@
726 721 *
727 722 * @param [type] $row [description]
728 723 * @param [type] $col [description]
729 724 * @param int $sheet Optional. [description]
730 - * @return [type] [description]
725 + * @return string [description]
731 726 */
732 - public function style( $row, $col, $sheet = 0 ) {
727 + public function style( $row, $col, $sheet = 0 ): string {
733 728 $css = '';
734 729 $font = $this->font( $row, $col, $sheet );
735 730 if ( '' !== $font ) {
736 731 $css .= "font-family:{$font};";
@@ -1062,13 +1057,13 @@
1062 1057 * @since 1.0.0
1063 1058 *
1064 1059 * @param [type] $row [description]
1065 1060 * @param [type] $col [description]
1066 - * @param int $sheet Optional. [description]
1067 - * @param [type] $prop [description]
1061 + * @param int $sheet [description]
1062 + * @param string $prop [description]
1068 1063 * @return [type] [description]
1069 1064 */
1070 - public function fontProperty( $row, $col, $sheet = 0, $prop ) {
1065 + public function fontProperty( $row, $col, $sheet, $prop ) {
1071 1066 $font = $this->fontRecord( $row, $col, $sheet );
1072 1067 if ( null !== $font ) {
1073 1068 return $font[ $prop ];
1074 1069 }
@@ -1204,11 +1199,11 @@
1204 1199 * @param bool $row_numbers Optional. [description]
1205 1200 * @param bool $col_letters Optional. [description]
1206 1201 * @param int $sheet Optional. [description]
1207 1202 * @param string $table_class Optional. [description]
1208 - * @return [type] [description]
1203 + * @return string [description]
1209 1204 */
1210 - public function dump( $row_numbers = false, $col_letters = false, $sheet = 0, $table_class = 'excel' ) {
1205 + public function dump( $row_numbers = false, $col_letters = false, $sheet = 0, $table_class = 'excel' ): string {
1211 1206 $out = "<table class=\"$table_class\" cellspacing=0>";
1212 1207 if ( $col_letters ) {
1213 1208 $out .= "<thead>\n\t<tr>";
1214 1209 if ( $row_numbers ) {
@@ -1274,33 +1269,32 @@
1274 1269
1275 1270 // --------------
1276 1271 // END PUBLIC API
1277 1272
1278 - protected $boundsheets = array();
1279 - protected $formatRecords = array();
1280 - protected $fontRecords = array();
1281 - protected $xfRecords = array();
1282 - protected $colInfo = array();
1283 - protected $rowInfo = array();
1273 + protected array $boundsheets = array();
1274 + protected array $formatRecords = array();
1275 + protected array $fontRecords = array();
1276 + protected array $xfRecords = array();
1277 + protected array $colInfo = array();
1278 + protected array $rowInfo = array();
1284 1279
1285 - protected $sst = array();
1286 - protected $sheets = array();
1280 + protected array $sst = array();
1281 + protected array $sheets = array();
1287 1282
1288 1283 protected $data;
1289 1284 protected $_ole;
1290 - protected $_defaultEncoding = 'UTF-8';
1291 - protected $_defaultFormat = SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT;
1292 - protected $_columnsFormat = array();
1293 - protected $_rowoffset = 1;
1294 - protected $_coloffset = 1;
1285 + protected string $_defaultEncoding = 'UTF-8';
1286 + protected string $_defaultFormat = SPREADSHEET_EXCEL_READER_DEF_NUM_FORMAT;
1287 + protected array $_columnsFormat = array();
1288 + protected int $_rowoffset = 1;
1289 + protected int $_coloffset = 1;
1295 1290
1296 1291 /**
1297 1292 * List of default date formats used by Excel
1298 1293 *
1299 1294 * @since 1.0.0
1300 - * @var array
1301 1295 */
1302 - protected $dateFormats = array(
1296 + protected array $dateFormats = array(
1303 1297 0xe => 'm/d/Y',
1304 1298 0xf => 'M-d-Y',
1305 1299 0x10 => 'd-M',
1306 1300 0x11 => 'M-Y',
@@ -1317,11 +1311,10 @@
1317 1311 /**
1318 1312 * Default number formats used by Excel
1319 1313 *
1320 1314 * @since 1.0.0
1321 - * @var array
1322 1315 */
1323 - protected $numberFormats = array(
1316 + protected array $numberFormats = array(
1324 1317 0x1 => '0',
1325 1318 0x2 => '0.00',
1326 1319 0x3 => '#,##0',
1327 1320 0x4 => '#,##0.00',
@@ -1346,11 +1339,10 @@
1346 1339 /**
1347 1340 * [$colors description]
1348 1341 *
1349 1342 * @since 1.0.0
1350 - * @var array
1351 1343 */
1352 - protected $colors = array(
1344 + protected array $colors = array(
1353 1345 0x00 => '#000000',
1354 1346 0x01 => '#FFFFFF',
1355 1347 0x02 => '#FF0000',
1356 1348 0x03 => '#00FF00',
@@ -1428,11 +1420,10 @@
1428 1420 /**
1429 1421 * [$lineStyles description]
1430 1422 *
1431 1423 * @since 1.0.0
1432 - * @var array
1433 1424 */
1434 - protected $lineStyles = array(
1425 + protected array $lineStyles = array(
1435 1426 0x00 => '',
1436 1427 0x01 => 'Thin',
1437 1428 0x02 => 'Medium',
1438 1429 0x03 => 'Dashed',
@@ -1451,11 +1442,10 @@
1451 1442 /**
1452 1443 * [$lineStylesCss description]
1453 1444 *
1454 1445 * @since 1.0.0
1455 - * @var array
1456 1446 */
1457 - protected $lineStylesCss = array(
1447 + protected array $lineStylesCss = array(
1458 1448 'Thin' => '1px solid',
1459 1449 'Medium' => '2px solid',
1460 1450 'Dashed' => '1px dashed',
1461 1451 'Dotted' => '1px dotted',
@@ -1476,14 +1466,14 @@
1476 1466 * @since 1.0.0
1477 1467 *
1478 1468 * @param [type] $data [description]
1479 1469 * @param [type] $start [description]
1480 - * @return [type] [description]
1470 + * @return string [description]
1481 1471 */
1482 - protected function read16bitstring( $data, $start ) {
1472 + protected function read16bitstring( $data, $start ): string {
1483 1473 $len = 0;
1484 1474 while ( ord( $data[ $start + $len ] ) + ord( $data[ $start + $len + 1 ] ) > 0 ) {
1485 - $len++;
1475 + ++$len;
1486 1476 }
1487 1477 return substr( $data, $start, $len );
1488 1478 }
1489 1479
@@ -1495,11 +1485,11 @@
1495 1485 *
1496 1486 * @param [type] $format [description]
1497 1487 * @param [type] $num [description]
1498 1488 * @param [type] $f [description]
1499 - * @return [type] [description]
1489 + * @return array<string, mixed> [description]
1500 1490 */
1501 - protected function _format_value( $format, $num, $f ) {
1491 + protected function _format_value( $format, $num, $f ): array {
1502 1492 // 49 = TEXT format
1503 1493 // https://code.google.com/archive/p/php-excel-reader/issues/7
1504 1494 if ( ( ! $f && '%s' === $format ) || ( 49 === (int) $f ) || ( 'GENERAL' === $format ) ) {
1505 1495 return array(
@@ -1556,10 +1546,10 @@
1556 1546
1557 1547 // Handle the number itself.
1558 1548 $number_regex = '/(\d+)(\.?)(\d*)/';
1559 1549 if ( preg_match( $number_regex, $pattern, $matches ) ) {
1560 - //$left = $matches[1];
1561 - //$dec = $matches[2];
1550 + // $left = $matches[1];
1551 + // $dec = $matches[2];
1562 1552 $right = $matches[3];
1563 1553 if ( $has_commas ) {
1564 1554 $formatted = number_format( $num, strlen( $right ) );
1565 1555 } else {
@@ -1607,9 +1597,9 @@
1607 1597 * @since 1.0.0
1608 1598 *
1609 1599 * @param [type] $encoding [description]
1610 1600 */
1611 - public function setOutputEncoding( $encoding ) {
1601 + public function setOutputEncoding( $encoding ): void {
1612 1602 $this->_defaultEncoding = $encoding;
1613 1603 }
1614 1604
1615 1605 /**
@@ -1621,9 +1611,9 @@
1621 1611 * @since 1.0.0
1622 1612 *
1623 1613 * @param string $encoder Optional. [description]
1624 1614 */
1625 - public function setUTFEncoder( $encoder = 'iconv' ) {
1615 + public function setUTFEncoder( $encoder = 'iconv' ): void {
1626 1616 $this->_encoderFunction = '';
1627 1617 if ( 'iconv' === $encoder ) {
1628 1618 $this->_encoderFunction = function_exists( 'iconv' ) ? 'iconv' : '';
1629 1619 } elseif ( 'mb' === $encoder ) {
@@ -1637,9 +1627,9 @@
1637 1627 * @since 1.0.0
1638 1628 *
1639 1629 * @param [type] $iOffset [description]
1640 1630 */
1641 - public function setRowColOffset( $iOffset ) {
1631 + public function setRowColOffset( $iOffset ): void {
1642 1632 $this->_rowoffset = $iOffset;
1643 1633 $this->_coloffset = $iOffset;
1644 1634 }
1645 1635
@@ -1649,9 +1639,9 @@
1649 1639 * @since 1.0.0
1650 1640 *
1651 1641 * @param [type] $sFormat [description]
1652 1642 */
1653 - public function setDefaultFormat( $sFormat ) {
1643 + public function setDefaultFormat( $sFormat ): void {
1654 1644 $this->_defaultFormat = $sFormat;
1655 1645 }
1656 1646
1657 1647 /**
@@ -1661,9 +1651,9 @@
1661 1651 *
1662 1652 * @param [type] $column [description]
1663 1653 * @param [type] $sFormat [description]
1664 1654 */
1665 - public function setColumnFormat( $column, $sFormat ) {
1655 + public function setColumnFormat( $column, $sFormat ): void {
1666 1656 $this->_columnsFormat[ $column ] = $sFormat;
1667 1657 }
1668 1658
1669 1659 /**
@@ -1670,12 +1660,11 @@
1670 1660 * Read the spreadsheet file using OLE, then parse.
1671 1661 *
1672 1662 * @since 1.0.0
1673 1663 *
1674 - * @param [type] $data [description]
1675 - * @return [type] [description]
1664 + * @param string $data [description]
1676 1665 */
1677 - public function read( $data ) {
1666 + public function read( $data ): void {
1678 1667 $res = $this->_ole->read( $data );
1679 1668
1680 1669 // oops, something goes wrong (Darko Miljanovic)
1681 1670 if ( false === $res ) {
@@ -1701,9 +1690,9 @@
1701 1690 protected function _parse() {
1702 1691 $pos = 0;
1703 1692 $data = $this->data;
1704 1693
1705 - //$code = $this->v( $data, $pos );
1694 + // $code = $this->v( $data, $pos );
1706 1695 $length = $this->v( $data, $pos + 2 );
1707 1696 $version = $this->v( $data, $pos + 4 );
1708 1697 $substreamType = $this->v( $data, $pos + 6 );
1709 1698 if ( SPREADSHEET_EXCEL_READER_BIFF8 !== $version && SPREADSHEET_EXCEL_READER_BIFF7 !== $version ) {
@@ -1739,9 +1728,9 @@
1739 1728 }
1740 1729 $numChars = ord( $data[ $spos ] ) | ( ord( $data[ $spos + 1 ] ) << 8 );
1741 1730 $spos += 2;
1742 1731 $optionFlags = ord( $data[ $spos ] );
1743 - $spos++;
1732 + ++$spos;
1744 1733 $asciiEncoding = ( 0 === ( $optionFlags & 0x01 ) );
1745 1734 $extendedString = ( 0 !== ( $optionFlags & 0x04 ) );
1746 1735
1747 1736 // See if string contains formatting information.
@@ -1986,10 +1975,10 @@
1986 1975 $this->nineteenFour = ( 1 === ord( $data[ $pos + 4 ] ) );
1987 1976 break;
1988 1977 case SPREADSHEET_EXCEL_READER_TYPE_BOUNDSHEET:
1989 1978 $rec_offset = $this->_GetInt4d( $data, $pos + 4 );
1990 - //$rec_typeFlag = ord( $data[ $pos + 8 ] );
1991 - //$rec_visibilityFlag = ord( $data[ $pos + 9 ] );
1979 + // $rec_typeFlag = ord( $data[ $pos + 8 ] );
1980 + // $rec_visibilityFlag = ord( $data[ $pos + 9 ] );
1992 1981 $rec_length = ord( $data[ $pos + 10 ] );
1993 1982
1994 1983 if ( SPREADSHEET_EXCEL_READER_BIFF8 === $version ) {
1995 1984 $chartype = ord( $data[ $pos + 11 ] );
@@ -2164,10 +2153,10 @@
2164 2153 break;
2165 2154 case SPREADSHEET_EXCEL_READER_TYPE_BOOLERR:
2166 2155 $row = ord( $data[ $spos ] ) | ord( $data[ $spos + 1 ] ) << 8;
2167 2156 $column = ord( $data[ $spos + 2 ] ) | ord( $data[ $spos + 3 ] ) << 8;
2168 - $string = ord( $data[ $spos + 6 ] );
2169 - $this->addcell( $row, $column, $string );
2157 + $a_string = ord( $data[ $spos + 6 ] );
2158 + $this->addcell( $row, $column, $a_string );
2170 2159 break;
2171 2160 case SPREADSHEET_EXCEL_READER_TYPE_STRING:
2172 2161 // https://code.google.com/archive/p/php-excel-reader/issues/4
2173 2162 if ( SPREADSHEET_EXCEL_READER_BIFF8 === $version ) {
@@ -2175,9 +2164,9 @@
2175 2164 $xpos = $spos;
2176 2165 $numChars = ord( $data[ $xpos ] ) | ( ord( $data[ $xpos + 1 ] ) << 8 );
2177 2166 $xpos += 2;
2178 2167 $optionFlags = ord( $data[ $xpos ] );
2179 - $xpos++;
2168 + ++$xpos;
2180 2169 $asciiEncoding = ( 0 === ( $optionFlags & 0x01 ) );
2181 2170 $extendedString = ( 0 !== ( $optionFlags & 0x04 ) );
2182 2171 // See if string contains formatting information
2183 2172 $richString = ( 0 !== ( $optionFlags & 0x08 ) );
@@ -2312,9 +2301,9 @@
2312 2301 *
2313 2302 * @param [type] $spos [description]
2314 2303 * @return bool [description]
2315 2304 */
2316 - protected function isDate( $spos ) {
2305 + protected function isDate( $spos ): bool {
2317 2306 $xfindex = ord( $this->data[ $spos + 4 ] ) | ord( $this->data[ $spos + 5 ] ) << 8;
2318 2307 return ( 'date' === $this->xfRecords[ $xfindex ]['type'] );
2319 2308 }
2320 2309 /**
@@ -2321,18 +2310,18 @@
2321 2310 * [gmgetdate description]
2322 2311 *
2323 2312 * @since 1.0.0
2324 2313 *
2325 - * @param [type] $ts Optional. [description]
2326 - * @return [type] [description]
2314 + * @param int $ts Optional. Timestamp. Defaults to current Unix timestamp.
2315 + * @return array<string, string> [description]
2327 2316 */
2328 - protected function gmgetdate( $ts = null ) {
2317 + protected function gmgetdate( $ts = null ): array {
2329 2318 $k = array( 'seconds', 'minutes', 'hours', 'mday', 'wday', 'mon', 'year', 'yday', 'weekday', 'month', 0 );
2330 2319 return array_combine( $k, explode( ':', gmdate( 's:i:G:j:w:n:Y:z:l:F:U', is_null( $ts ) ? time() : $ts ) ) );
2331 2320 }
2332 2321
2333 2322 /**
2334 - * Get the details for a particular cell
2323 + * Gets the details for a particular cell.
2335 2324 *
2336 2325 * @since 1.0.0
2337 2326 *
2338 2327 * @param [type] $spos [description]
@@ -2337,11 +2326,11 @@
2337 2326 *
2338 2327 * @param [type] $spos [description]
2339 2328 * @param [type] $numValue [description]
2340 2329 * @param [type] $column [description]
2341 - * @return [type] [description]
2330 + * @return array<string, mixed> [description]
2342 2331 */
2343 - protected function _getCellDetails( $spos, $numValue, $column ) {
2332 + protected function _getCellDetails( $spos, $numValue, $column ): array {
2344 2333 $xfindex = ord( $this->data[ $spos + 4 ] ) | ord( $this->data[ $spos + 5 ] ) << 8;
2345 2334 $xfrecord = $this->xfRecords[ $xfindex ];
2346 2335 $type = $xfrecord['type'];
2347 2336
@@ -2367,15 +2356,15 @@
2367 2356
2368 2357 $totalseconds = floor( SPREADSHEET_EXCEL_READER_MSINADAY * $fractionalDay );
2369 2358 $secs = $totalseconds % 60;
2370 2359 $totalseconds -= $secs;
2371 - $hours = floor( $totalseconds / ( 60 * 60 ) );
2372 - $mins = floor( $totalseconds / 60 ) % 60;
2373 - $string = date( $format, mktime( $hours, $mins, $secs, $dateinfo['mon'], $dateinfo['mday'], $dateinfo['year'] ) );
2360 + $hours = intdiv( $totalseconds, 60 * 60 );
2361 + $mins = intdiv( $totalseconds, 60 ) % 60;
2362 + $a_string = date( $format, mktime( $hours, $mins, $secs, $dateinfo['mon'], $dateinfo['mday'], $dateinfo['year'] ) );
2374 2363 } elseif ( 'number' === $type ) {
2375 2364 $rectype = 'number';
2376 2365 $formatted = $this->_format_value( $format, $numValue, $formatIndex );
2377 - $string = $formatted['string'];
2366 + $a_string = $formatted['string'];
2378 2367 $formatColor = $formatted['formatColor'];
2379 2368 $raw = $numValue;
2380 2369 } else {
2381 2370 if ( '' === $format ) {
@@ -2382,9 +2371,9 @@
2382 2371 $format = $this->_defaultFormat;
2383 2372 }
2384 2373 $rectype = 'unknown';
2385 2374 $formatted = $this->_format_value( $format, $numValue, $formatIndex );
2386 - $string = $formatted['string'];
2375 + $a_string = $formatted['string'];
2387 2376 $formatColor = $formatted['formatColor'];
2388 2377 $raw = $numValue;
2389 2378 }
2390 2379
@@ -2431,12 +2420,12 @@
2431 2420 * [addcell description]
2432 2421 *
2433 2422 * @since 1.0.0
2434 2423 *
2435 - * @param [type] $row [description]
2436 - * @param [type] $col [description]
2437 - * @param [type] $string [description]
2438 - * @param [type] $info Optional. [description]
2424 + * @param [type] $row [description]
2425 + * @param [type] $col [description]
2426 + * @param [type] $a_string [description]
2427 + * @param array<string, mixed> $info Optional. [description]
2439 2428 * @return [type] [description]
2440 2429 */
2441 2430 protected function addcell( $row, $col, $string, $info = null ) {
2442 2431 $this->sheets[ $this->sn ]['maxrow'] = max( $this->sheets[ $this->sn ]['maxrow'], $row + $this->_rowoffset );
@@ -2484,19 +2473,19 @@
2484 2473 * [_encodeUTF16 description]
2485 2474 *
2486 2475 * @since 1.0.0
2487 2476 *
2488 - * @param [type] $string [description]
2477 + * @param [type] $a_string [description]
2489 2478 * @return [type] [description]
2490 2479 */
2491 - protected function _encodeUTF16( $string ) {
2480 + protected function _encodeUTF16( $a_string ) {
2492 2481 if ( $this->_defaultEncoding ) {
2493 2482 switch ( $this->_encoderFunction ) {
2494 2483 case 'iconv':
2495 - $string = iconv( 'UTF-16LE', $this->_defaultEncoding, $string );
2484 + $a_string = iconv( 'UTF-16LE', $this->_defaultEncoding, $a_string );
2496 2485 break;
2497 2486 case 'mb_convert_encoding':
2498 - $string = mb_convert_encoding( $string, $this->_defaultEncoding, 'UTF-16LE' );
2487 + $a_string = mb_convert_encoding( $string, $this->_defaultEncoding, 'UTF-16LE' );
2499 2488 break;
2500 2489 }
2501 2490 }
2502 2491 return $string;
@@ -2508,11 +2497,11 @@
2508 2497 * @since 1.0.0
2509 2498 *
2510 2499 * @param [type] $data [description]
2511 2500 * @param [type] $pos [description]
2512 - * @return [type] [description]
2501 + * @return int [description]
2513 2502 */
2514 - protected function _GetInt4d( $data, $pos ) {
2503 + protected function _GetInt4d( $data, $pos ): int {
2515 2504 $value = ord( $data[ $pos ] ) | ( ord( $data[ $pos + 1 ] ) << 8 ) | ( ord( $data[ $pos + 2 ] ) << 16 ) | ( ord( $data[ $pos + 3 ] ) << 24 );
2516 2505 if ( $value >= 4294967294 ) {
2517 2506 $value = -2;
2518 2507 }
@@ -2525,11 +2514,11 @@
2525 2514 * @since 1.0.0
2526 2515 *
2527 2516 * @param [type] $data [description]
2528 2517 * @param [type] $pos [description]
2529 - * @return [type] [description]
2518 + * @return int [description]
2530 2519 */
2531 - protected function v( $data, $pos ) {
2520 + protected function v( $data, $pos ): int {
2532 2521 return ord( $data[ $pos ] ) | ord( $data[ $pos + 1 ] ) << 8;
2533 2522 }
2534 2523
2535 2524 } // class Spreadsheet_Excel_Reader