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/vendor/PhpSpreadsheet/Reader/Html.php +28 -15 3.3.1 → 3.4 View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 2
3 3 namespace TablePress\PhpOffice\PhpSpreadsheet\Reader;
4 4
5 +use TablePress\Composer\Pcre\Preg;
5 6 use DOMAttr;
6 7 use DOMDocument;
7 8 use DOMElement;
8 9 use DOMNode;
@@ -179,9 +180,9 @@
179 180 } catch (Exception $exception) {
180 181 return false;
181 182 }
182 183
183 - $beginning = preg_replace(self::STARTS_WITH_BOM, '', $this->readBeginning()) ?? '';
184 + $beginning = Preg::replace(self::STARTS_WITH_BOM, '', $this->readBeginning());
184 185
185 186 $startWithTag = self::startsWithTag($beginning);
186 187 $containsTags = self::containsTags($beginning);
187 188 $endsWithTag = self::endsWithTag($this->readEnding());
@@ -201,9 +202,9 @@
201 202 private function readEnding(): string
202 203 {
203 204 $meta = stream_get_meta_data($this->fileHandle);
204 205 // Phpstan incorrectly flags following line for Php8.2-, corrected in 8.3
205 - $filename = $meta['uri']; //@phpstan-ignore-line
206 + $filename = $meta['uri']; //@phpstan-ignore offsetAccess.notFound (fixable when Php < 8.3 is no longer possible)
206 207
207 208 clearstatcache(true, $filename);
208 209 $size = (int) filesize($filename);
209 210 if ($size === 0) {
@@ -341,15 +342,23 @@
341 342 $hyperlink = $sheet->hyperlinkExists($column . $row) ? $sheet->getHyperlink($column . $row) : null;
342 343
343 344 try {
344 345 if (isset($attributeArray['data-formula'])) {
345 - $sheet->setCellValueExplicit($column . $row, $attributeArray['data-formula'], DataType::TYPE_FORMULA);
346 + $sheet->setCellValueExplicit(
347 + $column . $row,
348 + $attributeArray['data-formula'],
349 + DataType::TYPE_FORMULA
350 + );
346 351 $sheet->getCell($column . $row)
347 352 ->setCalculatedValue(
348 353 $cellContent
349 354 );
350 355 } else {
351 - $sheet->setCellValueExplicit($column . $row, $cellContent, $attributeArray['data-type']);
356 + $sheet->setCellValueExplicit(
357 + $column . $row,
358 + $attributeArray['data-value'] ?? $cellContent,
359 + $attributeArray['data-type']
360 + );
352 361 }
353 362 } catch (SpreadsheetException $exception) {
354 363 $sheet->setCellValue($column . $row, $cellContent);
355 364 }
@@ -358,18 +367,18 @@
358 367 $hyperlink = null;
359 368 if ($sheet->hyperlinkExists($column . $row)) {
360 369 $hyperlink = $sheet->getHyperlink($column . $row);
361 370 }
362 - $sheet->setCellValue($column . $row, $cellContent);
371 + $sheet->setCellValue($column . $row, $attributeArray['data-value'] ?? $cellContent);
363 372 $sheet->setHyperlink($column . $row, $hyperlink);
364 373 }
365 - $this->dataArray[$row][$column] = $cellContent; // @phpstan-ignore-line
374 + $this->dataArray[$row][$column] = $cellContent; // @phpstan-ignore property.deprecated (fixable when $this.data is removed)
366 375 }
367 376 } else {
368 377 // We have a Rich Text run.
369 378 // I don't actually see any way to reach this line.
370 379 // TODO
371 - // @phpstan-ignore-next-line
380 + // @phpstan-ignore property.deprecated (fixable when $this->data is removed)
372 381 $this->dataArray[$row][$column] = 'RICH TEXT: ' . StringHelper::convertToString($cellContent); // @codeCoverageIgnore
373 382 }
374 383 $cellContentx = '';
375 384 }
@@ -453,9 +462,9 @@
453 462 $sheet->getComment($column . $row)->setTextboxDirection(Comment::TEXTBOX_DIRECTION_RTL);
454 463 }
455 464 if (isset($attributeArray['style'])) {
456 465 $alignStyle = $attributeArray['style'];
457 - if (preg_match('/\btext-align:\s*(left|right|center|justify)\b/', (string) $alignStyle, $matches) === 1) {
466 + if (Preg::isMatch('/\btext-align:\s*(left|right|center|justify)\b/', (string) $alignStyle, $matches)) {
458 467 $sheet->getComment($column . $row)->setAlignment($matches[1]);
459 468 }
460 469 }
461 470 } else {
@@ -766,11 +775,11 @@
766 775 }
767 776
768 777 protected function processDomElement(DOMNode $element, Worksheet $sheet, int &$row, string &$column, string &$cellContent): void
769 778 {
770 - foreach ($element->childNodes as $child) {
779 + foreach ($element->childNodes ?? [] as $child) {
771 780 if ($child instanceof DOMText) {
772 - $domText = (string) preg_replace('/\s+/', ' ', trim($child->nodeValue ?? ''));
781 + $domText = Preg::replace('/\s+/', ' ', trim($child->nodeValue ?? ''));
773 782 if ($domText === "\u{a0}") {
774 783 $domText = '';
775 784 }
776 785 // simply append the text if the cell content is a plain text string
@@ -879,9 +888,9 @@
879 888 $properties->setViewport($metaContent);
880 889
881 890 break;
882 891 default:
883 - if (preg_match('/^custom[.](bool|date|float|int|string)[.](.+)$/', $metaName, $matches) === 1) {
892 + if (Preg::isMatch('/^custom[.](bool|date|float|int|string)[.](.+)$/', $metaName, $matches)) {
884 893 switch ($matches[1]) {
885 894 case 'bool':
886 895 $properties->setCustomProperty($matches[2], (bool) $metaContent, Properties::PROPERTY_TYPE_BOOLEAN);
887 896 break;
@@ -915,15 +924,14 @@
915 924
916 925 /** @internal */
917 926 protected static function replaceNonAsciiIfNeeded(string $convert): ?string
918 927 {
919 - if (preg_match(self::STARTS_WITH_BOM, $convert) !== 1 && preg_match(self::DECLARES_CHARSET, $convert) !== 1) {
928 + if (!Preg::isMatch(self::STARTS_WITH_BOM, $convert) && !Preg::isMatch(self::DECLARES_CHARSET, $convert)) {
920 929 $lowend = "\u{80}";
921 930 $highend = "\u{10ffff}";
922 931 $regexp = "/[$lowend-$highend]/u";
923 - /** @var callable $callback */
924 - $callback = [self::class, 'replaceNonAscii'];
925 - $convert = preg_replace_callback($regexp, $callback, $convert);
932 + // use native preg because of "u" modifier
933 + $convert = preg_replace_callback($regexp, \Closure::fromCallable([self::class, 'replaceNonAscii']), $convert);
926 934 }
927 935
928 936 return $convert;
929 937 }
@@ -1278,8 +1286,13 @@
1278 1286 $opacity = $styleArray['opacity'];
1279 1287 if (is_numeric($opacity)) {
1280 1288 $drawing->setOpacity((int) ($opacity * 100000));
1281 1289 }
1290 + }
1291 + /** @var string */
1292 + $transform = $styleArray['transform'] ?? '';
1293 + if (Preg::isMatch('/rotate[(](-?\d{1,3})deg[)]$/', $transform, $matches)) {
1294 + $drawing->setRotation((int) $matches[1]);
1282 1295 }
1283 1296 }
1284 1297
1285 1298 /**