Php8.2 Deprecation in Reader/Xlsx (#2894)
* Php8.2 Deprecation in Reader/Xlsx
Using `${var}` will be deprecated, with the suggested resolution being to use `{$var}`. This appears to be the only place in PhpSpreadsheet which does this. Some vendor packages will need to change for 8.2 for this and other reasons.
* mb_convert_encoding and HTML_ENTITIES
Also scheduled to be deprecated with 8.2. It appears to have not been needed in PhpSpreadsheet in the first place.
This commit is contained in:
parent
1829dea91e
commit
481cef2def
|
|
@ -632,16 +632,6 @@ class Html extends BaseReader
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure mb_convert_encoding returns string.
|
||||
*
|
||||
* @param mixed $result
|
||||
*/
|
||||
private static function ensureString($result): string
|
||||
{
|
||||
return is_string($result) ? $result : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads PhpSpreadsheet from file into PhpSpreadsheet instance.
|
||||
*
|
||||
|
|
@ -660,8 +650,8 @@ class Html extends BaseReader
|
|||
$dom = new DOMDocument();
|
||||
// Reload the HTML file into the DOM object
|
||||
try {
|
||||
$convert = mb_convert_encoding($this->securityScanner->scanFile($filename), 'HTML-ENTITIES', 'UTF-8');
|
||||
$loaded = $dom->loadHTML(self::ensureString($convert));
|
||||
$convert = $this->securityScanner->scanFile($filename);
|
||||
$loaded = $dom->loadHTML($convert);
|
||||
} catch (Throwable $e) {
|
||||
$loaded = false;
|
||||
}
|
||||
|
|
@ -683,8 +673,8 @@ class Html extends BaseReader
|
|||
$dom = new DOMDocument();
|
||||
// Reload the HTML file into the DOM object
|
||||
try {
|
||||
$convert = mb_convert_encoding($this->securityScanner->scan($content), 'HTML-ENTITIES', 'UTF-8');
|
||||
$loaded = $dom->loadHTML(self::ensureString($convert));
|
||||
$convert = $this->securityScanner->scan($content);
|
||||
$loaded = $dom->loadHTML($convert);
|
||||
} catch (Throwable $e) {
|
||||
$loaded = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ class Xlsx extends BaseReader
|
|||
[$workbookBasename, $xmlNamespaceBase] = $this->getWorkbookBaseName();
|
||||
$drawingNS = self::REL_TO_DRAWING[$xmlNamespaceBase] ?? Namespaces::DRAWINGML;
|
||||
$chartNS = self::REL_TO_CHART[$xmlNamespaceBase] ?? Namespaces::CHART;
|
||||
$wbRels = $this->loadZip("xl/_rels/${workbookBasename}.rels", Namespaces::RELATIONSHIPS);
|
||||
$wbRels = $this->loadZip("xl/_rels/{$workbookBasename}.rels", Namespaces::RELATIONSHIPS);
|
||||
$theme = null;
|
||||
$this->styleReader = new Styles();
|
||||
foreach ($wbRels->Relationship as $relx) {
|
||||
|
|
@ -1849,11 +1849,6 @@ class Xlsx extends BaseReader
|
|||
|
||||
private static function dirAdd($base, $add): string
|
||||
{
|
||||
$add = "$add";
|
||||
if (substr($add, 0, 4) === '/xl/') {
|
||||
$add = substr($add, 4);
|
||||
}
|
||||
|
||||
return (string) preg_replace('~[^/]+/\.\./~', '', dirname($base) . "/$add");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue