code style fixes + const check fix

This commit is contained in:
Dennis Eichhorn 2023-12-29 15:38:29 +00:00
parent cfc0d32a10
commit 3011a504cd
636 changed files with 7615 additions and 7608 deletions

View File

@ -76,7 +76,7 @@ class ConfigVariables
// Uses Adobe CJK fonts for CJK languages // Uses Adobe CJK fonts for CJK languages
// default TRUE, only set false if you have defined some available fonts that support CJK // default TRUE, only set false if you have defined some available fonts that support CJK
// If true this will not stop use of other CJK fonts if specified by font-family: // If true this will not stop use of other CJK fonts if specified by font-family:
// and vice versa i.e. only dictates behaviour when specified by lang="" incl. AutoFont() // and vice versa i.e. only dictates behavior when specified by lang="" incl. AutoFont()
'useAdobeCJK' => false, 'useAdobeCJK' => false,
// When embedding full TTF font files, remakes the font file using only core tables // When embedding full TTF font files, remakes the font file using only core tables

File diff suppressed because one or more lines are too long

View File

@ -7,7 +7,7 @@ use PclZip;
class PclZipAdapter implements ZipInterface class PclZipAdapter implements ZipInterface
{ {
/** /**
* @var PclZip * @var \PclZip
*/ */
protected $oPclZip; protected $oPclZip;
@ -18,8 +18,8 @@ class PclZipAdapter implements ZipInterface
public function open($filename) public function open($filename)
{ {
$this->oPclZip = new PclZip($filename); $this->oPclZip = new \PclZip($filename);
$this->tmpDir = sys_get_temp_dir(); $this->tmpDir = \sys_get_temp_dir();
return $this; return $this;
} }
@ -31,17 +31,17 @@ class PclZipAdapter implements ZipInterface
public function addFromString($localname, $contents) public function addFromString($localname, $contents)
{ {
$pathData = pathinfo($localname); $pathData = \pathinfo($localname);
$hFile = fopen($this->tmpDir . '/' . $pathData['basename'], 'wb'); $hFile = \fopen($this->tmpDir . '/' . $pathData['basename'], 'wb');
fwrite($hFile, $contents); \fwrite($hFile, $contents);
fclose($hFile); \fclose($hFile);
$res = $this->oPclZip->add($this->tmpDir . '/' . $pathData['basename'], PCLZIP_OPT_REMOVE_PATH, $this->tmpDir, PCLZIP_OPT_ADD_PATH, $pathData['dirname']); $res = $this->oPclZip->add($this->tmpDir . '/' . $pathData['basename'], PCLZIP_OPT_REMOVE_PATH, $this->tmpDir, PCLZIP_OPT_ADD_PATH, $pathData['dirname']);
if ($res == 0) { if ($res == 0) {
throw new \Exception('Error zipping files : ' . $this->oPclZip->errorInfo(true)); throw new \Exception('Error zipping files : ' . $this->oPclZip->errorInfo(true));
} }
unlink($this->tmpDir . '/' . $pathData['basename']); \unlink($this->tmpDir . '/' . $pathData['basename']);
return $this; return $this;
} }

View File

@ -7,7 +7,7 @@ use ZipArchive;
class ZipArchiveAdapter implements ZipInterface class ZipArchiveAdapter implements ZipInterface
{ {
/** /**
* @var ZipArchive * @var \ZipArchive
*/ */
protected $oZipArchive; protected $oZipArchive;
@ -19,12 +19,12 @@ class ZipArchiveAdapter implements ZipInterface
public function open($filename) public function open($filename)
{ {
$this->filename = $filename; $this->filename = $filename;
$this->oZipArchive = new ZipArchive(); $this->oZipArchive = new \ZipArchive();
if ($this->oZipArchive->open($this->filename, ZipArchive::OVERWRITE) === true) { if ($this->oZipArchive->open($this->filename, \ZipArchive::OVERWRITE) === true) {
return $this; return $this;
} }
if ($this->oZipArchive->open($this->filename, ZipArchive::CREATE) === true) { if ($this->oZipArchive->open($this->filename, \ZipArchive::CREATE) === true) {
return $this; return $this;
} }
throw new \Exception("Could not open $this->filename for writing."); throw new \Exception("Could not open $this->filename for writing.");

View File

@ -32,7 +32,7 @@ class Autoloader
*/ */
public static function register(): void public static function register(): void
{ {
spl_autoload_register([new self(), 'autoload']); \spl_autoload_register([new self(), 'autoload']);
} }
/** /**
@ -42,11 +42,11 @@ class Autoloader
*/ */
public static function autoload(string $class): void public static function autoload(string $class): void
{ {
$prefixLength = strlen(self::NAMESPACE_PREFIX); $prefixLength = \strlen(self::NAMESPACE_PREFIX);
if (0 === strncmp(self::NAMESPACE_PREFIX, $class, $prefixLength)) { if (0 === \strncmp(self::NAMESPACE_PREFIX, $class, $prefixLength)) {
$file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength)); $file = \str_replace('\\', DIRECTORY_SEPARATOR, \substr($class, $prefixLength));
$file = realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php'); $file = \realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php');
if (file_exists($file)) { if (\file_exists($file)) {
/** @noinspection PhpIncludeInspection Dynamic includes */ /** @noinspection PhpIncludeInspection Dynamic includes */
require_once $file; require_once $file;
} }

View File

@ -30,7 +30,7 @@ class Drawing
*/ */
public static function pixelsToEmu(float $pValue = 0): float public static function pixelsToEmu(float $pValue = 0): float
{ {
return round($pValue * 9525); return \round($pValue * 9525);
} }
/** /**
@ -46,7 +46,7 @@ class Drawing
return 0; return 0;
} }
return (int) round($pValue / 9525); return (int) \round($pValue / 9525);
} }
/** /**
@ -135,7 +135,7 @@ class Drawing
return 0; return 0;
} }
return (int) round((($pValue / 2.54) * self::DPI_96)); return (int) \round((($pValue / 2.54) * self::DPI_96));
} }
/** /**
@ -147,7 +147,7 @@ class Drawing
*/ */
public static function degreesToAngle(int $pValue = 0): int public static function degreesToAngle(int $pValue = 0): int
{ {
return (int) round($pValue * 60000); return (int) \round($pValue * 60000);
} }
/** /**
@ -163,7 +163,7 @@ class Drawing
return 0; return 0;
} }
return round($pValue / 60000); return \round($pValue / 60000);
} }
/** /**
@ -243,7 +243,7 @@ class Drawing
return 0; return 0;
} }
return round($pValue / 15); return \round($pValue / 15);
} }
/** /**
@ -259,7 +259,7 @@ class Drawing
return 0; return 0;
} }
return (int) round(($pValue / 0.75) / 9525); return (int) \round(($pValue / 0.75) / 9525);
} }
/** /**
@ -272,20 +272,20 @@ class Drawing
public static function htmlToRGB(string $pValue): ?array public static function htmlToRGB(string $pValue): ?array
{ {
if ($pValue[0] == '#') { if ($pValue[0] == '#') {
$pValue = substr($pValue, 1); $pValue = \substr($pValue, 1);
} }
if (strlen($pValue) == 6) { if (\strlen($pValue) == 6) {
list($colorR, $colorG, $colorB) = [$pValue[0] . $pValue[1], $pValue[2] . $pValue[3], $pValue[4] . $pValue[5]]; list($colorR, $colorG, $colorB) = [$pValue[0] . $pValue[1], $pValue[2] . $pValue[3], $pValue[4] . $pValue[5]];
} elseif (strlen($pValue) == 3) { } elseif (\strlen($pValue) == 3) {
list($colorR, $colorG, $colorB) = [$pValue[0] . $pValue[0], $pValue[1] . $pValue[1], $pValue[2] . $pValue[2]]; list($colorR, $colorG, $colorB) = [$pValue[0] . $pValue[0], $pValue[1] . $pValue[1], $pValue[2] . $pValue[2]];
} else { } else {
return null; return null;
} }
$colorR = hexdec($colorR); $colorR = \hexdec($colorR);
$colorG = hexdec($colorG); $colorG = \hexdec($colorG);
$colorB = hexdec($colorB); $colorB = \hexdec($colorB);
return [$colorR, $colorG, $colorB]; return [$colorR, $colorG, $colorB];
} }

View File

@ -33,12 +33,12 @@ class File
// Sick construction, but it seems that // Sick construction, but it seems that
// file_exists returns strange values when // file_exists returns strange values when
// doing the original file_exists on ZIP archives... // doing the original file_exists on ZIP archives...
if (strtolower(substr($pFilename, 0, 3)) == 'zip') { if (\strtolower(\substr($pFilename, 0, 3)) == 'zip') {
// Open ZIP file and verify if the file exists // Open ZIP file and verify if the file exists
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6); $zipFile = \substr($pFilename, 6, \strpos($pFilename, '#') - 6);
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1); $archiveFile = \substr($pFilename, \strpos($pFilename, '#') + 1);
$zip = new ZipArchive(); $zip = new \ZipArchive();
if ($zip->open($zipFile) === true) { if ($zip->open($zipFile) === true) {
$returnValue = ($zip->getFromName($archiveFile) !== false); $returnValue = ($zip->getFromName($archiveFile) !== false);
$zip->close(); $zip->close();
@ -50,7 +50,7 @@ class File
} }
// Regular file_exists // Regular file_exists
return file_exists($pFilename); return \file_exists($pFilename);
} }
/** /**
@ -65,12 +65,12 @@ class File
if (!self::fileExists($pFilename)) { if (!self::fileExists($pFilename)) {
return null; return null;
} }
if (strtolower(substr($pFilename, 0, 3)) == 'zip') { if (\strtolower(\substr($pFilename, 0, 3)) == 'zip') {
// Open ZIP file and verify if the file exists // Open ZIP file and verify if the file exists
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6); $zipFile = \substr($pFilename, 6, \strpos($pFilename, '#') - 6);
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1); $archiveFile = \substr($pFilename, \strpos($pFilename, '#') + 1);
$zip = new ZipArchive(); $zip = new \ZipArchive();
if ($zip->open($zipFile) === true) { if ($zip->open($zipFile) === true) {
$returnValue = $zip->getFromName($archiveFile); $returnValue = $zip->getFromName($archiveFile);
$zip->close(); $zip->close();
@ -81,7 +81,7 @@ class File
return null; return null;
} }
// Regular file contents // Regular file contents
return file_get_contents($pFilename); return \file_get_contents($pFilename);
} }
/** /**
@ -94,13 +94,13 @@ class File
public static function realpath(string $pFilename): string public static function realpath(string $pFilename): string
{ {
// Try using realpath() // Try using realpath()
$returnValue = realpath($pFilename); $returnValue = \realpath($pFilename);
// Found something? // Found something?
if (empty($returnValue)) { if (empty($returnValue)) {
$pathArray = explode('/', $pFilename); $pathArray = \explode('/', $pFilename);
while (in_array('..', $pathArray) && $pathArray[0] != '..') { while (\in_array('..', $pathArray) && $pathArray[0] != '..') {
$numPathArray = count($pathArray); $numPathArray = \count($pathArray);
for ($i = 0; $i < $numPathArray; ++$i) { for ($i = 0; $i < $numPathArray; ++$i) {
if ($pathArray[$i] == '..' && $i > 0) { if ($pathArray[$i] == '..' && $i > 0) {
unset($pathArray[$i]); unset($pathArray[$i]);
@ -109,7 +109,7 @@ class File
} }
} }
} }
$returnValue = implode('/', $pathArray); $returnValue = \implode('/', $pathArray);
} }
// Return // Return

View File

@ -17,9 +17,11 @@
namespace PhpOffice\Common\Microsoft; namespace PhpOffice\Common\Microsoft;
/*
if (!defined('IDENTIFIER_OLE')) { if (!defined('IDENTIFIER_OLE')) {
define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1)); define('IDENTIFIER_OLE', pack('CCCCCCCC', 0xD0, 0xCF, 0x11, 0xE0, 0xA1, 0xB1, 0x1A, 0xE1));
} }
*/
class OLERead class OLERead
{ {
@ -29,7 +31,7 @@ class OLERead
private $data = ''; private $data = '';
// OLE identifier // OLE identifier
public const IDENTIFIER_OLE = IDENTIFIER_OLE; public const IDENTIFIER_OLE = "\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1";
// Size of a sector = 512 bytes // Size of a sector = 512 bytes
public const BIG_BLOCK_SIZE = 0x200; public const BIG_BLOCK_SIZE = 0x200;
@ -105,24 +107,26 @@ class OLERead
* *
* @throws \Exception * @throws \Exception
*/ */
public function read(string $sFileName): void public function read(string $sFileName): bool
{ {
// Check if file exists and is readable // Check if file exists and is readable
if (!is_readable($sFileName)) { if (!\is_readable($sFileName)) {
throw new \Exception('Could not open ' . $sFileName . ' for reading! File does not exist, or it is not readable.'); return false;
//throw new \Exception('Could not open ' . $sFileName . ' for reading! File does not exist, or it is not readable.');
} }
// Get the file identifier // Get the file identifier
// Don't bother reading the whole file until we know it's a valid OLE file // Don't bother reading the whole file until we know it's a valid OLE file
$this->data = file_get_contents($sFileName, false, null, 0, 8); $this->data = \file_get_contents($sFileName, false, null, 0, 8);
// Check OLE identifier // Check OLE identifier
if ($this->data != self::IDENTIFIER_OLE) { if ($this->data != self::IDENTIFIER_OLE) {
throw new \Exception('The filename ' . $sFileName . ' is not recognised as an OLE file'); return false;
//throw new \Exception('The filename ' . $sFileName . ' is not recognized as an OLE file');
} }
// Get the file data // Get the file data
$this->data = file_get_contents($sFileName); $this->data = \file_get_contents($sFileName);
// Total number of sectors used for the SAT // Total number of sectors used for the SAT
$numBigBlkDepotBlks = self::getInt4d($this->data, self::NUM_BIG_BLOCK_DEPOT_BLOCKS_POS); $numBigBlkDepotBlks = self::getInt4d($this->data, self::NUM_BIG_BLOCK_DEPOT_BLOCKS_POS);
@ -155,7 +159,7 @@ class OLERead
for ($j = 0; $j < $numExtensionBlocks; ++$j) { for ($j = 0; $j < $numExtensionBlocks; ++$j) {
$pos = ($extensionBlock + 1) * self::BIG_BLOCK_SIZE; $pos = ($extensionBlock + 1) * self::BIG_BLOCK_SIZE;
$blocksToRead = min($numBigBlkDepotBlks - $bbdBlocks, self::BIG_BLOCK_SIZE / 4 - 1); $blocksToRead = \min($numBigBlkDepotBlks - $bbdBlocks, self::BIG_BLOCK_SIZE / 4 - 1);
for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; ++$i) { for ($i = $bbdBlocks; $i < $bbdBlocks + $blocksToRead; ++$i) {
$bigBlockDepotBlocks[$i] = self::getInt4d($this->data, $pos); $bigBlockDepotBlocks[$i] = self::getInt4d($this->data, $pos);
@ -173,7 +177,7 @@ class OLERead
for ($i = 0; $i < $numBigBlkDepotBlks; ++$i) { for ($i = 0; $i < $numBigBlkDepotBlks; ++$i) {
$pos = ($bigBlockDepotBlocks[$i] + 1) * self::BIG_BLOCK_SIZE; $pos = ($bigBlockDepotBlocks[$i] + 1) * self::BIG_BLOCK_SIZE;
$this->bigBlockChain .= substr($this->data, $pos, 4 * $bbs); $this->bigBlockChain .= \substr($this->data, $pos, 4 * $bbs);
$pos += 4 * $bbs; $pos += 4 * $bbs;
} }
@ -182,7 +186,7 @@ class OLERead
while ($sbdBlock != -2) { while ($sbdBlock != -2) {
$pos = ($sbdBlock + 1) * self::BIG_BLOCK_SIZE; $pos = ($sbdBlock + 1) * self::BIG_BLOCK_SIZE;
$this->smallBlockChain .= substr($this->data, $pos, 4 * $bbs); $this->smallBlockChain .= \substr($this->data, $pos, 4 * $bbs);
$pos += 4 * $bbs; $pos += 4 * $bbs;
$sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock * 4); $sbdBlock = self::getInt4d($this->bigBlockChain, $sbdBlock * 4);
@ -193,6 +197,8 @@ class OLERead
$this->entry = $this->readData($block); $this->entry = $this->readData($block);
$this->readPropertySets(); $this->readPropertySets();
return true;
} }
/** /**
@ -211,7 +217,7 @@ class OLERead
while ($block != -2) { while ($block != -2) {
$pos = $block * self::SMALL_BLOCK_SIZE; $pos = $block * self::SMALL_BLOCK_SIZE;
$streamData .= substr($rootdata, $pos, self::SMALL_BLOCK_SIZE); $streamData .= \substr($rootdata, $pos, self::SMALL_BLOCK_SIZE);
$block = self::getInt4d($this->smallBlockChain, $block * 4); $block = self::getInt4d($this->smallBlockChain, $block * 4);
} }
@ -232,7 +238,7 @@ class OLERead
while ($block != -2) { while ($block != -2) {
$pos = ($block + 1) * self::BIG_BLOCK_SIZE; $pos = ($block + 1) * self::BIG_BLOCK_SIZE;
$streamData .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); $streamData .= \substr($this->data, $pos, self::BIG_BLOCK_SIZE);
$block = self::getInt4d($this->bigBlockChain, $block * 4); $block = self::getInt4d($this->bigBlockChain, $block * 4);
} }
@ -253,7 +259,7 @@ class OLERead
while ($block != -2) { while ($block != -2) {
$pos = ($block + 1) * self::BIG_BLOCK_SIZE; $pos = ($block + 1) * self::BIG_BLOCK_SIZE;
$data .= substr($this->data, $pos, self::BIG_BLOCK_SIZE); $data .= \substr($this->data, $pos, self::BIG_BLOCK_SIZE);
$block = self::getInt4d($this->bigBlockChain, $block * 4); $block = self::getInt4d($this->bigBlockChain, $block * 4);
} }
@ -268,16 +274,16 @@ class OLERead
$offset = 0; $offset = 0;
// loop through entires, each entry is 128 bytes // loop through entires, each entry is 128 bytes
$entryLen = strlen($this->entry); $entryLen = \strlen($this->entry);
while ($offset < $entryLen) { while ($offset < $entryLen) {
// entry data (128 bytes) // entry data (128 bytes)
$data = substr($this->entry, $offset, self::PROPERTY_STORAGE_BLOCK_SIZE); $data = \substr($this->entry, $offset, self::PROPERTY_STORAGE_BLOCK_SIZE);
// size in bytes of name // size in bytes of name
$nameSize = ord($data[self::SIZE_OF_NAME_POS]) | (ord($data[self::SIZE_OF_NAME_POS + 1]) << 8); $nameSize = \ord($data[self::SIZE_OF_NAME_POS]) | (\ord($data[self::SIZE_OF_NAME_POS + 1]) << 8);
// type of entry // type of entry
$type = ord($data[self::TYPE_POS]); $type = \ord($data[self::TYPE_POS]);
// sectorID of first sector or short sector, if this entry refers to a stream (the case with workbook) // sectorID of first sector or short sector, if this entry refers to a stream (the case with workbook)
// sectorID of first sector of the short-stream container stream, if this entry is root entry // sectorID of first sector of the short-stream container stream, if this entry is root entry
@ -285,7 +291,7 @@ class OLERead
$size = self::getInt4d($data, self::SIZE_POS); $size = self::getInt4d($data, self::SIZE_POS);
$name = str_replace("\x00", '', substr($data, 0, $nameSize)); $name = \str_replace("\x00", '', \substr($data, 0, $nameSize));
if ($size > 0) { if ($size > 0) {
$this->props[] = [ $this->props[] = [
'name' => $name, 'name' => $name,
@ -295,34 +301,35 @@ class OLERead
]; ];
// tmp helper to simplify checks // tmp helper to simplify checks
$upName = strtoupper($name); $upName = \strtoupper($name);
switch ($upName) { switch ($upName) {
case 'ROOT ENTRY': case 'ROOT ENTRY':
case 'R': case 'R':
$this->rootEntry = count($this->props) - 1; $this->rootEntry = \count($this->props) - 1;
break; break;
case chr(1) . 'COMPOBJ': case \chr(1) . 'COMPOBJ':
break; break;
case chr(1) . 'OLE': case \chr(1) . 'OLE':
break; break;
case chr(5) . 'SUMMARYINFORMATION': case \chr(5) . 'SUMMARYINFORMATION':
$this->summaryInformation = count($this->props) - 1; $this->summaryInformation = \count($this->props) - 1;
break; break;
case chr(5) . 'DOCUMENTSUMMARYINFORMATION': case \chr(5) . 'DOCUMENTSUMMARYINFORMATION':
$this->docSummaryInfos = count($this->props) - 1; $this->docSummaryInfos = \count($this->props) - 1;
break; break;
case 'CURRENT USER': case 'CURRENT USER':
$this->currentUser = count($this->props) - 1; $this->currentUser = \count($this->props) - 1;
break; break;
case 'PICTURES': case 'PICTURES':
$this->pictures = count($this->props) - 1; $this->pictures = \count($this->props) - 1;
break; break;
case 'POWERPOINT DOCUMENT': case 'POWERPOINT DOCUMENT':
$this->powerpointDocument = count($this->props) - 1; $this->powerpointDocument = \count($this->props) - 1;
break; break;
default: default:
throw new \Exception('OLE Block Not defined: $upName : ' . $upName . ' - $name : "' . $name . '"'); return;
//throw new \Exception('OLE Block Not defined: $upName : ' . $upName . ' - $name : "' . $name . '"');
} }
} }
@ -343,14 +350,14 @@ class OLERead
// FIX: represent numbers correctly on 64-bit system // FIX: represent numbers correctly on 64-bit system
// http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334 // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334
// Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems // Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems
$or24 = ord($data[$pos + 3]); $or24 = \ord($data[$pos + 3]);
if ($or24 >= 128) { if ($or24 >= 128) {
// negative number // negative number
$ord24 = -abs((256 - $or24) << 24); $ord24 = -\abs((256 - $or24) << 24);
} else { } else {
$ord24 = ($or24 & 127) << 24; $ord24 = ($or24 & 127) << 24;
} }
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $ord24; return \ord($data[$pos]) | (\ord($data[$pos + 1]) << 8) | (\ord($data[$pos + 2]) << 16) | $ord24;
} }
} }

View File

@ -116,44 +116,44 @@ class PasswordEncoder
*/ */
public static function hashPassword(string $password, string $algorithmName = self::ALGORITHM_SHA_1, string $salt = null, int $spinCount = 10000) public static function hashPassword(string $password, string $algorithmName = self::ALGORITHM_SHA_1, string $salt = null, int $spinCount = 10000)
{ {
$origEncoding = mb_internal_encoding(); $origEncoding = \mb_internal_encoding();
mb_internal_encoding('UTF-8'); \mb_internal_encoding('UTF-8');
$password = mb_substr($password, 0, min(self::$passwordMaxLength, mb_strlen($password))); $password = \mb_substr($password, 0, \min(self::$passwordMaxLength, \mb_strlen($password)));
// Get the single-byte values by iterating through the Unicode characters of the truncated password. // Get the single-byte values by iterating through the Unicode characters of the truncated password.
// For each character, if the low byte is not equal to 0, take it. Otherwise, take the high byte. // For each character, if the low byte is not equal to 0, take it. Otherwise, take the high byte.
$passUtf8 = mb_convert_encoding($password, 'UCS-2LE', 'UTF-8'); $passUtf8 = \mb_convert_encoding($password, 'UCS-2LE', 'UTF-8');
$byteChars = []; $byteChars = [];
for ($i = 0; $i < mb_strlen($password); ++$i) { for ($i = 0; $i < \mb_strlen($password); ++$i) {
$byteChars[$i] = ord(substr($passUtf8, $i * 2, 1)); $byteChars[$i] = \ord(\substr($passUtf8, $i * 2, 1));
if ($byteChars[$i] == 0) { if ($byteChars[$i] == 0) {
$byteChars[$i] = ord(substr($passUtf8, $i * 2 + 1, 1)); $byteChars[$i] = \ord(\substr($passUtf8, $i * 2 + 1, 1));
} }
} }
// build low-order word and hig-order word and combine them // build low-order word and hig-order word and combine them
$combinedKey = self::buildCombinedKey($byteChars); $combinedKey = self::buildCombinedKey($byteChars);
// build reversed hexadecimal string // build reversed hexadecimal string
$hex = str_pad(strtoupper(dechex($combinedKey & 0xFFFFFFFF)), 8, '0', \STR_PAD_LEFT); $hex = \str_pad(\strtoupper(\dechex($combinedKey & 0xFFFFFFFF)), 8, '0', \STR_PAD_LEFT);
$reversedHex = $hex[6] . $hex[7] . $hex[4] . $hex[5] . $hex[2] . $hex[3] . $hex[0] . $hex[1]; $reversedHex = $hex[6] . $hex[7] . $hex[4] . $hex[5] . $hex[2] . $hex[3] . $hex[0] . $hex[1];
$generatedKey = mb_convert_encoding($reversedHex, 'UCS-2LE', 'UTF-8'); $generatedKey = \mb_convert_encoding($reversedHex, 'UCS-2LE', 'UTF-8');
// Implementation Notes List: // Implementation Notes List:
// Word requires that the initial hash of the password with the salt not be considered in the count. // Word requires that the initial hash of the password with the salt not be considered in the count.
// The initial hash of salt + key is not included in the iteration count. // The initial hash of salt + key is not included in the iteration count.
$algorithm = self::getAlgorithm($algorithmName); $algorithm = self::getAlgorithm($algorithmName);
$generatedKey = hash($algorithm, $salt . $generatedKey, true); $generatedKey = \hash($algorithm, $salt . $generatedKey, true);
for ($i = 0; $i < $spinCount; ++$i) { for ($i = 0; $i < $spinCount; ++$i) {
$generatedKey = hash($algorithm, $generatedKey . pack('CCCC', $i, $i >> 8, $i >> 16, $i >> 24), true); $generatedKey = \hash($algorithm, $generatedKey . \pack('CCCC', $i, $i >> 8, $i >> 16, $i >> 24), true);
} }
$generatedKey = base64_encode($generatedKey); $generatedKey = \base64_encode($generatedKey);
mb_internal_encoding($origEncoding); \mb_internal_encoding($origEncoding);
return $generatedKey; return $generatedKey;
} }
@ -196,7 +196,7 @@ class PasswordEncoder
*/ */
private static function buildCombinedKey(array $byteChars): int private static function buildCombinedKey(array $byteChars): int
{ {
$byteCharsLength = count($byteChars); $byteCharsLength = \count($byteChars);
// Compute the high-order word // Compute the high-order word
// Initialize from the initial code array (see above), depending on the passwords length. // Initialize from the initial code array (see above), depending on the passwords length.
$highOrderWord = self::$initialCodeArray[$byteCharsLength - 1]; $highOrderWord = self::$initialCodeArray[$byteCharsLength - 1];
@ -231,7 +231,7 @@ class PasswordEncoder
} }
/** /**
* Simulate behaviour of (signed) int32 * Simulate behavior of (signed) int32
* *
* @codeCoverageIgnore * @codeCoverageIgnore
* *

View File

@ -36,8 +36,8 @@ class Text
{ {
for ($i = 0; $i <= 19; ++$i) { for ($i = 0; $i <= 19; ++$i) {
if ($i != 9 && $i != 10 && $i != 13) { if ($i != 9 && $i != 10 && $i != 13) {
$find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_'; $find = '_x' . \sprintf('%04s', \strtoupper(\dechex($i))) . '_';
$replace = chr($i); $replace = \chr($i);
self::$controlCharacters[$find] = $replace; self::$controlCharacters[$find] = $replace;
} }
} }
@ -64,7 +64,7 @@ class Text
self::buildControlCharacters(); self::buildControlCharacters();
} }
return str_replace(array_values(self::$controlCharacters), array_keys(self::$controlCharacters), $value); return \str_replace(\array_values(self::$controlCharacters), \array_keys(self::$controlCharacters), $value);
} }
/** /**
@ -77,7 +77,7 @@ class Text
*/ */
public static function numberFormat(float $number, int $decimals): string public static function numberFormat(float $number, int $decimals): string
{ {
return number_format($number, $decimals, '.', ''); return \number_format($number, $decimals, '.', '');
} }
/** /**
@ -92,16 +92,16 @@ class Text
public static function chr(int $dec): string public static function chr(int $dec): string
{ {
if ($dec <= 0x7F) { if ($dec <= 0x7F) {
return chr($dec); return \chr($dec);
} }
if ($dec <= 0x7FF) { if ($dec <= 0x7FF) {
return chr(($dec >> 6) + 192) . chr(($dec & 63) + 128); return \chr(($dec >> 6) + 192) . \chr(($dec & 63) + 128);
} }
if ($dec <= 0xFFFF) { if ($dec <= 0xFFFF) {
return chr(($dec >> 12) + 224) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128); return \chr(($dec >> 12) + 224) . \chr((($dec >> 6) & 63) + 128) . \chr(($dec & 63) + 128);
} }
if ($dec <= 0x1FFFFF) { if ($dec <= 0x1FFFFF) {
return chr(($dec >> 18) + 240) . chr((($dec >> 12) & 63) + 128) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128); return \chr(($dec >> 18) + 240) . \chr((($dec >> 12) & 63) + 128) . \chr((($dec >> 6) & 63) + 128) . \chr(($dec & 63) + 128);
} }
return ''; return '';
@ -120,7 +120,7 @@ class Text
self::buildControlCharacters(); self::buildControlCharacters();
} }
return str_replace(array_keys(self::$controlCharacters), array_values(self::$controlCharacters), $value); return \str_replace(\array_keys(self::$controlCharacters), \array_values(self::$controlCharacters), $value);
} }
/** /**
@ -132,7 +132,7 @@ class Text
*/ */
public static function isUTF8(string $value = ''): bool public static function isUTF8(string $value = ''): bool
{ {
return is_string($value) && ($value === '' || preg_match('/^./su', $value) == 1); return \is_string($value) && ($value === '' || \preg_match('/^./su', $value) == 1);
} }
/** /**
@ -144,8 +144,8 @@ class Text
*/ */
public static function toUTF8(?string $value = ''): ?string public static function toUTF8(?string $value = ''): ?string
{ {
if (!is_null($value) && !self::isUTF8($value)) { if (!\is_null($value) && !self::isUTF8($value)) {
$value = utf8_encode($value); $value = \utf8_encode($value);
} }
return $value; return $value;
@ -184,16 +184,16 @@ class Text
$lookingFor = 1; $lookingFor = 1;
// Gets unicode for each character // Gets unicode for each character
for ($i = 0; $i < strlen($text); ++$i) { for ($i = 0; $i < \strlen($text); ++$i) {
$thisValue = ord($text[$i]); $thisValue = \ord($text[$i]);
if ($thisValue < 128) { if ($thisValue < 128) {
$unicode[] = $thisValue; $unicode[] = $thisValue;
} else { } else {
if (count($values) == 0) { if (\count($values) == 0) {
$lookingFor = $thisValue < 224 ? 2 : 3; $lookingFor = $thisValue < 224 ? 2 : 3;
} }
$values[] = $thisValue; $values[] = $thisValue;
if (count($values) == $lookingFor) { if (\count($values) == $lookingFor) {
if ($lookingFor == 3) { if ($lookingFor == 3) {
$number = (($values[0] % 16) * 4096) + (($values[1] % 64) * 64) + ($values[2] % 64); $number = (($values[0] % 16) * 4096) + (($values[1] % 64) * 64) + ($values[2] % 64);
} else { } else {
@ -225,7 +225,7 @@ class Text
foreach ($unicode as $value) { foreach ($unicode as $value) {
if ($value != 65279) { if ($value != 65279) {
$entities .= $value > 127 ? '\uc0{\u' . $value . '}' : chr($value); $entities .= $value > 127 ? '\uc0{\u' . $value . '}' : \chr($value);
} }
} }
@ -241,9 +241,9 @@ class Text
*/ */
public static function removeUnderscorePrefix(?string $value): string public static function removeUnderscorePrefix(?string $value): string
{ {
if (!is_null($value)) { if (!\is_null($value)) {
if (substr($value, 0, 1) == '_') { if (\substr($value, 0, 1) == '_') {
$value = substr($value, 1); $value = \substr($value, 1);
} }
} }

View File

@ -33,14 +33,14 @@ class XMLReader
/** /**
* DOMDocument object * DOMDocument object
* *
* @var DOMDocument * @var \DOMDocument
*/ */
private $dom = null; private $dom = null;
/** /**
* DOMXpath object * DOMXpath object
* *
* @var DOMXpath * @var \DOMXpath
*/ */
private $xpath = null; private $xpath = null;
@ -50,17 +50,17 @@ class XMLReader
* @param string $zipFile * @param string $zipFile
* @param string $xmlFile * @param string $xmlFile
* *
* @return DOMDocument|false * @return \DOMDocument|false
* *
* @throws \Exception * @throws \Exception
*/ */
public function getDomFromZip(string $zipFile, string $xmlFile) public function getDomFromZip(string $zipFile, string $xmlFile)
{ {
if (file_exists($zipFile) === false) { if (\file_exists($zipFile) === false) {
throw new \Exception('Cannot find archive file.'); throw new \Exception('Cannot find archive file.');
} }
$zip = new ZipArchive(); $zip = new \ZipArchive();
$zip->open($zipFile); $zip->open($zipFile);
$content = $zip->getFromName($xmlFile); $content = $zip->getFromName($xmlFile);
$zip->close(); $zip->close();
@ -77,20 +77,20 @@ class XMLReader
* *
* @param string $content * @param string $content
* *
* @return DOMDocument * @return \DOMDocument
*/ */
public function getDomFromString(string $content) public function getDomFromString(string $content)
{ {
$originalLibXMLEntityValue = false; $originalLibXMLEntityValue = false;
if (\PHP_VERSION_ID < 80000) { if (\PHP_VERSION_ID < 80000) {
$originalLibXMLEntityValue = libxml_disable_entity_loader(true); $originalLibXMLEntityValue = \libxml_disable_entity_loader(true);
} }
$this->dom = new DOMDocument(); $this->dom = new \DOMDocument();
$this->dom->loadXML($content); $this->dom->loadXML($content);
if (\PHP_VERSION_ID < 80000) { if (\PHP_VERSION_ID < 80000) {
libxml_disable_entity_loader($originalLibXMLEntityValue); \libxml_disable_entity_loader($originalLibXMLEntityValue);
} }
return $this->dom; return $this->dom;
@ -100,20 +100,20 @@ class XMLReader
* Get elements * Get elements
* *
* @param string $path * @param string $path
* @param DOMElement $contextNode * @param \DOMElement $contextNode
* *
* @return DOMNodeList<DOMElement> * @return \DOMNodeList<\DOMElement>
*/ */
public function getElements(string $path, DOMElement $contextNode = null) public function getElements(string $path, \DOMElement $contextNode = null)
{ {
if ($this->dom === null) { if ($this->dom === null) {
return new DOMNodeList(); return new \DOMNodeList();
} }
if ($this->xpath === null) { if ($this->xpath === null) {
$this->xpath = new DOMXpath($this->dom); $this->xpath = new \DOMXpath($this->dom);
} }
if (is_null($contextNode)) { if (\is_null($contextNode)) {
return $this->xpath->query($path); return $this->xpath->query($path);
} }
@ -136,7 +136,7 @@ class XMLReader
throw new \InvalidArgumentException('Dom needs to be loaded before registering a namespace'); throw new \InvalidArgumentException('Dom needs to be loaded before registering a namespace');
} }
if ($this->xpath === null) { if ($this->xpath === null) {
$this->xpath = new DOMXpath($this->dom); $this->xpath = new \DOMXpath($this->dom);
} }
return $this->xpath->registerNamespace($prefix, $namespaceURI); return $this->xpath->registerNamespace($prefix, $namespaceURI);
@ -146,15 +146,15 @@ class XMLReader
* Get element * Get element
* *
* @param string $path * @param string $path
* @param DOMElement $contextNode * @param \DOMElement $contextNode
* *
* @return DOMElement|null * @return \DOMElement|null
*/ */
public function getElement($path, DOMElement $contextNode = null): ?DOMElement public function getElement($path, \DOMElement $contextNode = null): ?\DOMElement
{ {
$elements = $this->getElements($path, $contextNode); $elements = $this->getElements($path, $contextNode);
if ($elements->length > 0) { if ($elements->length > 0) {
return $elements->item(0) instanceof DOMElement ? $elements->item(0) : null; return $elements->item(0) instanceof \DOMElement ? $elements->item(0) : null;
} }
return null; return null;
@ -164,18 +164,18 @@ class XMLReader
* Get element attribute * Get element attribute
* *
* @param string $attribute * @param string $attribute
* @param DOMElement $contextNode * @param \DOMElement $contextNode
* @param string $path * @param string $path
* *
* @return string|null * @return string|null
*/ */
public function getAttribute($attribute, DOMElement $contextNode = null, $path = null) public function getAttribute($attribute, \DOMElement $contextNode = null, $path = null)
{ {
$return = null; $return = null;
if ($path !== null) { if ($path !== null) {
$elements = $this->getElements($path, $contextNode); $elements = $this->getElements($path, $contextNode);
if ($elements->length > 0) { if ($elements->length > 0) {
/** @var DOMElement $node Type hint */ /** @var \DOMElement $node Type hint */
$node = $elements->item(0); $node = $elements->item(0);
$return = $node->getAttribute($attribute); $return = $node->getAttribute($attribute);
} }
@ -192,11 +192,11 @@ class XMLReader
* Get element value * Get element value
* *
* @param string $path * @param string $path
* @param DOMElement $contextNode * @param \DOMElement $contextNode
* *
* @return string|null * @return string|null
*/ */
public function getValue($path, DOMElement $contextNode = null) public function getValue($path, \DOMElement $contextNode = null)
{ {
$elements = $this->getElements($path, $contextNode); $elements = $this->getElements($path, $contextNode);
if ($elements->length > 0) { if ($elements->length > 0) {
@ -210,11 +210,11 @@ class XMLReader
* Count elements * Count elements
* *
* @param string $path * @param string $path
* @param DOMElement $contextNode * @param \DOMElement $contextNode
* *
* @return int * @return int
*/ */
public function countElements($path, DOMElement $contextNode = null) public function countElements($path, \DOMElement $contextNode = null)
{ {
$elements = $this->getElements($path, $contextNode); $elements = $this->getElements($path, $contextNode);
@ -225,11 +225,11 @@ class XMLReader
* Element exists * Element exists
* *
* @param string $path * @param string $path
* @param DOMElement $contextNode * @param \DOMElement $contextNode
* *
* @return bool * @return bool
*/ */
public function elementExists($path, DOMElement $contextNode = null) public function elementExists($path, \DOMElement $contextNode = null)
{ {
return $this->getElements($path, $contextNode)->length > 0; return $this->getElements($path, $contextNode)->length > 0;
} }

View File

@ -59,11 +59,11 @@ class XMLWriter extends \XMLWriter
if ($pTemporaryStorage == self::STORAGE_MEMORY) { if ($pTemporaryStorage == self::STORAGE_MEMORY) {
$this->openMemory(); $this->openMemory();
} else { } else {
if ($pTemporaryStorageDir && !is_dir($pTemporaryStorageDir)) { if ($pTemporaryStorageDir && !\is_dir($pTemporaryStorageDir)) {
$pTemporaryStorageDir = sys_get_temp_dir(); $pTemporaryStorageDir = \sys_get_temp_dir();
} }
// Create temporary filename // Create temporary filename
$this->tempFileName = @tempnam($pTemporaryStorageDir, 'xml'); $this->tempFileName = @\tempnam($pTemporaryStorageDir, 'xml');
// Open storage // Open storage
$this->openUri($this->tempFileName); $this->openUri($this->tempFileName);
@ -87,7 +87,7 @@ class XMLWriter extends \XMLWriter
if (empty($this->tempFileName)) { if (empty($this->tempFileName)) {
return; return;
} }
if (PHP_OS != 'WINNT' && @unlink($this->tempFileName) === false) { if (PHP_OS != 'WINNT' && @\unlink($this->tempFileName) === false) {
throw new \Exception('The file ' . $this->tempFileName . ' could not be deleted.'); throw new \Exception('The file ' . $this->tempFileName . ' could not be deleted.');
} }
} }
@ -105,7 +105,7 @@ class XMLWriter extends \XMLWriter
$this->flush(); $this->flush();
return file_get_contents($this->tempFileName); return \file_get_contents($this->tempFileName);
} }
/** /**
@ -124,7 +124,7 @@ class XMLWriter extends \XMLWriter
public function writeElementBlock(string $element, $attributes, string $value = null) public function writeElementBlock(string $element, $attributes, string $value = null)
{ {
$this->startElement($element); $this->startElement($element);
if (!is_array($attributes)) { if (!\is_array($attributes)) {
$attributes = [$attributes => $value]; $attributes = [$attributes => $value];
} }
foreach ($attributes as $attribute => $value) { foreach ($attributes as $attribute => $value) {
@ -146,7 +146,7 @@ class XMLWriter extends \XMLWriter
public function writeElementIf(bool $condition, string $element, ?string $attribute = null, $value = null) public function writeElementIf(bool $condition, string $element, ?string $attribute = null, $value = null)
{ {
if ($condition) { if ($condition) {
if (is_null($attribute)) { if (\is_null($attribute)) {
$this->writeElement($element, $value); $this->writeElement($element, $value);
} else { } else {
$this->startElement($element); $this->startElement($element);
@ -180,8 +180,8 @@ class XMLWriter extends \XMLWriter
*/ */
public function writeAttribute($name, $value): bool public function writeAttribute($name, $value): bool
{ {
if (is_float($value)) { if (\is_float($value)) {
$value = json_encode($value); $value = \json_encode($value);
} }
return parent::writeAttribute($name, $value ?? ''); return parent::writeAttribute($name, $value ?? '');

View File

@ -153,10 +153,10 @@ abstract class AbstractShape implements ComparableInterface
*/ */
public function setContainer(ShapeContainerInterface $pValue = null, $pOverrideOld = false) public function setContainer(ShapeContainerInterface $pValue = null, $pOverrideOld = false)
{ {
if (is_null($this->container)) { if (\is_null($this->container)) {
// Add drawing to ShapeContainerInterface // Add drawing to ShapeContainerInterface
$this->container = $pValue; $this->container = $pValue;
if (!is_null($this->container)) { if (!\is_null($this->container)) {
$this->container->getShapeCollection()->append($this); $this->container->getShapeCollection()->append($this);
} }
} else { } else {
@ -345,7 +345,7 @@ abstract class AbstractShape implements ComparableInterface
*/ */
public function hasHyperlink() public function hasHyperlink()
{ {
return !is_null($this->hyperlink); return !\is_null($this->hyperlink);
} }
/** /**
@ -353,7 +353,7 @@ abstract class AbstractShape implements ComparableInterface
*/ */
public function getHyperlink(): Hyperlink public function getHyperlink(): Hyperlink
{ {
if (is_null($this->hyperlink)) { if (\is_null($this->hyperlink)) {
$this->hyperlink = new Hyperlink(); $this->hyperlink = new Hyperlink();
} }
@ -377,7 +377,7 @@ abstract class AbstractShape implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5((is_object($this->container) ? $this->container->getHashCode() : '') . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->rotation . (is_null($this->getFill()) ? '' : $this->getFill()->getHashCode()) . (is_null($this->shadow) ? '' : $this->shadow->getHashCode()) . (is_null($this->hyperlink) ? '' : $this->hyperlink->getHashCode()) . __CLASS__); return \md5((\is_object($this->container) ? $this->container->getHashCode() : '') . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->rotation . (\is_null($this->getFill()) ? '' : $this->getFill()->getHashCode()) . (\is_null($this->shadow) ? '' : $this->shadow->getHashCode()) . (\is_null($this->hyperlink) ? '' : $this->hyperlink->getHashCode()) . __CLASS__);
} }
/** /**
@ -412,7 +412,7 @@ abstract class AbstractShape implements ComparableInterface
public function isPlaceholder(): bool public function isPlaceholder(): bool
{ {
return !is_null($this->placeholder); return !\is_null($this->placeholder);
} }
public function getPlaceholder(): ?Placeholder public function getPlaceholder(): ?Placeholder

View File

@ -33,7 +33,7 @@ class Autoloader
*/ */
public static function register(): void public static function register(): void
{ {
spl_autoload_register([new self(), 'autoload']); \spl_autoload_register([new self(), 'autoload']);
} }
/** /**
@ -41,14 +41,14 @@ class Autoloader
*/ */
public static function autoload(string $class): void public static function autoload(string $class): void
{ {
$prefixLength = strlen(self::NAMESPACE_PREFIX); $prefixLength = \strlen(self::NAMESPACE_PREFIX);
if (0 === strncmp(self::NAMESPACE_PREFIX, $class, $prefixLength)) { if (0 === \strncmp(self::NAMESPACE_PREFIX, $class, $prefixLength)) {
$file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength)); $file = \str_replace('\\', DIRECTORY_SEPARATOR, \substr($class, $prefixLength));
$file = realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php'); $file = \realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php');
if (!$file) { if (!$file) {
return; return;
} }
if (file_exists($file)) { if (\file_exists($file)) {
/** @noinspection PhpIncludeInspection Dynamic includes */ /** @noinspection PhpIncludeInspection Dynamic includes */
require_once $file; require_once $file;
} }

View File

@ -117,8 +117,8 @@ class DocumentProperties
// Initialise values // Initialise values
$this->creator = 'Unknown Creator'; $this->creator = 'Unknown Creator';
$this->lastModifiedBy = $this->creator; $this->lastModifiedBy = $this->creator;
$this->created = time(); $this->created = \time();
$this->modified = time(); $this->modified = \time();
$this->title = 'Untitled Presentation'; $this->title = 'Untitled Presentation';
$this->subject = ''; $this->subject = '';
$this->description = ''; $this->description = '';
@ -194,8 +194,8 @@ class DocumentProperties
*/ */
public function setCreated($pValue = null) public function setCreated($pValue = null)
{ {
if (is_null($pValue)) { if (\is_null($pValue)) {
$pValue = time(); $pValue = \time();
} }
$this->created = $pValue; $this->created = $pValue;
@ -221,8 +221,8 @@ class DocumentProperties
*/ */
public function setModified($pValue = null) public function setModified($pValue = null)
{ {
if (is_null($pValue)) { if (\is_null($pValue)) {
$pValue = time(); $pValue = \time();
} }
$this->modified = $pValue; $this->modified = $pValue;
@ -380,7 +380,7 @@ class DocumentProperties
*/ */
public function getCustomProperties(): array public function getCustomProperties(): array
{ {
return array_keys($this->customProperties); return \array_keys($this->customProperties);
} }
/** /**
@ -443,18 +443,18 @@ class DocumentProperties
*/ */
public function setCustomProperty(string $propertyName, $propertyValue = '', ?string $propertyType = null): self public function setCustomProperty(string $propertyName, $propertyValue = '', ?string $propertyType = null): self
{ {
if (!in_array($propertyType, [ if (!\in_array($propertyType, [
self::PROPERTY_TYPE_INTEGER, self::PROPERTY_TYPE_INTEGER,
self::PROPERTY_TYPE_FLOAT, self::PROPERTY_TYPE_FLOAT,
self::PROPERTY_TYPE_STRING, self::PROPERTY_TYPE_STRING,
self::PROPERTY_TYPE_DATE, self::PROPERTY_TYPE_DATE,
self::PROPERTY_TYPE_BOOLEAN, self::PROPERTY_TYPE_BOOLEAN,
])) { ])) {
if (is_float($propertyValue)) { if (\is_float($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_FLOAT; $propertyType = self::PROPERTY_TYPE_FLOAT;
} elseif (is_int($propertyValue)) { } elseif (\is_int($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_INTEGER; $propertyType = self::PROPERTY_TYPE_INTEGER;
} elseif (is_bool($propertyValue)) { } elseif (\is_bool($propertyValue)) {
$propertyType = self::PROPERTY_TYPE_BOOLEAN; $propertyType = self::PROPERTY_TYPE_BOOLEAN;
} else { } else {
$propertyType = self::PROPERTY_TYPE_STRING; $propertyType = self::PROPERTY_TYPE_STRING;

View File

@ -24,7 +24,7 @@ class DirectoryNotFoundException extends PhpPresentationException
{ {
public function __construct(string $path) public function __construct(string $path)
{ {
parent::__construct(sprintf( parent::__construct(\sprintf(
'The directory %s doesn\'t exist', 'The directory %s doesn\'t exist',
$path $path
)); ));

View File

@ -24,7 +24,7 @@ class FileCopyException extends PhpPresentationException
{ {
public function __construct(string $source, string $destination) public function __construct(string $source, string $destination)
{ {
parent::__construct(sprintf( parent::__construct(\sprintf(
'The file %s can\'t be copied to %s', 'The file %s can\'t be copied to %s',
$source, $source,
$destination $destination

View File

@ -24,7 +24,7 @@ class FileNotFoundException extends PhpPresentationException
{ {
public function __construct(string $path) public function __construct(string $path)
{ {
parent::__construct(sprintf( parent::__construct(\sprintf(
'The file "%s" doesn\'t exist', 'The file "%s" doesn\'t exist',
$path $path
)); ));

View File

@ -24,7 +24,7 @@ class FileRemoveException extends PhpPresentationException
{ {
public function __construct(string $path) public function __construct(string $path)
{ {
parent::__construct(sprintf( parent::__construct(\sprintf(
'The file %s can\'t be removed', 'The file %s can\'t be removed',
$path $path
)); ));

View File

@ -24,7 +24,7 @@ class InvalidClassException extends PhpPresentationException
{ {
public function __construct(string $class, string $error) public function __construct(string $class, string $error)
{ {
parent::__construct(sprintf( parent::__construct(\sprintf(
'The class %s is invalid (%s)', 'The class %s is invalid (%s)',
$class, $class,
$error $error

View File

@ -31,7 +31,7 @@ class InvalidFileFormatException extends PhpPresentationException
$error = '(' . $error . ')'; $error = '(' . $error . ')';
} }
parent::__construct(sprintf( parent::__construct(\sprintf(
'The file %s is not in the format supported by %s%s%s', 'The file %s is not in the format supported by %s%s%s',
$path, $path,
$class, $class,

View File

@ -24,7 +24,7 @@ class InvalidParameterException extends PhpPresentationException
{ {
public function __construct(string $parameter, string $value) public function __construct(string $parameter, string $value)
{ {
parent::__construct(sprintf( parent::__construct(\sprintf(
'The parameter %s can\'t have the value "%s"', 'The parameter %s can\'t have the value "%s"',
$parameter, $parameter,
$value $value

View File

@ -24,7 +24,7 @@ class OutOfBoundsException extends PhpPresentationException
{ {
public function __construct(int $minBounds, ?int $maxBounds, int $expectedBounds) public function __construct(int $minBounds, ?int $maxBounds, int $expectedBounds)
{ {
parent::__construct(sprintf( parent::__construct(\sprintf(
'The expected value (%d) is out of bounds (%d, %s)', 'The expected value (%d) is out of bounds (%d, %s)',
$expectedBounds, $expectedBounds,
$minBounds, $minBounds,

View File

@ -22,6 +22,6 @@ namespace PhpOffice\PhpPresentation\Exception;
use Exception; use Exception;
class PhpPresentationException extends Exception class PhpPresentationException extends \Exception
{ {
} }

View File

@ -24,7 +24,7 @@ class ShapeContainerAlreadyAssignedException extends PhpPresentationException
{ {
public function __construct(string $class) public function __construct(string $class)
{ {
parent::__construct(sprintf( parent::__construct(\sprintf(
'The shape %s has already a container assigned', 'The shape %s has already a container assigned',
$class $class
)); ));

View File

@ -28,10 +28,10 @@ class UnauthorizedMimetypeException extends PhpPresentationException
*/ */
public function __construct(string $expectedMimetype, array $authorizedMimetypes) public function __construct(string $expectedMimetype, array $authorizedMimetypes)
{ {
parent::__construct(sprintf( parent::__construct(\sprintf(
'The mime type %s is not found in autorized values (%s)', 'The mime type %s is not found in autorized values (%s)',
$expectedMimetype, $expectedMimetype,
implode(', ', $authorizedMimetypes) \implode(', ', $authorizedMimetypes)
)); ));
} }
} }

View File

@ -37,7 +37,7 @@ class GeometryCalculator
{ {
$offsets = [self::X => 0, self::Y => 0]; $offsets = [self::X => 0, self::Y => 0];
if (null !== $container && 0 != count($container->getShapeCollection())) { if (null !== $container && 0 != \count($container->getShapeCollection())) {
$shapes = $container->getShapeCollection(); $shapes = $container->getShapeCollection();
if (null !== $shapes[0]) { if (null !== $shapes[0]) {
$offsets[self::X] = $shapes[0]->getOffsetX(); $offsets[self::X] = $shapes[0]->getOffsetX();
@ -70,7 +70,7 @@ class GeometryCalculator
/** @var array<string, int> $extents */ /** @var array<string, int> $extents */
$extents = [self::X => 0, self::Y => 0]; $extents = [self::X => 0, self::Y => 0];
if (null !== $container && 0 != count($container->getShapeCollection())) { if (null !== $container && 0 != \count($container->getShapeCollection())) {
$shapes = $container->getShapeCollection(); $shapes = $container->getShapeCollection();
if (null !== $shapes[0]) { if (null !== $shapes[0]) {
$extents[self::X] = (int) ($shapes[0]->getOffsetX() + $shapes[0]->getWidth()); $extents[self::X] = (int) ($shapes[0]->getOffsetX() + $shapes[0]->getWidth());

View File

@ -78,7 +78,7 @@ class HashTable
// Add value // Add value
if (!isset($this->items[$hashCode])) { if (!isset($this->items[$hashCode])) {
$this->items[$hashCode] = $pSource; $this->items[$hashCode] = $pSource;
$index = count($this->items) - 1; $index = \count($this->items) - 1;
$this->keyMap[$index] = $hashCode; $this->keyMap[$index] = $hashCode;
$pSource->setHashIndex($index); $pSource->setHashIndex($index);
} else { } else {
@ -106,7 +106,7 @@ class HashTable
$deleteKey = $key; $deleteKey = $key;
} }
} }
unset($this->keyMap[count($this->keyMap) - 1]); unset($this->keyMap[\count($this->keyMap) - 1]);
} }
} }
@ -124,7 +124,7 @@ class HashTable
*/ */
public function count(): int public function count(): int
{ {
return count($this->items); return \count($this->items);
} }
/** /**
@ -134,7 +134,7 @@ class HashTable
*/ */
public function getIndexForHashCode(string $pHashCode = ''): int public function getIndexForHashCode(string $pHashCode = ''): int
{ {
$index = array_search($pHashCode, $this->keyMap); $index = \array_search($pHashCode, $this->keyMap);
return false === $index ? -1 : $index; return false === $index ? -1 : $index;
} }

View File

@ -94,13 +94,13 @@ class IOFactory
*/ */
private static function loadClass(string $class, string $type, PhpPresentation $phpPresentation = null) private static function loadClass(string $class, string $type, PhpPresentation $phpPresentation = null)
{ {
if (!class_exists($class)) { if (!\class_exists($class)) {
throw new InvalidClassException($class, $type . ': The class doesn\'t exist'); throw new InvalidClassException($class, $type . ': The class doesn\'t exist');
} }
if (!self::isConcreteClass($class)) { if (!self::isConcreteClass($class)) {
throw new InvalidClassException($class, $type . ': The class is an abstract class or an interface'); throw new InvalidClassException($class, $type . ': The class is an abstract class or an interface');
} }
if (is_null($phpPresentation)) { if (\is_null($phpPresentation)) {
return new $class(); return new $class();
} }
@ -112,7 +112,7 @@ class IOFactory
*/ */
private static function isConcreteClass(string $class): bool private static function isConcreteClass(string $class): bool
{ {
$reflection = new ReflectionClass($class); $reflection = new \ReflectionClass($class);
return !$reflection->isAbstract() && !$reflection->isInterface(); return !$reflection->isAbstract() && !$reflection->isInterface();
} }

View File

@ -68,7 +68,7 @@ class PhpPresentation
/** /**
* Collection of Master Slides. * Collection of Master Slides.
* *
* @var array<int, SlideMaster>|ArrayObject<int, SlideMaster> * @var array<int, SlideMaster>|\ArrayObject<int, SlideMaster>
*/ */
protected $slideMasters; protected $slideMasters;
@ -184,10 +184,10 @@ class PhpPresentation
*/ */
public function removeSlideByIndex(int $index = 0): self public function removeSlideByIndex(int $index = 0): self
{ {
if ($index > count($this->slideCollection) - 1) { if ($index > \count($this->slideCollection) - 1) {
throw new OutOfBoundsException(0, count($this->slideCollection) - 1, $index); throw new OutOfBoundsException(0, \count($this->slideCollection) - 1, $index);
} }
array_splice($this->slideCollection, $index, 1); \array_splice($this->slideCollection, $index, 1);
return $this; return $this;
} }
@ -201,8 +201,8 @@ class PhpPresentation
*/ */
public function getSlide(int $index = 0): Slide public function getSlide(int $index = 0): Slide
{ {
if ($index > count($this->slideCollection) - 1) { if ($index > \count($this->slideCollection) - 1) {
throw new OutOfBoundsException(0, count($this->slideCollection) - 1, $index); throw new OutOfBoundsException(0, \count($this->slideCollection) - 1, $index);
} }
return $this->slideCollection[$index]; return $this->slideCollection[$index];
@ -240,7 +240,7 @@ class PhpPresentation
*/ */
public function getSlideCount(): int public function getSlideCount(): int
{ {
return count($this->slideCollection); return \count($this->slideCollection);
} }
/** /**
@ -262,8 +262,8 @@ class PhpPresentation
*/ */
public function setActiveSlideIndex(int $index = 0): Slide public function setActiveSlideIndex(int $index = 0): Slide
{ {
if ($index > count($this->slideCollection) - 1) { if ($index > \count($this->slideCollection) - 1) {
throw new OutOfBoundsException(0, count($this->slideCollection) - 1, $index); throw new OutOfBoundsException(0, \count($this->slideCollection) - 1, $index);
} }
$this->activeSlideIndex = $index; $this->activeSlideIndex = $index;
@ -320,7 +320,7 @@ class PhpPresentation
{ {
$copied = clone $this; $copied = clone $this;
$slideCount = count($this->slideCollection); $slideCount = \count($this->slideCollection);
for ($i = 0; $i < $slideCount; ++$i) { for ($i = 0; $i < $slideCount; ++$i) {
$this->slideCollection[$i] = $this->slideCollection[$i]->copy(); $this->slideCollection[$i] = $this->slideCollection[$i]->copy();
$this->slideCollection[$i]->rebindParent($this); $this->slideCollection[$i]->rebindParent($this);
@ -330,7 +330,7 @@ class PhpPresentation
} }
/** /**
* @return array<int, Slide\SlideMaster>|ArrayObject<int, Slide\SlideMaster> * @return array<int, Slide\SlideMaster>|\ArrayObject<int, Slide\SlideMaster>
*/ */
public function getAllMasterSlides() public function getAllMasterSlides()
{ {
@ -338,11 +338,11 @@ class PhpPresentation
} }
/** /**
* @param array<int, Slide\SlideMaster>|ArrayObject<int, Slide\SlideMaster> $slideMasters * @param array<int, Slide\SlideMaster>|\ArrayObject<int, Slide\SlideMaster> $slideMasters
*/ */
public function setAllMasterSlides($slideMasters = []): self public function setAllMasterSlides($slideMasters = []): self
{ {
if ($slideMasters instanceof ArrayObject || is_array($slideMasters)) { if ($slideMasters instanceof \ArrayObject || \is_array($slideMasters)) {
$this->slideMasters = $slideMasters; $this->slideMasters = $slideMasters;
} }

View File

@ -128,7 +128,7 @@ class PresentationProperties
*/ */
public function setThumbnailPath(string $path = ''): self public function setThumbnailPath(string $path = ''): self
{ {
if (file_exists($path)) { if (\file_exists($path)) {
$this->thumbnail = $path; $this->thumbnail = $path;
} }
@ -180,7 +180,7 @@ class PresentationProperties
*/ */
public function setLastView(string $value = self::VIEW_SLIDE): self public function setLastView(string $value = self::VIEW_SLIDE): self
{ {
if (in_array($value, $this->arrayView)) { if (\in_array($value, $this->arrayView)) {
$this->lastView = $value; $this->lastView = $value;
} }
@ -222,7 +222,7 @@ class PresentationProperties
*/ */
public function setSlideshowType(string $value = self::SLIDESHOW_TYPE_PRESENT): self public function setSlideshowType(string $value = self::SLIDESHOW_TYPE_PRESENT): self
{ {
if (in_array($value, $this->arraySlideshowTypes)) { if (\in_array($value, $this->arraySlideshowTypes)) {
$this->slideshowType = $value; $this->slideshowType = $value;
} }

View File

@ -92,16 +92,16 @@ class ODPresentation implements ReaderInterface
public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!\file_exists($pFilename)) {
throw new FileNotFoundException($pFilename); throw new FileNotFoundException($pFilename);
} }
$oZip = new ZipArchive(); $oZip = new \ZipArchive();
// Is it a zip ? // Is it a zip ?
if (true === $oZip->open($pFilename)) { if (true === $oZip->open($pFilename)) {
// Is it an OpenXML Document ? // Is it an OpenXML Document ?
// Is it a Presentation ? // Is it a Presentation ?
if (is_array($oZip->statName('META-INF/manifest.xml')) && is_array($oZip->statName('mimetype')) && 'application/vnd.oasis.opendocument.presentation' == $oZip->getFromName('mimetype')) { if (\is_array($oZip->statName('META-INF/manifest.xml')) && \is_array($oZip->statName('mimetype')) && 'application/vnd.oasis.opendocument.presentation' == $oZip->getFromName('mimetype')) {
return true; return true;
} }
} }
@ -136,7 +136,7 @@ class ODPresentation implements ReaderInterface
$this->oPhpPresentation = new PhpPresentation(); $this->oPhpPresentation = new PhpPresentation();
$this->oPhpPresentation->removeSlideByIndex(); $this->oPhpPresentation->removeSlideByIndex();
$this->oZip = new ZipArchive(); $this->oZip = new \ZipArchive();
$this->oZip->open($pFilename); $this->oZip->open($pFilename);
$this->oXMLReader = new XMLReader(); $this->oXMLReader = new XMLReader();
@ -174,12 +174,12 @@ class ODPresentation implements ReaderInterface
$properties = $this->oPhpPresentation->getDocumentProperties(); $properties = $this->oPhpPresentation->getDocumentProperties();
foreach ($arrayProperties as $path => $property) { foreach ($arrayProperties as $path => $property) {
$oElement = $this->oXMLReader->getElement($path); $oElement = $this->oXMLReader->getElement($path);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
$value = $oElement->nodeValue; $value = $oElement->nodeValue;
if (in_array($property, ['setCreated', 'setModified'])) { if (\in_array($property, ['setCreated', 'setModified'])) {
$dateTime = DateTime::createFromFormat(DateTime::W3C, $value); $dateTime = \DateTime::createFromFormat(\DateTime::W3C, $value);
if (!$dateTime) { if (!$dateTime) {
$dateTime = new DateTime(); $dateTime = new \DateTime();
} }
$value = $dateTime->getTimestamp(); $value = $dateTime->getTimestamp();
} }
@ -188,7 +188,7 @@ class ODPresentation implements ReaderInterface
} }
foreach ($this->oXMLReader->getElements('/office:document-meta/office:meta/meta:user-defined') as $element) { foreach ($this->oXMLReader->getElements('/office:document-meta/office:meta/meta:user-defined') as $element) {
if (!($element instanceof DOMElement) if (!($element instanceof \DOMElement)
|| !$element->hasAttribute('meta:name')) { || !$element->hasAttribute('meta:name')) {
continue; continue;
} }
@ -200,7 +200,7 @@ class ODPresentation implements ReaderInterface
$propertyType = DocumentProperties::PROPERTY_TYPE_BOOLEAN; $propertyType = DocumentProperties::PROPERTY_TYPE_BOOLEAN;
break; break;
case 'float': case 'float':
$propertyType = filter_var($propertyValue, FILTER_VALIDATE_INT) === false $propertyType = \filter_var($propertyValue, FILTER_VALIDATE_INT) === false
? DocumentProperties::PROPERTY_TYPE_FLOAT ? DocumentProperties::PROPERTY_TYPE_FLOAT
: DocumentProperties::PROPERTY_TYPE_INTEGER; : DocumentProperties::PROPERTY_TYPE_INTEGER;
break; break;
@ -222,12 +222,12 @@ class ODPresentation implements ReaderInterface
protected function loadSlides(): void protected function loadSlides(): void
{ {
foreach ($this->oXMLReader->getElements('/office:document-content/office:automatic-styles/*') as $oElement) { foreach ($this->oXMLReader->getElements('/office:document-content/office:automatic-styles/*') as $oElement) {
if ($oElement instanceof DOMElement && $oElement->hasAttribute('style:name')) { if ($oElement instanceof \DOMElement && $oElement->hasAttribute('style:name')) {
$this->loadStyle($oElement); $this->loadStyle($oElement);
} }
} }
foreach ($this->oXMLReader->getElements('/office:document-content/office:body/office:presentation/draw:page') as $oElement) { foreach ($this->oXMLReader->getElements('/office:document-content/office:body/office:presentation/draw:page') as $oElement) {
if ($oElement instanceof DOMElement && 'draw:page' == $oElement->nodeName) { if ($oElement instanceof \DOMElement && 'draw:page' == $oElement->nodeName) {
$this->loadSlide($oElement); $this->loadSlide($oElement);
} }
} }
@ -236,7 +236,7 @@ class ODPresentation implements ReaderInterface
protected function loadPresentationProperties(): void protected function loadPresentationProperties(): void
{ {
$element = $this->oXMLReader->getElement('/office:document-content/office:body/office:presentation/presentation:settings'); $element = $this->oXMLReader->getElement('/office:document-content/office:body/office:presentation/presentation:settings');
if ($element instanceof DOMElement) { if ($element instanceof \DOMElement) {
if ($element->getAttribute('presentation:full-screen') === 'false') { if ($element->getAttribute('presentation:full-screen') === 'false') {
$this->oPhpPresentation->getPresentationProperties()->setSlideshowType(PresentationProperties::SLIDESHOW_TYPE_BROWSE); $this->oPhpPresentation->getPresentationProperties()->setSlideshowType(PresentationProperties::SLIDESHOW_TYPE_BROWSE);
} }
@ -246,26 +246,26 @@ class ODPresentation implements ReaderInterface
/** /**
* Extract style * Extract style
*/ */
protected function loadStyle(DOMElement $nodeStyle): bool protected function loadStyle(\DOMElement $nodeStyle): bool
{ {
$keyStyle = $nodeStyle->getAttribute('style:name'); $keyStyle = $nodeStyle->getAttribute('style:name');
$nodeDrawingPageProps = $this->oXMLReader->getElement('style:drawing-page-properties', $nodeStyle); $nodeDrawingPageProps = $this->oXMLReader->getElement('style:drawing-page-properties', $nodeStyle);
if ($nodeDrawingPageProps instanceof DOMElement) { if ($nodeDrawingPageProps instanceof \DOMElement) {
// Read Background Color // Read Background Color
if ($nodeDrawingPageProps->hasAttribute('draw:fill-color') && 'solid' == $nodeDrawingPageProps->getAttribute('draw:fill')) { if ($nodeDrawingPageProps->hasAttribute('draw:fill-color') && 'solid' == $nodeDrawingPageProps->getAttribute('draw:fill')) {
$oBackground = new \PhpOffice\PhpPresentation\Slide\Background\Color(); $oBackground = new \PhpOffice\PhpPresentation\Slide\Background\Color();
$oColor = new Color(); $oColor = new Color();
$oColor->setRGB(substr($nodeDrawingPageProps->getAttribute('draw:fill-color'), -6)); $oColor->setRGB(\substr($nodeDrawingPageProps->getAttribute('draw:fill-color'), -6));
$oBackground->setColor($oColor); $oBackground->setColor($oColor);
} }
// Read Background Image // Read Background Image
if ('bitmap' == $nodeDrawingPageProps->getAttribute('draw:fill') && $nodeDrawingPageProps->hasAttribute('draw:fill-image-name')) { if ('bitmap' == $nodeDrawingPageProps->getAttribute('draw:fill') && $nodeDrawingPageProps->hasAttribute('draw:fill-image-name')) {
$nameStyle = $nodeDrawingPageProps->getAttribute('draw:fill-image-name'); $nameStyle = $nodeDrawingPageProps->getAttribute('draw:fill-image-name');
if (!empty($this->arrayCommonStyles[$nameStyle]) && 'image' == $this->arrayCommonStyles[$nameStyle]['type'] && !empty($this->arrayCommonStyles[$nameStyle]['path'])) { if (!empty($this->arrayCommonStyles[$nameStyle]) && 'image' == $this->arrayCommonStyles[$nameStyle]['type'] && !empty($this->arrayCommonStyles[$nameStyle]['path'])) {
$tmpBkgImg = tempnam(sys_get_temp_dir(), 'PhpPresentationReaderODPBkg'); $tmpBkgImg = \tempnam(\sys_get_temp_dir(), 'PhpPresentationReaderODPBkg');
$contentImg = $this->oZip->getFromName($this->arrayCommonStyles[$nameStyle]['path']); $contentImg = $this->oZip->getFromName($this->arrayCommonStyles[$nameStyle]['path']);
file_put_contents($tmpBkgImg, $contentImg); \file_put_contents($tmpBkgImg, $contentImg);
$oBackground = new Image(); $oBackground = new Image();
$oBackground->setPath($tmpBkgImg); $oBackground->setPath($tmpBkgImg);
@ -274,27 +274,27 @@ class ODPresentation implements ReaderInterface
} }
$nodeGraphicProps = $this->oXMLReader->getElement('style:graphic-properties', $nodeStyle); $nodeGraphicProps = $this->oXMLReader->getElement('style:graphic-properties', $nodeStyle);
if ($nodeGraphicProps instanceof DOMElement) { if ($nodeGraphicProps instanceof \DOMElement) {
// Read Shadow // Read Shadow
if ($nodeGraphicProps->hasAttribute('draw:shadow') && 'visible' == $nodeGraphicProps->getAttribute('draw:shadow')) { if ($nodeGraphicProps->hasAttribute('draw:shadow') && 'visible' == $nodeGraphicProps->getAttribute('draw:shadow')) {
$oShadow = new Shadow(); $oShadow = new Shadow();
$oShadow->setVisible(true); $oShadow->setVisible(true);
if ($nodeGraphicProps->hasAttribute('draw:shadow-color')) { if ($nodeGraphicProps->hasAttribute('draw:shadow-color')) {
$oShadow->getColor()->setRGB(substr($nodeGraphicProps->getAttribute('draw:shadow-color'), -6)); $oShadow->getColor()->setRGB(\substr($nodeGraphicProps->getAttribute('draw:shadow-color'), -6));
} }
if ($nodeGraphicProps->hasAttribute('draw:shadow-opacity')) { if ($nodeGraphicProps->hasAttribute('draw:shadow-opacity')) {
$oShadow->setAlpha(100 - (int) substr($nodeGraphicProps->getAttribute('draw:shadow-opacity'), 0, -1)); $oShadow->setAlpha(100 - (int) \substr($nodeGraphicProps->getAttribute('draw:shadow-opacity'), 0, -1));
} }
if ($nodeGraphicProps->hasAttribute('draw:shadow-offset-x') && $nodeGraphicProps->hasAttribute('draw:shadow-offset-y')) { if ($nodeGraphicProps->hasAttribute('draw:shadow-offset-x') && $nodeGraphicProps->hasAttribute('draw:shadow-offset-y')) {
$offsetX = (float) substr($nodeGraphicProps->getAttribute('draw:shadow-offset-x'), 0, -2); $offsetX = (float) \substr($nodeGraphicProps->getAttribute('draw:shadow-offset-x'), 0, -2);
$offsetY = (float) substr($nodeGraphicProps->getAttribute('draw:shadow-offset-y'), 0, -2); $offsetY = (float) \substr($nodeGraphicProps->getAttribute('draw:shadow-offset-y'), 0, -2);
$distance = 0; $distance = 0;
if (0 != $offsetX) { if (0 != $offsetX) {
$distance = ($offsetX < 0 ? $offsetX * -1 : $offsetX); $distance = ($offsetX < 0 ? $offsetX * -1 : $offsetX);
} elseif (0 != $offsetY) { } elseif (0 != $offsetY) {
$distance = ($offsetY < 0 ? $offsetY * -1 : $offsetY); $distance = ($offsetY < 0 ? $offsetY * -1 : $offsetY);
} }
$oShadow->setDirection((int) rad2deg(atan2($offsetY, $offsetX))); $oShadow->setDirection((int) \rad2deg(\atan2($offsetY, $offsetX)));
$oShadow->setDistance(CommonDrawing::centimetersToPixels($distance)); $oShadow->setDistance(CommonDrawing::centimetersToPixels($distance));
} }
} }
@ -312,7 +312,7 @@ class ODPresentation implements ReaderInterface
$oFill->setFillType(Fill::FILL_SOLID); $oFill->setFillType(Fill::FILL_SOLID);
if ($nodeGraphicProps->hasAttribute('draw:fill-color')) { if ($nodeGraphicProps->hasAttribute('draw:fill-color')) {
$oColor = new Color(); $oColor = new Color();
$oColor->setRGB(substr($nodeGraphicProps->getAttribute('draw:fill-color'), 1)); $oColor->setRGB(\substr($nodeGraphicProps->getAttribute('draw:fill-color'), 1));
$oFill->setStartColor($oColor); $oFill->setStartColor($oColor);
} }
break; break;
@ -321,10 +321,10 @@ class ODPresentation implements ReaderInterface
} }
$nodeTextProperties = $this->oXMLReader->getElement('style:text-properties', $nodeStyle); $nodeTextProperties = $this->oXMLReader->getElement('style:text-properties', $nodeStyle);
if ($nodeTextProperties instanceof DOMElement) { if ($nodeTextProperties instanceof \DOMElement) {
$oFont = new Font(); $oFont = new Font();
if ($nodeTextProperties->hasAttribute('fo:color')) { if ($nodeTextProperties->hasAttribute('fo:color')) {
$oFont->getColor()->setRGB(substr($nodeTextProperties->getAttribute('fo:color'), -6)); $oFont->getColor()->setRGB(\substr($nodeTextProperties->getAttribute('fo:color'), -6));
} }
// Font Latin // Font Latin
if ($nodeTextProperties->hasAttribute('fo:font-family')) { if ($nodeTextProperties->hasAttribute('fo:font-family')) {
@ -339,7 +339,7 @@ class ODPresentation implements ReaderInterface
} }
if ($nodeTextProperties->hasAttribute('fo:font-size')) { if ($nodeTextProperties->hasAttribute('fo:font-size')) {
$oFont $oFont
->setSize((int) substr($nodeTextProperties->getAttribute('fo:font-size'), 0, -2)) ->setSize((int) \substr($nodeTextProperties->getAttribute('fo:font-size'), 0, -2))
->setFormat(Font::FORMAT_LATIN); ->setFormat(Font::FORMAT_LATIN);
} }
// Font East Asian // Font East Asian
@ -355,7 +355,7 @@ class ODPresentation implements ReaderInterface
} }
if ($nodeTextProperties->hasAttribute('style:font-size-asian')) { if ($nodeTextProperties->hasAttribute('style:font-size-asian')) {
$oFont $oFont
->setSize((int) substr($nodeTextProperties->getAttribute('style:font-size-asian'), 0, -2)) ->setSize((int) \substr($nodeTextProperties->getAttribute('style:font-size-asian'), 0, -2))
->setFormat(Font::FORMAT_EAST_ASIAN); ->setFormat(Font::FORMAT_EAST_ASIAN);
} }
// Font Complex Script // Font Complex Script
@ -371,7 +371,7 @@ class ODPresentation implements ReaderInterface
} }
if ($nodeTextProperties->hasAttribute('style:font-size-complex')) { if ($nodeTextProperties->hasAttribute('style:font-size-complex')) {
$oFont $oFont
->setSize((int) substr($nodeTextProperties->getAttribute('style:font-size-complex'), 0, -2)) ->setSize((int) \substr($nodeTextProperties->getAttribute('style:font-size-complex'), 0, -2))
->setFormat(Font::FORMAT_COMPLEX_SCRIPT); ->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
} }
if ($nodeTextProperties->hasAttribute('style:script-type')) { if ($nodeTextProperties->hasAttribute('style:script-type')) {
@ -390,18 +390,18 @@ class ODPresentation implements ReaderInterface
} }
$nodeParagraphProps = $this->oXMLReader->getElement('style:paragraph-properties', $nodeStyle); $nodeParagraphProps = $this->oXMLReader->getElement('style:paragraph-properties', $nodeStyle);
if ($nodeParagraphProps instanceof DOMElement) { if ($nodeParagraphProps instanceof \DOMElement) {
if ($nodeParagraphProps->hasAttribute('fo:line-height')) { if ($nodeParagraphProps->hasAttribute('fo:line-height')) {
$lineHeightUnit = $this->getExpressionUnit($nodeParagraphProps->getAttribute('fo:margin-bottom')); $lineHeightUnit = $this->getExpressionUnit($nodeParagraphProps->getAttribute('fo:margin-bottom'));
$lineSpacingMode = $lineHeightUnit == '%' ? Paragraph::LINE_SPACING_MODE_PERCENT : Paragraph::LINE_SPACING_MODE_POINT; $lineSpacingMode = $lineHeightUnit == '%' ? Paragraph::LINE_SPACING_MODE_PERCENT : Paragraph::LINE_SPACING_MODE_POINT;
$lineSpacing = $this->getExpressionValue($nodeParagraphProps->getAttribute('fo:margin-bottom')); $lineSpacing = $this->getExpressionValue($nodeParagraphProps->getAttribute('fo:margin-bottom'));
} }
if ($nodeParagraphProps->hasAttribute('fo:margin-bottom')) { if ($nodeParagraphProps->hasAttribute('fo:margin-bottom')) {
$spacingAfter = (float) substr($nodeParagraphProps->getAttribute('fo:margin-bottom'), 0, -2); $spacingAfter = (float) \substr($nodeParagraphProps->getAttribute('fo:margin-bottom'), 0, -2);
$spacingAfter = CommonDrawing::centimetersToPoints($spacingAfter); $spacingAfter = CommonDrawing::centimetersToPoints($spacingAfter);
} }
if ($nodeParagraphProps->hasAttribute('fo:margin-top')) { if ($nodeParagraphProps->hasAttribute('fo:margin-top')) {
$spacingBefore = (float) substr($nodeParagraphProps->getAttribute('fo:margin-top'), 0, -2); $spacingBefore = (float) \substr($nodeParagraphProps->getAttribute('fo:margin-top'), 0, -2);
$spacingBefore = CommonDrawing::centimetersToPoints($spacingBefore); $spacingBefore = CommonDrawing::centimetersToPoints($spacingBefore);
} }
$oAlignment = new Alignment(); $oAlignment = new Alignment();
@ -434,7 +434,7 @@ class ODPresentation implements ReaderInterface
$oAlignment = new Alignment(); $oAlignment = new Alignment();
$oBullet = new Bullet(); $oBullet = new Bullet();
$oBullet->setBulletType(Bullet::TYPE_NONE); $oBullet->setBulletType(Bullet::TYPE_NONE);
if ($oNodeListLevel instanceof DOMElement) { if ($oNodeListLevel instanceof \DOMElement) {
if ($oNodeListLevel->hasAttribute('text:level')) { if ($oNodeListLevel->hasAttribute('text:level')) {
$oAlignment->setLevel((int) $oNodeListLevel->getAttribute('text:level') - 1); $oAlignment->setLevel((int) $oNodeListLevel->getAttribute('text:level') - 1);
} }
@ -444,19 +444,19 @@ class ODPresentation implements ReaderInterface
} }
$oNodeListProperties = $this->oXMLReader->getElement('style:list-level-properties', $oNodeListLevel); $oNodeListProperties = $this->oXMLReader->getElement('style:list-level-properties', $oNodeListLevel);
if ($oNodeListProperties instanceof DOMElement) { if ($oNodeListProperties instanceof \DOMElement) {
if ($oNodeListProperties->hasAttribute('text:min-label-width')) { if ($oNodeListProperties->hasAttribute('text:min-label-width')) {
$oAlignment->setIndent(CommonDrawing::centimetersToPixels((float) substr($oNodeListProperties->getAttribute('text:min-label-width'), 0, -2))); $oAlignment->setIndent(CommonDrawing::centimetersToPixels((float) \substr($oNodeListProperties->getAttribute('text:min-label-width'), 0, -2)));
} }
if ($oNodeListProperties->hasAttribute('text:space-before')) { if ($oNodeListProperties->hasAttribute('text:space-before')) {
$iSpaceBefore = CommonDrawing::centimetersToPixels((float) substr($oNodeListProperties->getAttribute('text:space-before'), 0, -2)); $iSpaceBefore = CommonDrawing::centimetersToPixels((float) \substr($oNodeListProperties->getAttribute('text:space-before'), 0, -2));
$iMarginLeft = $iSpaceBefore + $oAlignment->getIndent(); $iMarginLeft = $iSpaceBefore + $oAlignment->getIndent();
$oAlignment->setMarginLeft($iMarginLeft); $oAlignment->setMarginLeft($iMarginLeft);
} }
} }
$oNodeTextProperties = $this->oXMLReader->getElement('style:text-properties', $oNodeListLevel); $oNodeTextProperties = $this->oXMLReader->getElement('style:text-properties', $oNodeListLevel);
if ($oNodeTextProperties instanceof DOMElement) { if ($oNodeTextProperties instanceof \DOMElement) {
if ($oNodeTextProperties->hasAttribute('fo:font-family')) { if ($oNodeTextProperties->hasAttribute('fo:font-family')) {
$oBullet->setBulletFont($oNodeTextProperties->getAttribute('fo:font-family')); $oBullet->setBulletFont($oNodeTextProperties->getAttribute('fo:font-family'));
} }
@ -489,7 +489,7 @@ class ODPresentation implements ReaderInterface
/** /**
* Read Slide * Read Slide
*/ */
protected function loadSlide(DOMElement $nodeSlide): bool protected function loadSlide(\DOMElement $nodeSlide): bool
{ {
// Core // Core
$this->oPhpPresentation->createSlide(); $this->oPhpPresentation->createSlide();
@ -504,7 +504,7 @@ class ODPresentation implements ReaderInterface
} }
} }
foreach ($this->oXMLReader->getElements('draw:frame', $nodeSlide) as $oNodeFrame) { foreach ($this->oXMLReader->getElements('draw:frame', $nodeSlide) as $oNodeFrame) {
if ($oNodeFrame instanceof DOMElement) { if ($oNodeFrame instanceof \DOMElement) {
if ($this->oXMLReader->getElement('draw:image', $oNodeFrame)) { if ($this->oXMLReader->getElement('draw:image', $oNodeFrame)) {
$this->loadShapeDrawing($oNodeFrame); $this->loadShapeDrawing($oNodeFrame);
continue; continue;
@ -522,20 +522,20 @@ class ODPresentation implements ReaderInterface
/** /**
* Read Shape Drawing * Read Shape Drawing
*/ */
protected function loadShapeDrawing(DOMElement $oNodeFrame): void protected function loadShapeDrawing(\DOMElement $oNodeFrame): void
{ {
// Core // Core
$mimetype = ''; $mimetype = '';
$oNodeImage = $this->oXMLReader->getElement('draw:image', $oNodeFrame); $oNodeImage = $this->oXMLReader->getElement('draw:image', $oNodeFrame);
if ($oNodeImage instanceof DOMElement) { if ($oNodeImage instanceof \DOMElement) {
if ($oNodeImage->hasAttribute('loext:mime-type')) { if ($oNodeImage->hasAttribute('loext:mime-type')) {
$mimetype = $oNodeImage->getAttribute('loext:mime-type'); $mimetype = $oNodeImage->getAttribute('loext:mime-type');
} }
if ($oNodeImage->hasAttribute('xlink:href')) { if ($oNodeImage->hasAttribute('xlink:href')) {
$sFilename = $oNodeImage->getAttribute('xlink:href'); $sFilename = $oNodeImage->getAttribute('xlink:href');
// svm = StarView Metafile // svm = StarView Metafile
if ('svm' == pathinfo($sFilename, PATHINFO_EXTENSION)) { if ('svm' == \pathinfo($sFilename, PATHINFO_EXTENSION)) {
return; return;
} }
$imageFile = $this->oZip->getFromName($sFilename); $imageFile = $this->oZip->getFromName($sFilename);
@ -549,21 +549,21 @@ class ODPresentation implements ReaderInterface
// Contents of file // Contents of file
if (empty($mimetype)) { if (empty($mimetype)) {
$shape = new Gd(); $shape = new Gd();
$shape->setImageResource(imagecreatefromstring($imageFile)); $shape->setImageResource(\imagecreatefromstring($imageFile));
} else { } else {
$shape = new Base64(); $shape = new Base64();
$shape->setData('data:' . $mimetype . ';base64,' . base64_encode($imageFile)); $shape->setData('data:' . $mimetype . ';base64,' . \base64_encode($imageFile));
} }
$shape->getShadow()->setVisible(false); $shape->getShadow()->setVisible(false);
$shape->setName($oNodeFrame->hasAttribute('draw:name') ? $oNodeFrame->getAttribute('draw:name') : ''); $shape->setName($oNodeFrame->hasAttribute('draw:name') ? $oNodeFrame->getAttribute('draw:name') : '');
$shape->setDescription($oNodeFrame->hasAttribute('draw:name') ? $oNodeFrame->getAttribute('draw:name') : ''); $shape->setDescription($oNodeFrame->hasAttribute('draw:name') ? $oNodeFrame->getAttribute('draw:name') : '');
$shape->setResizeProportional(false); $shape->setResizeProportional(false);
$shape->setWidth($oNodeFrame->hasAttribute('svg:width') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:width'), 0, -2)) : 0); $shape->setWidth($oNodeFrame->hasAttribute('svg:width') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:width'), 0, -2)) : 0);
$shape->setHeight($oNodeFrame->hasAttribute('svg:height') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:height'), 0, -2)) : 0); $shape->setHeight($oNodeFrame->hasAttribute('svg:height') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:height'), 0, -2)) : 0);
$shape->setResizeProportional(true); $shape->setResizeProportional(true);
$shape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:x'), 0, -2)) : 0); $shape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:x'), 0, -2)) : 0);
$shape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:y'), 0, -2)) : 0); $shape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:y'), 0, -2)) : 0);
if ($oNodeFrame->hasAttribute('draw:style-name')) { if ($oNodeFrame->hasAttribute('draw:style-name')) {
$keyStyle = $oNodeFrame->getAttribute('draw:style-name'); $keyStyle = $oNodeFrame->getAttribute('draw:style-name');
@ -579,20 +579,20 @@ class ODPresentation implements ReaderInterface
/** /**
* Read Shape RichText * Read Shape RichText
*/ */
protected function loadShapeRichText(DOMElement $oNodeFrame): void protected function loadShapeRichText(\DOMElement $oNodeFrame): void
{ {
// Core // Core
$oShape = $this->oPhpPresentation->getActiveSlide()->createRichTextShape(); $oShape = $this->oPhpPresentation->getActiveSlide()->createRichTextShape();
$oShape->setParagraphs([]); $oShape->setParagraphs([]);
$oShape->setWidth($oNodeFrame->hasAttribute('svg:width') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:width'), 0, -2)) : 0); $oShape->setWidth($oNodeFrame->hasAttribute('svg:width') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:width'), 0, -2)) : 0);
$oShape->setHeight($oNodeFrame->hasAttribute('svg:height') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:height'), 0, -2)) : 0); $oShape->setHeight($oNodeFrame->hasAttribute('svg:height') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:height'), 0, -2)) : 0);
$oShape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:x'), 0, -2)) : 0); $oShape->setOffsetX($oNodeFrame->hasAttribute('svg:x') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:x'), 0, -2)) : 0);
$oShape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? CommonDrawing::centimetersToPixels((float) substr($oNodeFrame->getAttribute('svg:y'), 0, -2)) : 0); $oShape->setOffsetY($oNodeFrame->hasAttribute('svg:y') ? CommonDrawing::centimetersToPixels((float) \substr($oNodeFrame->getAttribute('svg:y'), 0, -2)) : 0);
foreach ($this->oXMLReader->getElements('draw:text-box/*', $oNodeFrame) as $oNodeParagraph) { foreach ($this->oXMLReader->getElements('draw:text-box/*', $oNodeFrame) as $oNodeParagraph) {
$this->levelParagraph = 0; $this->levelParagraph = 0;
if ($oNodeParagraph instanceof DOMElement) { if ($oNodeParagraph instanceof \DOMElement) {
if ('text:p' == $oNodeParagraph->nodeName) { if ('text:p' == $oNodeParagraph->nodeName) {
$this->readParagraph($oShape, $oNodeParagraph); $this->readParagraph($oShape, $oNodeParagraph);
} }
@ -602,7 +602,7 @@ class ODPresentation implements ReaderInterface
} }
} }
if (count($oShape->getParagraphs()) > 0) { if (\count($oShape->getParagraphs()) > 0) {
$oShape->setActiveParagraph(0); $oShape->setActiveParagraph(0);
} }
} }
@ -610,7 +610,7 @@ class ODPresentation implements ReaderInterface
/** /**
* Read Paragraph * Read Paragraph
*/ */
protected function readParagraph(RichText $oShape, DOMElement $oNodeParent): void protected function readParagraph(RichText $oShape, \DOMElement $oNodeParent): void
{ {
$oParagraph = $oShape->createParagraph(); $oParagraph = $oShape->createParagraph();
if ($oNodeParent->hasAttribute('text:style-name')) { if ($oNodeParent->hasAttribute('text:style-name')) {
@ -633,13 +633,13 @@ class ODPresentation implements ReaderInterface
$oDomList = $this->oXMLReader->getElements('text:span', $oNodeParent); $oDomList = $this->oXMLReader->getElements('text:span', $oNodeParent);
$oDomTextNodes = $this->oXMLReader->getElements('text()', $oNodeParent); $oDomTextNodes = $this->oXMLReader->getElements('text()', $oNodeParent);
foreach ($oDomTextNodes as $oDomTextNode) { foreach ($oDomTextNodes as $oDomTextNode) {
if ('' != trim($oDomTextNode->nodeValue)) { if ('' != \trim($oDomTextNode->nodeValue)) {
$oTextRun = $oParagraph->createTextRun(); $oTextRun = $oParagraph->createTextRun();
$oTextRun->setText(trim($oDomTextNode->nodeValue)); $oTextRun->setText(\trim($oDomTextNode->nodeValue));
} }
} }
foreach ($oDomList as $oNodeRichTextElement) { foreach ($oDomList as $oNodeRichTextElement) {
if ($oNodeRichTextElement instanceof DOMElement) { if ($oNodeRichTextElement instanceof \DOMElement) {
$this->readParagraphItem($oParagraph, $oNodeRichTextElement); $this->readParagraphItem($oParagraph, $oNodeRichTextElement);
} }
} }
@ -648,7 +648,7 @@ class ODPresentation implements ReaderInterface
/** /**
* Read Paragraph Item * Read Paragraph Item
*/ */
protected function readParagraphItem(Paragraph $oParagraph, DOMElement $oNodeParent): void protected function readParagraphItem(Paragraph $oParagraph, \DOMElement $oNodeParent): void
{ {
if ($this->oXMLReader->elementExists('text:line-break', $oNodeParent)) { if ($this->oXMLReader->elementExists('text:line-break', $oNodeParent)) {
$oParagraph->createBreak(); $oParagraph->createBreak();
@ -661,7 +661,7 @@ class ODPresentation implements ReaderInterface
} }
} }
$oTextRunLink = $this->oXMLReader->getElement('text:a', $oNodeParent); $oTextRunLink = $this->oXMLReader->getElement('text:a', $oNodeParent);
if ($oTextRunLink instanceof DOMElement) { if ($oTextRunLink instanceof \DOMElement) {
$oTextRun->setText($oTextRunLink->nodeValue); $oTextRun->setText($oTextRunLink->nodeValue);
if ($oTextRunLink->hasAttribute('xlink:href')) { if ($oTextRunLink->hasAttribute('xlink:href')) {
$oTextRun->getHyperlink()->setUrl($oTextRunLink->getAttribute('xlink:href')); $oTextRun->getHyperlink()->setUrl($oTextRunLink->getAttribute('xlink:href'));
@ -675,10 +675,10 @@ class ODPresentation implements ReaderInterface
/** /**
* Read List * Read List
*/ */
protected function readList(RichText $oShape, DOMElement $oNodeParent): void protected function readList(RichText $oShape, \DOMElement $oNodeParent): void
{ {
foreach ($this->oXMLReader->getElements('text:list-item/*', $oNodeParent) as $oNodeListItem) { foreach ($this->oXMLReader->getElements('text:list-item/*', $oNodeParent) as $oNodeListItem) {
if ($oNodeListItem instanceof DOMElement) { if ($oNodeListItem instanceof \DOMElement) {
if ('text:p' == $oNodeListItem->nodeName) { if ('text:p' == $oNodeListItem->nodeName) {
$this->readListItem($oShape, $oNodeListItem, $oNodeParent); $this->readListItem($oShape, $oNodeListItem, $oNodeParent);
} }
@ -694,7 +694,7 @@ class ODPresentation implements ReaderInterface
/** /**
* Read List Item * Read List Item
*/ */
protected function readListItem(RichText $oShape, DOMElement $oNodeParent, DOMElement $oNodeParagraph): void protected function readListItem(RichText $oShape, \DOMElement $oNodeParent, \DOMElement $oNodeParagraph): void
{ {
$oParagraph = $oShape->createParagraph(); $oParagraph = $oShape->createParagraph();
if ($oNodeParagraph->hasAttribute('text:style-name')) { if ($oNodeParagraph->hasAttribute('text:style-name')) {
@ -705,7 +705,7 @@ class ODPresentation implements ReaderInterface
} }
} }
foreach ($this->oXMLReader->getElements('text:span', $oNodeParent) as $oNodeRichTextElement) { foreach ($this->oXMLReader->getElements('text:span', $oNodeParent) as $oNodeRichTextElement) {
if ($oNodeRichTextElement instanceof DOMElement) { if ($oNodeRichTextElement instanceof \DOMElement) {
$this->readParagraphItem($oParagraph, $oNodeRichTextElement); $this->readParagraphItem($oParagraph, $oNodeRichTextElement);
} }
} }
@ -717,7 +717,7 @@ class ODPresentation implements ReaderInterface
protected function loadStylesFile(): void protected function loadStylesFile(): void
{ {
foreach ($this->oXMLReader->getElements('/office:document-styles/office:styles/*') as $oElement) { foreach ($this->oXMLReader->getElements('/office:document-styles/office:styles/*') as $oElement) {
if ($oElement instanceof DOMElement && 'draw:fill-image' == $oElement->nodeName) { if ($oElement instanceof \DOMElement && 'draw:fill-image' == $oElement->nodeName) {
$this->arrayCommonStyles[$oElement->getAttribute('draw:name')] = [ $this->arrayCommonStyles[$oElement->getAttribute('draw:name')] = [
'type' => 'image', 'type' => 'image',
'path' => $oElement->hasAttribute('xlink:href') ? $oElement->getAttribute('xlink:href') : null, 'path' => $oElement->hasAttribute('xlink:href') ? $oElement->getAttribute('xlink:href') : null,
@ -733,11 +733,11 @@ class ODPresentation implements ReaderInterface
*/ */
private function getExpressionUnit(string $expr): string private function getExpressionUnit(string $expr): string
{ {
if (substr($expr, -1) == '%') { if (\substr($expr, -1) == '%') {
return '%'; return '%';
} }
return substr($expr, -2); return \substr($expr, -2);
} }
/** /**
@ -747,10 +747,10 @@ class ODPresentation implements ReaderInterface
*/ */
private function getExpressionValue(string $expr): string private function getExpressionValue(string $expr): string
{ {
if (substr($expr, -1) == '%') { if (\substr($expr, -1) == '%') {
return substr($expr, 0, -1); return \substr($expr, 0, -1);
} }
return substr($expr, 0, -2); return \substr($expr, 0, -2);
} }
} }

View File

@ -105,16 +105,16 @@ class PowerPoint2007 implements ReaderInterface
public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!\file_exists($pFilename)) {
throw new FileNotFoundException($pFilename); throw new FileNotFoundException($pFilename);
} }
$oZip = new ZipArchive(); $oZip = new \ZipArchive();
// Is it a zip ? // Is it a zip ?
if (true === $oZip->open($pFilename)) { if (true === $oZip->open($pFilename)) {
// Is it an OpenXML Document ? // Is it an OpenXML Document ?
// Is it a Presentation ? // Is it a Presentation ?
if (is_array($oZip->statName('[Content_Types].xml')) && is_array($oZip->statName('ppt/presentation.xml'))) { if (\is_array($oZip->statName('[Content_Types].xml')) && \is_array($oZip->statName('ppt/presentation.xml'))) {
return true; return true;
} }
} }
@ -147,7 +147,7 @@ class PowerPoint2007 implements ReaderInterface
$this->oPhpPresentation->setAllMasterSlides([]); $this->oPhpPresentation->setAllMasterSlides([]);
$this->filename = $pFilename; $this->filename = $pFilename;
$this->oZip = new ZipArchive(); $this->oZip = new \ZipArchive();
$this->oZip->open($this->filename); $this->oZip->open($this->filename);
$docPropsCore = $this->oZip->getFromName('docProps/core.xml'); $docPropsCore = $this->oZip->getFromName('docProps/core.xml');
if (false !== $docPropsCore) { if (false !== $docPropsCore) {
@ -187,7 +187,7 @@ class PowerPoint2007 implements ReaderInterface
/* @phpstan-ignore-next-line */ /* @phpstan-ignore-next-line */
if ($xmlReader->getDomFromString($sPart)) { if ($xmlReader->getDomFromString($sPart)) {
foreach ($xmlReader->getElements('/p:presentation/p:sldSz') as $oElement) { foreach ($xmlReader->getElements('/p:presentation/p:sldSz') as $oElement) {
if (!($oElement instanceof DOMElement)) { if (!($oElement instanceof \DOMElement)) {
continue; continue;
} }
$type = $oElement->getAttribute('type'); $type = $oElement->getAttribute('type');
@ -227,9 +227,9 @@ class PowerPoint2007 implements ReaderInterface
$oProperties = $this->oPhpPresentation->getDocumentProperties(); $oProperties = $this->oPhpPresentation->getDocumentProperties();
foreach ($arrayProperties as $path => $property) { foreach ($arrayProperties as $path => $property) {
$oElement = $xmlReader->getElement($path); $oElement = $xmlReader->getElement($path);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('xsi:type') && 'dcterms:W3CDTF' == $oElement->getAttribute('xsi:type')) { if ($oElement->hasAttribute('xsi:type') && 'dcterms:W3CDTF' == $oElement->getAttribute('xsi:type')) {
$dateTime = DateTime::createFromFormat(DateTime::W3C, $oElement->nodeValue); $dateTime = \DateTime::createFromFormat(\DateTime::W3C, $oElement->nodeValue);
$oProperties->{$property}($dateTime->getTimestamp()); $oProperties->{$property}($dateTime->getTimestamp());
} else { } else {
$oProperties->{$property}($oElement->nodeValue); $oProperties->{$property}($oElement->nodeValue);
@ -245,7 +245,7 @@ class PowerPoint2007 implements ReaderInterface
protected function loadCustomProperties(string $sPart): void protected function loadCustomProperties(string $sPart): void
{ {
$xmlReader = new XMLReader(); $xmlReader = new XMLReader();
$sPart = str_replace(' xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"', '', $sPart); $sPart = \str_replace(' xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties"', '', $sPart);
/* @phpstan-ignore-next-line */ /* @phpstan-ignore-next-line */
if ($xmlReader->getDomFromString($sPart)) { if ($xmlReader->getDomFromString($sPart)) {
foreach ($xmlReader->getElements('/Properties/property[@fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"]') as $element) { foreach ($xmlReader->getElements('/Properties/property[@fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"]') as $element) {
@ -276,7 +276,7 @@ class PowerPoint2007 implements ReaderInterface
$propertyValue = $attributeTypeBoolean->nodeValue == 'true' ? true : false; $propertyValue = $attributeTypeBoolean->nodeValue == 'true' ? true : false;
} elseif ($attributeTypeDate) { } elseif ($attributeTypeDate) {
$propertyType = DocumentProperties::PROPERTY_TYPE_DATE; $propertyType = DocumentProperties::PROPERTY_TYPE_DATE;
$propertyValue = strtotime($attributeTypeDate->nodeValue); $propertyValue = \strtotime($attributeTypeDate->nodeValue);
} else { } else {
$propertyType = DocumentProperties::PROPERTY_TYPE_STRING; $propertyType = DocumentProperties::PROPERTY_TYPE_STRING;
$propertyValue = $attributeTypeString->nodeValue; $propertyValue = $attributeTypeString->nodeValue;
@ -297,7 +297,7 @@ class PowerPoint2007 implements ReaderInterface
/* @phpstan-ignore-next-line */ /* @phpstan-ignore-next-line */
if ($xmlReader->getDomFromString($sPart)) { if ($xmlReader->getDomFromString($sPart)) {
$element = $xmlReader->getElement('/p:presentationPr/p:showPr'); $element = $xmlReader->getElement('/p:presentationPr/p:showPr');
if ($element instanceof DOMElement) { if ($element instanceof \DOMElement) {
if ($element->hasAttribute('loop')) { if ($element->hasAttribute('loop')) {
$this->oPhpPresentation->getPresentationProperties()->setLoopContinuouslyUntilEsc( $this->oPhpPresentation->getPresentationProperties()->setLoopContinuouslyUntilEsc(
(bool) $element->getAttribute('loop') (bool) $element->getAttribute('loop')
@ -332,7 +332,7 @@ class PowerPoint2007 implements ReaderInterface
if ($xmlReader->getDomFromString($sPart)) { if ($xmlReader->getDomFromString($sPart)) {
$pathZoom = '/p:viewPr/p:slideViewPr/p:cSldViewPr/p:cViewPr/p:scale/a:sx'; $pathZoom = '/p:viewPr/p:slideViewPr/p:cSldViewPr/p:cViewPr/p:scale/a:sx';
$oElement = $xmlReader->getElement($pathZoom); $oElement = $xmlReader->getElement($pathZoom);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('d') && $oElement->hasAttribute('n')) { if ($oElement->hasAttribute('d') && $oElement->hasAttribute('n')) {
$this->oPhpPresentation->getPresentationProperties()->setZoom($oElement->getAttribute('n') / $oElement->getAttribute('d')); $this->oPhpPresentation->getPresentationProperties()->setZoom($oElement->getAttribute('n') / $oElement->getAttribute('d'));
} }
@ -354,7 +354,7 @@ class PowerPoint2007 implements ReaderInterface
$this->loadMasterSlides($xmlReader, $fileRels); $this->loadMasterSlides($xmlReader, $fileRels);
// Continue with loading the slides // Continue with loading the slides
foreach ($xmlReader->getElements('/p:presentation/p:sldIdLst/p:sldId') as $oElement) { foreach ($xmlReader->getElements('/p:presentation/p:sldIdLst/p:sldId') as $oElement) {
if (!($oElement instanceof DOMElement)) { if (!($oElement instanceof \DOMElement)) {
continue; continue;
} }
$rId = $oElement->getAttribute('r:id'); $rId = $oElement->getAttribute('r:id');
@ -362,12 +362,12 @@ class PowerPoint2007 implements ReaderInterface
if (!empty($pathSlide)) { if (!empty($pathSlide)) {
$pptSlide = $this->oZip->getFromName('ppt/' . $pathSlide); $pptSlide = $this->oZip->getFromName('ppt/' . $pathSlide);
if (false !== $pptSlide) { if (false !== $pptSlide) {
$slideRels = 'ppt/slides/_rels/' . basename($pathSlide) . '.rels'; $slideRels = 'ppt/slides/_rels/' . \basename($pathSlide) . '.rels';
$this->loadRels($slideRels); $this->loadRels($slideRels);
$this->loadSlide($pptSlide, basename($pathSlide)); $this->loadSlide($pptSlide, \basename($pathSlide));
foreach ($this->arrayRels[$slideRels] as $rel) { foreach ($this->arrayRels[$slideRels] as $rel) {
if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide' == $rel['Type']) { if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide' == $rel['Type']) {
$this->loadSlideNote(basename($rel['Target']), $this->oPhpPresentation->getActiveSlide()); $this->loadSlideNote(\basename($rel['Target']), $this->oPhpPresentation->getActiveSlide());
} }
} }
} }
@ -383,7 +383,7 @@ class PowerPoint2007 implements ReaderInterface
{ {
// Get all the MasterSlide Id's from the presentation.xml file // Get all the MasterSlide Id's from the presentation.xml file
foreach ($xmlReader->getElements('/p:presentation/p:sldMasterIdLst/p:sldMasterId') as $oElement) { foreach ($xmlReader->getElements('/p:presentation/p:sldMasterIdLst/p:sldMasterId') as $oElement) {
if (!($oElement instanceof DOMElement)) { if (!($oElement instanceof \DOMElement)) {
continue; continue;
} }
$rId = $oElement->getAttribute('r:id'); $rId = $oElement->getAttribute('r:id');
@ -393,8 +393,8 @@ class PowerPoint2007 implements ReaderInterface
if (!empty($pathMasterSlide)) { if (!empty($pathMasterSlide)) {
$pptMasterSlide = $this->oZip->getFromName('ppt/' . $pathMasterSlide); $pptMasterSlide = $this->oZip->getFromName('ppt/' . $pathMasterSlide);
if (false !== $pptMasterSlide) { if (false !== $pptMasterSlide) {
$this->loadRels('ppt/slideMasters/_rels/' . basename($pathMasterSlide) . '.rels'); $this->loadRels('ppt/slideMasters/_rels/' . \basename($pathMasterSlide) . '.rels');
$this->loadMasterSlide($pptMasterSlide, basename($pathMasterSlide)); $this->loadMasterSlide($pptMasterSlide, \basename($pathMasterSlide));
} }
} }
} }
@ -415,9 +415,9 @@ class PowerPoint2007 implements ReaderInterface
// Background // Background
$oElement = $xmlReader->getElement('/p:sld/p:cSld/p:bg/p:bgPr'); $oElement = $xmlReader->getElement('/p:sld/p:cSld/p:bg/p:bgPr');
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
$oElementColor = $xmlReader->getElement('a:solidFill/a:srgbClr', $oElement); $oElementColor = $xmlReader->getElement('a:solidFill/a:srgbClr', $oElement);
if ($oElementColor instanceof DOMElement) { if ($oElementColor instanceof \DOMElement) {
// Color // Color
$oColor = new Color(); $oColor = new Color();
$oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null); $oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
@ -429,7 +429,7 @@ class PowerPoint2007 implements ReaderInterface
$oSlide->setBackground($oBackground); $oSlide->setBackground($oBackground);
} }
$oElementColor = $xmlReader->getElement('a:solidFill/a:schemeClr', $oElement); $oElementColor = $xmlReader->getElement('a:solidFill/a:schemeClr', $oElement);
if ($oElementColor instanceof DOMElement) { if ($oElementColor instanceof \DOMElement) {
// Color // Color
$oColor = new SchemeColor(); $oColor = new SchemeColor();
$oColor->setValue($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null); $oColor->setValue($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
@ -441,23 +441,23 @@ class PowerPoint2007 implements ReaderInterface
$oSlide->setBackground($oBackground); $oSlide->setBackground($oBackground);
} }
$oElementImage = $xmlReader->getElement('a:blipFill/a:blip', $oElement); $oElementImage = $xmlReader->getElement('a:blipFill/a:blip', $oElement);
if ($oElementImage instanceof DOMElement) { if ($oElementImage instanceof \DOMElement) {
$relImg = $this->arrayRels['ppt/slides/_rels/' . $baseFile . '.rels'][$oElementImage->getAttribute('r:embed')]; $relImg = $this->arrayRels['ppt/slides/_rels/' . $baseFile . '.rels'][$oElementImage->getAttribute('r:embed')];
if (is_array($relImg)) { if (\is_array($relImg)) {
// File // File
$pathImage = 'ppt/slides/' . $relImg['Target']; $pathImage = 'ppt/slides/' . $relImg['Target'];
$pathImage = explode('/', $pathImage); $pathImage = \explode('/', $pathImage);
foreach ($pathImage as $key => $partPath) { foreach ($pathImage as $key => $partPath) {
if ('..' == $partPath) { if ('..' == $partPath) {
unset($pathImage[$key - 1]); unset($pathImage[$key - 1]);
unset($pathImage[$key]); unset($pathImage[$key]);
} }
} }
$pathImage = implode('/', $pathImage); $pathImage = \implode('/', $pathImage);
$contentImg = $this->oZip->getFromName($pathImage); $contentImg = $this->oZip->getFromName($pathImage);
$tmpBkgImg = tempnam(sys_get_temp_dir(), 'PhpPresentationReaderPpt2007Bkg'); $tmpBkgImg = \tempnam(\sys_get_temp_dir(), 'PhpPresentationReaderPpt2007Bkg');
file_put_contents($tmpBkgImg, $contentImg); \file_put_contents($tmpBkgImg, $contentImg);
// Background // Background
$oBackground = new Slide\Background\Image(); $oBackground = new Slide\Background\Image();
$oBackground->setPath($tmpBkgImg); $oBackground->setPath($tmpBkgImg);
@ -476,8 +476,8 @@ class PowerPoint2007 implements ReaderInterface
$oSlide = $this->oPhpPresentation->getActiveSlide(); $oSlide = $this->oPhpPresentation->getActiveSlide();
foreach ($this->arrayRels['ppt/slides/_rels/' . $baseFile . '.rels'] as $valueRel) { foreach ($this->arrayRels['ppt/slides/_rels/' . $baseFile . '.rels'] as $valueRel) {
if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout' == $valueRel['Type']) { if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout' == $valueRel['Type']) {
$layoutBasename = basename($valueRel['Target']); $layoutBasename = \basename($valueRel['Target']);
if (array_key_exists($layoutBasename, $this->arraySlideLayouts)) { if (\array_key_exists($layoutBasename, $this->arraySlideLayouts)) {
$oSlide->setSlideLayout($this->arraySlideLayouts[$layoutBasename]); $oSlide->setSlideLayout($this->arraySlideLayouts[$layoutBasename]);
} }
break; break;
@ -498,7 +498,7 @@ class PowerPoint2007 implements ReaderInterface
// Background // Background
$oElement = $xmlReader->getElement('/p:sldMaster/p:cSld/p:bg'); $oElement = $xmlReader->getElement('/p:sldMaster/p:cSld/p:bg');
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
$this->loadSlideBackground($xmlReader, $oElement, $oSlideMaster); $this->loadSlideBackground($xmlReader, $oElement, $oSlideMaster);
} }
@ -523,7 +523,7 @@ class PowerPoint2007 implements ReaderInterface
foreach ($arrayElementTxStyles as $oElementTxStyle) { foreach ($arrayElementTxStyles as $oElementTxStyle) {
$arrayElementsLvl = $xmlReader->getElements('/p:sldMaster/p:txStyles/' . $oElementTxStyle->nodeName . '/*'); $arrayElementsLvl = $xmlReader->getElements('/p:sldMaster/p:txStyles/' . $oElementTxStyle->nodeName . '/*');
foreach ($arrayElementsLvl as $oElementLvl) { foreach ($arrayElementsLvl as $oElementLvl) {
if (!($oElementLvl instanceof DOMElement) || 'a:extLst' == $oElementLvl->nodeName) { if (!($oElementLvl instanceof \DOMElement) || 'a:extLst' == $oElementLvl->nodeName) {
continue; continue;
} }
$oRTParagraph = new Paragraph(); $oRTParagraph = new Paragraph();
@ -531,9 +531,9 @@ class PowerPoint2007 implements ReaderInterface
if ('a:defPPr' == $oElementLvl->nodeName) { if ('a:defPPr' == $oElementLvl->nodeName) {
$level = 0; $level = 0;
} else { } else {
$level = str_replace('a:lvl', '', $oElementLvl->nodeName); $level = \str_replace('a:lvl', '', $oElementLvl->nodeName);
$level = str_replace('pPr', '', $level); $level = \str_replace('pPr', '', $level);
$level = intval($level); $level = \intval($level);
} }
if ($oElementLvl->hasAttribute('algn')) { if ($oElementLvl->hasAttribute('algn')) {
@ -555,7 +555,7 @@ class PowerPoint2007 implements ReaderInterface
$oRTParagraph->getAlignment()->setIndent($val); $oRTParagraph->getAlignment()->setIndent($val);
} }
$oElementLvlDefRPR = $xmlReader->getElement('a:defRPr', $oElementLvl); $oElementLvlDefRPR = $xmlReader->getElement('a:defRPr', $oElementLvl);
if ($oElementLvlDefRPR instanceof DOMElement) { if ($oElementLvlDefRPR instanceof \DOMElement) {
if ($oElementLvlDefRPR->hasAttribute('sz')) { if ($oElementLvlDefRPR->hasAttribute('sz')) {
$oRTParagraph->getFont()->setSize($oElementLvlDefRPR->getAttribute('sz') / 100); $oRTParagraph->getFont()->setSize($oElementLvlDefRPR->getAttribute('sz') / 100);
} }
@ -567,7 +567,7 @@ class PowerPoint2007 implements ReaderInterface
} }
} }
$oElementSchemeColor = $xmlReader->getElement('a:defRPr/a:solidFill/a:schemeClr', $oElementLvl); $oElementSchemeColor = $xmlReader->getElement('a:defRPr/a:solidFill/a:schemeClr', $oElementLvl);
if ($oElementSchemeColor instanceof DOMElement) { if ($oElementSchemeColor instanceof \DOMElement) {
if ($oElementSchemeColor->hasAttribute('val')) { if ($oElementSchemeColor->hasAttribute('val')) {
$oSchemeColor = new SchemeColor(); $oSchemeColor = new SchemeColor();
$oSchemeColor->setValue($oElementSchemeColor->getAttribute('val')); $oSchemeColor->setValue($oElementSchemeColor->getAttribute('val'));
@ -592,7 +592,7 @@ class PowerPoint2007 implements ReaderInterface
// Load the theme // Load the theme
foreach ($this->arrayRels[$oSlideMaster->getRelsIndex()] as $arrayRel) { foreach ($this->arrayRels[$oSlideMaster->getRelsIndex()] as $arrayRel) {
if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme' == $arrayRel['Type']) { if ('http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme' == $arrayRel['Type']) {
$pptTheme = $this->oZip->getFromName('ppt/' . substr($arrayRel['Target'], strrpos($arrayRel['Target'], '../') + 3)); $pptTheme = $this->oZip->getFromName('ppt/' . \substr($arrayRel['Target'], \strrpos($arrayRel['Target'], '../') + 3));
if (false !== $pptTheme) { if (false !== $pptTheme) {
$this->loadTheme($pptTheme, $oSlideMaster); $this->loadTheme($pptTheme, $oSlideMaster);
} }
@ -602,7 +602,7 @@ class PowerPoint2007 implements ReaderInterface
// Load the Layoutslide // Load the Layoutslide
foreach ($xmlReader->getElements('/p:sldMaster/p:sldLayoutIdLst/p:sldLayoutId') as $oElement) { foreach ($xmlReader->getElements('/p:sldMaster/p:sldLayoutIdLst/p:sldLayoutId') as $oElement) {
if (!($oElement instanceof DOMElement)) { if (!($oElement instanceof \DOMElement)) {
continue; continue;
} }
$rId = $oElement->getAttribute('r:id'); $rId = $oElement->getAttribute('r:id');
@ -610,11 +610,11 @@ class PowerPoint2007 implements ReaderInterface
$pathLayoutSlide = isset($this->arrayRels[$oSlideMaster->getRelsIndex()][$rId]) ? $pathLayoutSlide = isset($this->arrayRels[$oSlideMaster->getRelsIndex()][$rId]) ?
$this->arrayRels[$oSlideMaster->getRelsIndex()][$rId]['Target'] : ''; $this->arrayRels[$oSlideMaster->getRelsIndex()][$rId]['Target'] : '';
if (!empty($pathLayoutSlide)) { if (!empty($pathLayoutSlide)) {
$pptLayoutSlide = $this->oZip->getFromName('ppt/' . substr($pathLayoutSlide, strrpos($pathLayoutSlide, '../') + 3)); $pptLayoutSlide = $this->oZip->getFromName('ppt/' . \substr($pathLayoutSlide, \strrpos($pathLayoutSlide, '../') + 3));
if (false !== $pptLayoutSlide) { if (false !== $pptLayoutSlide) {
$this->loadRels('ppt/slideLayouts/_rels/' . basename($pathLayoutSlide) . '.rels'); $this->loadRels('ppt/slideLayouts/_rels/' . \basename($pathLayoutSlide) . '.rels');
$oSlideMaster->addSlideLayout( $oSlideMaster->addSlideLayout(
$this->loadLayoutSlide($pptLayoutSlide, basename($pathLayoutSlide), $oSlideMaster) $this->loadLayoutSlide($pptLayoutSlide, \basename($pathLayoutSlide), $oSlideMaster)
); );
} }
} }
@ -633,19 +633,19 @@ class PowerPoint2007 implements ReaderInterface
// Name // Name
$oElement = $xmlReader->getElement('/p:sldLayout/p:cSld'); $oElement = $xmlReader->getElement('/p:sldLayout/p:cSld');
if ($oElement instanceof DOMElement && $oElement->hasAttribute('name')) { if ($oElement instanceof \DOMElement && $oElement->hasAttribute('name')) {
$oSlideLayout->setLayoutName($oElement->getAttribute('name')); $oSlideLayout->setLayoutName($oElement->getAttribute('name'));
} }
// Background // Background
$oElement = $xmlReader->getElement('/p:sldLayout/p:cSld/p:bg'); $oElement = $xmlReader->getElement('/p:sldLayout/p:cSld/p:bg');
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
$this->loadSlideBackground($xmlReader, $oElement, $oSlideLayout); $this->loadSlideBackground($xmlReader, $oElement, $oSlideLayout);
} }
// ColorMapping // ColorMapping
$oElement = $xmlReader->getElement('/p:sldLayout/p:clrMapOvr/a:overrideClrMapping'); $oElement = $xmlReader->getElement('/p:sldLayout/p:clrMapOvr/a:overrideClrMapping');
if ($oElement instanceof DOMElement && $oElement->hasAttributes()) { if ($oElement instanceof \DOMElement && $oElement->hasAttributes()) {
$colorMap = []; $colorMap = [];
foreach ($oElement->attributes as $attr) { foreach ($oElement->attributes as $attr) {
$colorMap[$attr->nodeName] = $attr->nodeValue; $colorMap[$attr->nodeName] = $attr->nodeValue;
@ -671,11 +671,11 @@ class PowerPoint2007 implements ReaderInterface
if ($xmlReader->getDomFromString($sPart)) { if ($xmlReader->getDomFromString($sPart)) {
$oElements = $xmlReader->getElements('/a:theme/a:themeElements/a:clrScheme/*'); $oElements = $xmlReader->getElements('/a:theme/a:themeElements/a:clrScheme/*');
foreach ($oElements as $oElement) { foreach ($oElements as $oElement) {
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
$oSchemeColor = new SchemeColor(); $oSchemeColor = new SchemeColor();
$oSchemeColor->setValue(str_replace('a:', '', $oElement->tagName)); $oSchemeColor->setValue(\str_replace('a:', '', $oElement->tagName));
$colorElement = $xmlReader->getElement('*', $oElement); $colorElement = $xmlReader->getElement('*', $oElement);
if ($colorElement instanceof DOMElement) { if ($colorElement instanceof \DOMElement) {
if ($colorElement->hasAttribute('lastClr')) { if ($colorElement->hasAttribute('lastClr')) {
$oSchemeColor->setRGB($colorElement->getAttribute('lastClr')); $oSchemeColor->setRGB($colorElement->getAttribute('lastClr'));
} elseif ($colorElement->hasAttribute('val')) { } elseif ($colorElement->hasAttribute('val')) {
@ -688,11 +688,11 @@ class PowerPoint2007 implements ReaderInterface
} }
} }
protected function loadSlideBackground(XMLReader $xmlReader, DOMElement $oElement, AbstractSlide $oSlide): void protected function loadSlideBackground(XMLReader $xmlReader, \DOMElement $oElement, AbstractSlide $oSlide): void
{ {
// Background color // Background color
$oElementColor = $xmlReader->getElement('p:bgPr/a:solidFill/a:srgbClr', $oElement); $oElementColor = $xmlReader->getElement('p:bgPr/a:solidFill/a:srgbClr', $oElement);
if ($oElementColor instanceof DOMElement) { if ($oElementColor instanceof \DOMElement) {
// Color // Color
$oColor = new Color(); $oColor = new Color();
$oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null); $oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
@ -705,7 +705,7 @@ class PowerPoint2007 implements ReaderInterface
// Background scheme color // Background scheme color
$oElementSchemeColor = $xmlReader->getElement('p:bgRef/a:schemeClr', $oElement); $oElementSchemeColor = $xmlReader->getElement('p:bgRef/a:schemeClr', $oElement);
if ($oElementSchemeColor instanceof DOMElement) { if ($oElementSchemeColor instanceof \DOMElement) {
// Color // Color
$oColor = new SchemeColor(); $oColor = new SchemeColor();
$oColor->setValue($oElementSchemeColor->hasAttribute('val') ? $oElementSchemeColor->getAttribute('val') : null); $oColor->setValue($oElementSchemeColor->hasAttribute('val') ? $oElementSchemeColor->getAttribute('val') : null);
@ -718,23 +718,23 @@ class PowerPoint2007 implements ReaderInterface
// Background image // Background image
$oElementImage = $xmlReader->getElement('p:bgPr/a:blipFill/a:blip', $oElement); $oElementImage = $xmlReader->getElement('p:bgPr/a:blipFill/a:blip', $oElement);
if ($oElementImage instanceof DOMElement) { if ($oElementImage instanceof \DOMElement) {
$relImg = $this->arrayRels[$oSlide->getRelsIndex()][$oElementImage->getAttribute('r:embed')]; $relImg = $this->arrayRels[$oSlide->getRelsIndex()][$oElementImage->getAttribute('r:embed')];
if (is_array($relImg)) { if (\is_array($relImg)) {
// File // File
$pathImage = 'ppt/slides/' . $relImg['Target']; $pathImage = 'ppt/slides/' . $relImg['Target'];
$pathImage = explode('/', $pathImage); $pathImage = \explode('/', $pathImage);
foreach ($pathImage as $key => $partPath) { foreach ($pathImage as $key => $partPath) {
if ('..' == $partPath) { if ('..' == $partPath) {
unset($pathImage[$key - 1]); unset($pathImage[$key - 1]);
unset($pathImage[$key]); unset($pathImage[$key]);
} }
} }
$pathImage = implode('/', $pathImage); $pathImage = \implode('/', $pathImage);
$contentImg = $this->oZip->getFromName($pathImage); $contentImg = $this->oZip->getFromName($pathImage);
$tmpBkgImg = tempnam(sys_get_temp_dir(), 'PhpPresentationReaderPpt2007Bkg'); $tmpBkgImg = \tempnam(\sys_get_temp_dir(), 'PhpPresentationReaderPpt2007Bkg');
file_put_contents($tmpBkgImg, $contentImg); \file_put_contents($tmpBkgImg, $contentImg);
// Background // Background
$oBackground = new Slide\Background\Image(); $oBackground = new Slide\Background\Image();
$oBackground->setPath($tmpBkgImg); $oBackground->setPath($tmpBkgImg);
@ -757,7 +757,7 @@ class PowerPoint2007 implements ReaderInterface
} }
} }
protected function loadShapeDrawing(XMLReader $document, DOMElement $node, AbstractSlide $oSlide): void protected function loadShapeDrawing(XMLReader $document, \DOMElement $node, AbstractSlide $oSlide): void
{ {
// Core // Core
$document->registerNamespace('asvg', 'http://schemas.microsoft.com/office/drawing/2016/SVG/main'); $document->registerNamespace('asvg', 'http://schemas.microsoft.com/office/drawing/2016/SVG/main');
@ -771,13 +771,13 @@ class PowerPoint2007 implements ReaderInterface
$fileRels = $oSlide->getRelsIndex(); $fileRels = $oSlide->getRelsIndex();
$oElement = $document->getElement('p:nvPicPr/p:cNvPr', $node); $oElement = $document->getElement('p:nvPicPr/p:cNvPr', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
$oShape->setName($oElement->hasAttribute('name') ? $oElement->getAttribute('name') : ''); $oShape->setName($oElement->hasAttribute('name') ? $oElement->getAttribute('name') : '');
$oShape->setDescription($oElement->hasAttribute('descr') ? $oElement->getAttribute('descr') : ''); $oShape->setDescription($oElement->hasAttribute('descr') ? $oElement->getAttribute('descr') : '');
// Hyperlink // Hyperlink
$oElementHlinkClick = $document->getElement('a:hlinkClick', $oElement); $oElementHlinkClick = $document->getElement('a:hlinkClick', $oElement);
if (is_object($oElementHlinkClick)) { if (\is_object($oElementHlinkClick)) {
$oShape->setHyperlink( $oShape->setHyperlink(
$this->loadHyperlink($document, $oElementHlinkClick, $oShape->getHyperlink()) $this->loadHyperlink($document, $oElementHlinkClick, $oShape->getHyperlink())
); );
@ -785,46 +785,46 @@ class PowerPoint2007 implements ReaderInterface
} }
$oElement = $document->getElement('p:blipFill/a:blip', $node); $oElement = $document->getElement('p:blipFill/a:blip', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('r:embed') && isset($this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')]['Target'])) { if ($oElement->hasAttribute('r:embed') && isset($this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')]['Target'])) {
$pathImage = 'ppt/slides/' . $this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')]['Target']; $pathImage = 'ppt/slides/' . $this->arrayRels[$fileRels][$oElement->getAttribute('r:embed')]['Target'];
$pathImage = explode('/', $pathImage); $pathImage = \explode('/', $pathImage);
foreach ($pathImage as $key => $partPath) { foreach ($pathImage as $key => $partPath) {
if ('..' == $partPath) { if ('..' == $partPath) {
unset($pathImage[$key - 1]); unset($pathImage[$key - 1]);
unset($pathImage[$key]); unset($pathImage[$key]);
} }
} }
$pathImage = implode('/', $pathImage); $pathImage = \implode('/', $pathImage);
$imageFile = $this->oZip->getFromName($pathImage); $imageFile = $this->oZip->getFromName($pathImage);
if (!empty($imageFile)) { if (!empty($imageFile)) {
if ($oShape instanceof Gd) { if ($oShape instanceof Gd) {
$info = getimagesizefromstring($imageFile); $info = \getimagesizefromstring($imageFile);
$oShape->setMimeType($info['mime']); $oShape->setMimeType($info['mime']);
$oShape->setRenderingFunction(str_replace('/', '', $info['mime'])); $oShape->setRenderingFunction(\str_replace('/', '', $info['mime']));
$oShape->setImageResource(imagecreatefromstring($imageFile)); $oShape->setImageResource(\imagecreatefromstring($imageFile));
} elseif ($oShape instanceof Base64) { } elseif ($oShape instanceof Base64) {
$oShape->setData('data:image/svg+xml;base64,' . base64_encode($imageFile)); $oShape->setData('data:image/svg+xml;base64,' . \base64_encode($imageFile));
} }
} }
} }
} }
$oElement = $document->getElement('p:spPr', $node); $oElement = $document->getElement('p:spPr', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
$oFill = $this->loadStyleFill($document, $oElement); $oFill = $this->loadStyleFill($document, $oElement);
$oShape->setFill($oFill); $oShape->setFill($oFill);
} }
$oElement = $document->getElement('p:spPr/a:xfrm', $node); $oElement = $document->getElement('p:spPr/a:xfrm', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('rot')) { if ($oElement->hasAttribute('rot')) {
$oShape->setRotation((int) CommonDrawing::angleToDegrees((int) $oElement->getAttribute('rot'))); $oShape->setRotation((int) CommonDrawing::angleToDegrees((int) $oElement->getAttribute('rot')));
} }
} }
$oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node); $oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('x')) { if ($oElement->hasAttribute('x')) {
$oShape->setOffsetX(CommonDrawing::emuToPixels((int) $oElement->getAttribute('x'))); $oShape->setOffsetX(CommonDrawing::emuToPixels((int) $oElement->getAttribute('x')));
} }
@ -834,7 +834,7 @@ class PowerPoint2007 implements ReaderInterface
} }
$oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node); $oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('cx')) { if ($oElement->hasAttribute('cx')) {
$oShape->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cx'))); $oShape->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cx')));
} }
@ -844,11 +844,11 @@ class PowerPoint2007 implements ReaderInterface
} }
$oElement = $document->getElement('p:spPr/a:effectLst', $node); $oElement = $document->getElement('p:spPr/a:effectLst', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
$oShape->getShadow()->setVisible(true); $oShape->getShadow()->setVisible(true);
$oSubElement = $document->getElement('a:outerShdw', $oElement); $oSubElement = $document->getElement('a:outerShdw', $oElement);
if ($oSubElement instanceof DOMElement) { if ($oSubElement instanceof \DOMElement) {
if ($oSubElement->hasAttribute('blurRad')) { if ($oSubElement->hasAttribute('blurRad')) {
$oShape->getShadow()->setBlurRadius(CommonDrawing::emuToPixels((int) $oSubElement->getAttribute('blurRad'))); $oShape->getShadow()->setBlurRadius(CommonDrawing::emuToPixels((int) $oSubElement->getAttribute('blurRad')));
} }
@ -864,7 +864,7 @@ class PowerPoint2007 implements ReaderInterface
} }
$oSubElement = $document->getElement('a:outerShdw/a:srgbClr', $oElement); $oSubElement = $document->getElement('a:outerShdw/a:srgbClr', $oElement);
if ($oSubElement instanceof DOMElement) { if ($oSubElement instanceof \DOMElement) {
if ($oSubElement->hasAttribute('val')) { if ($oSubElement->hasAttribute('val')) {
$oColor = new Color(); $oColor = new Color();
$oColor->setRGB($oSubElement->getAttribute('val')); $oColor->setRGB($oSubElement->getAttribute('val'));
@ -873,7 +873,7 @@ class PowerPoint2007 implements ReaderInterface
} }
$oSubElement = $document->getElement('a:outerShdw/a:srgbClr/a:alpha', $oElement); $oSubElement = $document->getElement('a:outerShdw/a:srgbClr/a:alpha', $oElement);
if ($oSubElement instanceof DOMElement) { if ($oSubElement instanceof \DOMElement) {
if ($oSubElement->hasAttribute('val')) { if ($oSubElement->hasAttribute('val')) {
$oShape->getShadow()->setAlpha((int) $oSubElement->getAttribute('val') / 1000); $oShape->getShadow()->setAlpha((int) $oSubElement->getAttribute('val') / 1000);
} }
@ -883,7 +883,7 @@ class PowerPoint2007 implements ReaderInterface
$oSlide->addShape($oShape); $oSlide->addShape($oShape);
} }
protected function loadShapeRichText(XMLReader $document, DOMElement $node, $oSlide): void protected function loadShapeRichText(XMLReader $document, \DOMElement $node, $oSlide): void
{ {
if (!$document->elementExists('p:txBody/a:p/a:r', $node) || !$oSlide instanceof AbstractSlide) { if (!$document->elementExists('p:txBody/a:p/a:r', $node) || !$oSlide instanceof AbstractSlide) {
return; return;
@ -897,12 +897,12 @@ class PowerPoint2007 implements ReaderInterface
} }
$oElement = $document->getElement('p:spPr/a:xfrm', $node); $oElement = $document->getElement('p:spPr/a:xfrm', $node);
if ($oElement instanceof DOMElement && $oElement->hasAttribute('rot')) { if ($oElement instanceof \DOMElement && $oElement->hasAttribute('rot')) {
$oShape->setRotation((int) CommonDrawing::angleToDegrees((int) $oElement->getAttribute('rot'))); $oShape->setRotation((int) CommonDrawing::angleToDegrees((int) $oElement->getAttribute('rot')));
} }
$oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node); $oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('x')) { if ($oElement->hasAttribute('x')) {
$oShape->setOffsetX(CommonDrawing::emuToPixels((int) $oElement->getAttribute('x'))); $oShape->setOffsetX(CommonDrawing::emuToPixels((int) $oElement->getAttribute('x')));
} }
@ -912,7 +912,7 @@ class PowerPoint2007 implements ReaderInterface
} }
$oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node); $oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('cx')) { if ($oElement->hasAttribute('cx')) {
$oShape->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cx'))); $oShape->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cx')));
} }
@ -922,7 +922,7 @@ class PowerPoint2007 implements ReaderInterface
} }
$oElement = $document->getElement('p:nvSpPr/p:nvPr/p:ph', $node); $oElement = $document->getElement('p:nvSpPr/p:nvPr/p:ph', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('type')) { if ($oElement->hasAttribute('type')) {
$placeholder = new Placeholder($oElement->getAttribute('type')); $placeholder = new Placeholder($oElement->getAttribute('type'));
$oShape->setPlaceHolder($placeholder); $oShape->setPlaceHolder($placeholder);
@ -931,24 +931,24 @@ class PowerPoint2007 implements ReaderInterface
$arrayElements = $document->getElements('p:txBody/a:p', $node); $arrayElements = $document->getElements('p:txBody/a:p', $node);
foreach ($arrayElements as $oElement) { foreach ($arrayElements as $oElement) {
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
$this->loadParagraph($document, $oElement, $oShape); $this->loadParagraph($document, $oElement, $oShape);
} }
} }
if (count($oShape->getParagraphs()) > 0) { if (\count($oShape->getParagraphs()) > 0) {
$oShape->setActiveParagraph(0); $oShape->setActiveParagraph(0);
} }
} }
protected function loadShapeTable(XMLReader $document, DOMElement $node, AbstractSlide $oSlide): void protected function loadShapeTable(XMLReader $document, \DOMElement $node, AbstractSlide $oSlide): void
{ {
$this->fileRels = $oSlide->getRelsIndex(); $this->fileRels = $oSlide->getRelsIndex();
$oShape = $oSlide->createTableShape(); $oShape = $oSlide->createTableShape();
$oElement = $document->getElement('p:cNvPr', $node); $oElement = $document->getElement('p:cNvPr', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('name')) { if ($oElement->hasAttribute('name')) {
$oShape->setName($oElement->getAttribute('name')); $oShape->setName($oElement->getAttribute('name'));
} }
@ -958,7 +958,7 @@ class PowerPoint2007 implements ReaderInterface
} }
$oElement = $document->getElement('p:xfrm/a:off', $node); $oElement = $document->getElement('p:xfrm/a:off', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('x')) { if ($oElement->hasAttribute('x')) {
$oShape->setOffsetX(CommonDrawing::emuToPixels((int) $oElement->getAttribute('x'))); $oShape->setOffsetX(CommonDrawing::emuToPixels((int) $oElement->getAttribute('x')));
} }
@ -968,7 +968,7 @@ class PowerPoint2007 implements ReaderInterface
} }
$oElement = $document->getElement('p:xfrm/a:ext', $node); $oElement = $document->getElement('p:xfrm/a:ext', $node);
if ($oElement instanceof DOMElement) { if ($oElement instanceof \DOMElement) {
if ($oElement->hasAttribute('cx')) { if ($oElement->hasAttribute('cx')) {
$oShape->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cx'))); $oShape->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cx')));
} }
@ -981,14 +981,14 @@ class PowerPoint2007 implements ReaderInterface
$oShape->setNumColumns($arrayElements->length); $oShape->setNumColumns($arrayElements->length);
$oShape->createRow(); $oShape->createRow();
foreach ($arrayElements as $key => $oElement) { foreach ($arrayElements as $key => $oElement) {
if ($oElement instanceof DOMElement && $oElement->getAttribute('w')) { if ($oElement instanceof \DOMElement && $oElement->getAttribute('w')) {
$oShape->getRow(0)->getCell($key)->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('w'))); $oShape->getRow(0)->getCell($key)->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('w')));
} }
} }
$arrayElements = $document->getElements('a:graphic/a:graphicData/a:tbl/a:tr', $node); $arrayElements = $document->getElements('a:graphic/a:graphicData/a:tbl/a:tr', $node);
foreach ($arrayElements as $keyRow => $oElementRow) { foreach ($arrayElements as $keyRow => $oElementRow) {
if (!($oElementRow instanceof DOMElement)) { if (!($oElementRow instanceof \DOMElement)) {
continue; continue;
} }
if ($oShape->hasRow($keyRow)) { if ($oShape->hasRow($keyRow)) {
@ -1001,7 +1001,7 @@ class PowerPoint2007 implements ReaderInterface
} }
$arrayElementsCell = $document->getElements('a:tc', $oElementRow); $arrayElementsCell = $document->getElements('a:tc', $oElementRow);
foreach ($arrayElementsCell as $keyCell => $oElementCell) { foreach ($arrayElementsCell as $keyCell => $oElementCell) {
if (!($oElementCell instanceof DOMElement)) { if (!($oElementCell instanceof \DOMElement)) {
continue; continue;
} }
$oCell = $oRow->getCell($keyCell); $oCell = $oRow->getCell($keyCell);
@ -1014,14 +1014,14 @@ class PowerPoint2007 implements ReaderInterface
} }
foreach ($document->getElements('a:txBody/a:p', $oElementCell) as $oElementPara) { foreach ($document->getElements('a:txBody/a:p', $oElementCell) as $oElementPara) {
if ($oElementPara instanceof DOMElement) { if ($oElementPara instanceof \DOMElement) {
$this->loadParagraph($document, $oElementPara, $oCell); $this->loadParagraph($document, $oElementPara, $oCell);
} }
} }
$oElementTcPr = $document->getElement('a:tcPr', $oElementCell); $oElementTcPr = $document->getElement('a:tcPr', $oElementCell);
if ($oElementTcPr instanceof DOMElement) { if ($oElementTcPr instanceof \DOMElement) {
$numParagraphs = count($oCell->getParagraphs()); $numParagraphs = \count($oCell->getParagraphs());
if ($numParagraphs > 0) { if ($numParagraphs > 0) {
if ($oElementTcPr->hasAttribute('vert')) { if ($oElementTcPr->hasAttribute('vert')) {
$oCell->getParagraph(0)->getAlignment()->setTextDirection($oElementTcPr->getAttribute('vert')); $oCell->getParagraph(0)->getAlignment()->setTextDirection($oElementTcPr->getAttribute('vert'));
@ -1050,27 +1050,27 @@ class PowerPoint2007 implements ReaderInterface
$oBorders = new Borders(); $oBorders = new Borders();
$oElementBorderL = $document->getElement('a:lnL', $oElementTcPr); $oElementBorderL = $document->getElement('a:lnL', $oElementTcPr);
if ($oElementBorderL instanceof DOMElement) { if ($oElementBorderL instanceof \DOMElement) {
$this->loadStyleBorder($document, $oElementBorderL, $oBorders->getLeft()); $this->loadStyleBorder($document, $oElementBorderL, $oBorders->getLeft());
} }
$oElementBorderR = $document->getElement('a:lnR', $oElementTcPr); $oElementBorderR = $document->getElement('a:lnR', $oElementTcPr);
if ($oElementBorderR instanceof DOMElement) { if ($oElementBorderR instanceof \DOMElement) {
$this->loadStyleBorder($document, $oElementBorderR, $oBorders->getRight()); $this->loadStyleBorder($document, $oElementBorderR, $oBorders->getRight());
} }
$oElementBorderT = $document->getElement('a:lnT', $oElementTcPr); $oElementBorderT = $document->getElement('a:lnT', $oElementTcPr);
if ($oElementBorderT instanceof DOMElement) { if ($oElementBorderT instanceof \DOMElement) {
$this->loadStyleBorder($document, $oElementBorderT, $oBorders->getTop()); $this->loadStyleBorder($document, $oElementBorderT, $oBorders->getTop());
} }
$oElementBorderB = $document->getElement('a:lnB', $oElementTcPr); $oElementBorderB = $document->getElement('a:lnB', $oElementTcPr);
if ($oElementBorderB instanceof DOMElement) { if ($oElementBorderB instanceof \DOMElement) {
$this->loadStyleBorder($document, $oElementBorderB, $oBorders->getBottom()); $this->loadStyleBorder($document, $oElementBorderB, $oBorders->getBottom());
} }
$oElementBorderDiagDown = $document->getElement('a:lnTlToBr', $oElementTcPr); $oElementBorderDiagDown = $document->getElement('a:lnTlToBr', $oElementTcPr);
if ($oElementBorderDiagDown instanceof DOMElement) { if ($oElementBorderDiagDown instanceof \DOMElement) {
$this->loadStyleBorder($document, $oElementBorderDiagDown, $oBorders->getDiagonalDown()); $this->loadStyleBorder($document, $oElementBorderDiagDown, $oBorders->getDiagonalDown());
} }
$oElementBorderDiagUp = $document->getElement('a:lnBlToTr', $oElementTcPr); $oElementBorderDiagUp = $document->getElement('a:lnBlToTr', $oElementTcPr);
if ($oElementBorderDiagUp instanceof DOMElement) { if ($oElementBorderDiagUp instanceof \DOMElement) {
$this->loadStyleBorder($document, $oElementBorderDiagUp, $oBorders->getDiagonalUp()); $this->loadStyleBorder($document, $oElementBorderDiagUp, $oBorders->getDiagonalUp());
} }
$oCell->setBorders($oBorders); $oCell->setBorders($oBorders);
@ -1082,14 +1082,14 @@ class PowerPoint2007 implements ReaderInterface
/** /**
* @param Cell|RichText $oShape * @param Cell|RichText $oShape
*/ */
protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oShape): void protected function loadParagraph(XMLReader $document, \DOMElement $oElement, $oShape): void
{ {
// Core // Core
$oParagraph = $oShape->createParagraph(); $oParagraph = $oShape->createParagraph();
$oParagraph->setRichTextElements([]); $oParagraph->setRichTextElements([]);
$oSubElement = $document->getElement('a:pPr', $oElement); $oSubElement = $document->getElement('a:pPr', $oElement);
if ($oSubElement instanceof DOMElement) { if ($oSubElement instanceof \DOMElement) {
if ($oSubElement->hasAttribute('algn')) { if ($oSubElement->hasAttribute('algn')) {
$oParagraph->getAlignment()->setHorizontal($oSubElement->getAttribute('algn')); $oParagraph->getAlignment()->setHorizontal($oSubElement->getAttribute('algn'));
} }
@ -1113,41 +1113,41 @@ class PowerPoint2007 implements ReaderInterface
} }
$oElementLineSpacingPoints = $document->getElement('a:lnSpc/a:spcPts', $oSubElement); $oElementLineSpacingPoints = $document->getElement('a:lnSpc/a:spcPts', $oSubElement);
if ($oElementLineSpacingPoints instanceof DOMElement) { if ($oElementLineSpacingPoints instanceof \DOMElement) {
$oParagraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_POINT); $oParagraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_POINT);
$oParagraph->setLineSpacing($oElementLineSpacingPoints->getAttribute('val') / 100); $oParagraph->setLineSpacing($oElementLineSpacingPoints->getAttribute('val') / 100);
} }
$oElementLineSpacingPercent = $document->getElement('a:lnSpc/a:spcPct', $oSubElement); $oElementLineSpacingPercent = $document->getElement('a:lnSpc/a:spcPct', $oSubElement);
if ($oElementLineSpacingPercent instanceof DOMElement) { if ($oElementLineSpacingPercent instanceof \DOMElement) {
$oParagraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_PERCENT); $oParagraph->setLineSpacingMode(Paragraph::LINE_SPACING_MODE_PERCENT);
$oParagraph->setLineSpacing($oElementLineSpacingPercent->getAttribute('val') / 1000); $oParagraph->setLineSpacing($oElementLineSpacingPercent->getAttribute('val') / 1000);
} }
$oElementSpacingBefore = $document->getElement('a:spcBef/a:spcPts', $oSubElement); $oElementSpacingBefore = $document->getElement('a:spcBef/a:spcPts', $oSubElement);
if ($oElementSpacingBefore instanceof DOMElement) { if ($oElementSpacingBefore instanceof \DOMElement) {
$oParagraph->setSpacingBefore($oElementSpacingBefore->getAttribute('val') / 100); $oParagraph->setSpacingBefore($oElementSpacingBefore->getAttribute('val') / 100);
} }
$oElementSpacingAfter = $document->getElement('a:spcAft/a:spcPts', $oSubElement); $oElementSpacingAfter = $document->getElement('a:spcAft/a:spcPts', $oSubElement);
if ($oElementSpacingAfter instanceof DOMElement) { if ($oElementSpacingAfter instanceof \DOMElement) {
$oParagraph->setSpacingAfter($oElementSpacingAfter->getAttribute('val') / 100); $oParagraph->setSpacingAfter($oElementSpacingAfter->getAttribute('val') / 100);
} }
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE); $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NONE);
$oElementBuFont = $document->getElement('a:buFont', $oSubElement); $oElementBuFont = $document->getElement('a:buFont', $oSubElement);
if ($oElementBuFont instanceof DOMElement) { if ($oElementBuFont instanceof \DOMElement) {
if ($oElementBuFont->hasAttribute('typeface')) { if ($oElementBuFont->hasAttribute('typeface')) {
$oParagraph->getBulletStyle()->setBulletFont($oElementBuFont->getAttribute('typeface')); $oParagraph->getBulletStyle()->setBulletFont($oElementBuFont->getAttribute('typeface'));
} }
} }
$oElementBuChar = $document->getElement('a:buChar', $oSubElement); $oElementBuChar = $document->getElement('a:buChar', $oSubElement);
if ($oElementBuChar instanceof DOMElement) { if ($oElementBuChar instanceof \DOMElement) {
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET); $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_BULLET);
if ($oElementBuChar->hasAttribute('char')) { if ($oElementBuChar->hasAttribute('char')) {
$oParagraph->getBulletStyle()->setBulletChar($oElementBuChar->getAttribute('char')); $oParagraph->getBulletStyle()->setBulletChar($oElementBuChar->getAttribute('char'));
} }
} }
$oElementBuAutoNum = $document->getElement('a:buAutoNum', $oSubElement); $oElementBuAutoNum = $document->getElement('a:buAutoNum', $oSubElement);
if ($oElementBuAutoNum instanceof DOMElement) { if ($oElementBuAutoNum instanceof \DOMElement) {
$oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NUMERIC); $oParagraph->getBulletStyle()->setBulletType(Bullet::TYPE_NUMERIC);
if ($oElementBuAutoNum->hasAttribute('type')) { if ($oElementBuAutoNum->hasAttribute('type')) {
$oParagraph->getBulletStyle()->setBulletNumericStyle($oElementBuAutoNum->getAttribute('type')); $oParagraph->getBulletStyle()->setBulletNumericStyle($oElementBuAutoNum->getAttribute('type'));
@ -1157,13 +1157,13 @@ class PowerPoint2007 implements ReaderInterface
} }
} }
$oElementBuClr = $document->getElement('a:buClr', $oSubElement); $oElementBuClr = $document->getElement('a:buClr', $oSubElement);
if ($oElementBuClr instanceof DOMElement) { if ($oElementBuClr instanceof \DOMElement) {
$oColor = new Color(); $oColor = new Color();
/** /**
* @todo Create protected for reading Color * @todo Create protected for reading Color
*/ */
$oElementColor = $document->getElement('a:srgbClr', $oElementBuClr); $oElementColor = $document->getElement('a:srgbClr', $oElementBuClr);
if ($oElementColor instanceof DOMElement) { if ($oElementColor instanceof \DOMElement) {
$oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null); $oColor->setRGB($oElementColor->hasAttribute('val') ? $oElementColor->getAttribute('val') : null);
} }
$oParagraph->getBulletStyle()->setBulletColor($oColor); $oParagraph->getBulletStyle()->setBulletColor($oColor);
@ -1171,7 +1171,7 @@ class PowerPoint2007 implements ReaderInterface
} }
$arraySubElements = $document->getElements('(a:r|a:br)', $oElement); $arraySubElements = $document->getElements('(a:r|a:br)', $oElement);
foreach ($arraySubElements as $oSubElement) { foreach ($arraySubElements as $oSubElement) {
if (!($oSubElement instanceof DOMElement)) { if (!($oSubElement instanceof \DOMElement)) {
continue; continue;
} }
if ('a:br' == $oSubElement->tagName) { if ('a:br' == $oSubElement->tagName) {
@ -1179,7 +1179,7 @@ class PowerPoint2007 implements ReaderInterface
} }
if ('a:r' == $oSubElement->tagName) { if ('a:r' == $oSubElement->tagName) {
$oElementrPr = $document->getElement('a:rPr', $oSubElement); $oElementrPr = $document->getElement('a:rPr', $oSubElement);
if (is_object($oElementrPr)) { if (\is_object($oElementrPr)) {
$oText = $oParagraph->createTextRun(); $oText = $oParagraph->createTextRun();
if ($oElementrPr->hasAttribute('b')) { if ($oElementrPr->hasAttribute('b')) {
@ -1201,14 +1201,14 @@ class PowerPoint2007 implements ReaderInterface
} }
// Color // Color
$oElementSrgbClr = $document->getElement('a:solidFill/a:srgbClr', $oElementrPr); $oElementSrgbClr = $document->getElement('a:solidFill/a:srgbClr', $oElementrPr);
if (is_object($oElementSrgbClr) && $oElementSrgbClr->hasAttribute('val')) { if (\is_object($oElementSrgbClr) && $oElementSrgbClr->hasAttribute('val')) {
$oColor = new Color(); $oColor = new Color();
$oColor->setRGB($oElementSrgbClr->getAttribute('val')); $oColor->setRGB($oElementSrgbClr->getAttribute('val'));
$oText->getFont()->setColor($oColor); $oText->getFont()->setColor($oColor);
} }
// Hyperlink // Hyperlink
$oElementHlinkClick = $document->getElement('a:hlinkClick', $oElementrPr); $oElementHlinkClick = $document->getElement('a:hlinkClick', $oElementrPr);
if (is_object($oElementHlinkClick)) { if (\is_object($oElementHlinkClick)) {
$oText->setHyperlink( $oText->setHyperlink(
$this->loadHyperlink($document, $oElementHlinkClick, $oText->getHyperlink()) $this->loadHyperlink($document, $oElementHlinkClick, $oText->getHyperlink())
); );
@ -1216,21 +1216,21 @@ class PowerPoint2007 implements ReaderInterface
// Font // Font
$oElementFontFormat = null; $oElementFontFormat = null;
$oElementFontFormatLatin = $document->getElement('a:latin', $oElementrPr); $oElementFontFormatLatin = $document->getElement('a:latin', $oElementrPr);
if (is_object($oElementFontFormatLatin)) { if (\is_object($oElementFontFormatLatin)) {
$oText->getFont()->setFormat(Font::FORMAT_LATIN); $oText->getFont()->setFormat(Font::FORMAT_LATIN);
$oElementFontFormat = $oElementFontFormatLatin; $oElementFontFormat = $oElementFontFormatLatin;
} }
$oElementFontFormatEastAsian = $document->getElement('a:ea', $oElementrPr); $oElementFontFormatEastAsian = $document->getElement('a:ea', $oElementrPr);
if (is_object($oElementFontFormatEastAsian)) { if (\is_object($oElementFontFormatEastAsian)) {
$oText->getFont()->setFormat(Font::FORMAT_EAST_ASIAN); $oText->getFont()->setFormat(Font::FORMAT_EAST_ASIAN);
$oElementFontFormat = $oElementFontFormatEastAsian; $oElementFontFormat = $oElementFontFormatEastAsian;
} }
$oElementFontFormatComplexScript = $document->getElement('a:cs', $oElementrPr); $oElementFontFormatComplexScript = $document->getElement('a:cs', $oElementrPr);
if (is_object($oElementFontFormatComplexScript)) { if (\is_object($oElementFontFormatComplexScript)) {
$oText->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT); $oText->getFont()->setFormat(Font::FORMAT_COMPLEX_SCRIPT);
$oElementFontFormat = $oElementFontFormatComplexScript; $oElementFontFormat = $oElementFontFormatComplexScript;
} }
if (is_object($oElementFontFormat) && $oElementFontFormat->hasAttribute('typeface')) { if (\is_object($oElementFontFormat) && $oElementFontFormat->hasAttribute('typeface')) {
$oText->getFont()->setName($oElementFontFormat->getAttribute('typeface')); $oText->getFont()->setName($oElementFontFormat->getAttribute('typeface'));
} }
@ -1244,7 +1244,7 @@ class PowerPoint2007 implements ReaderInterface
} }
} }
protected function loadHyperlink(XMLReader $xmlReader, DOMElement $element, Hyperlink $hyperlink): Hyperlink protected function loadHyperlink(XMLReader $xmlReader, \DOMElement $element, Hyperlink $hyperlink): Hyperlink
{ {
if ($element->hasAttribute('tooltip')) { if ($element->hasAttribute('tooltip')) {
$hyperlink->setTooltip($element->getAttribute('tooltip')); $hyperlink->setTooltip($element->getAttribute('tooltip'));
@ -1261,7 +1261,7 @@ class PowerPoint2007 implements ReaderInterface
return $hyperlink; return $hyperlink;
} }
protected function loadStyleBorder(XMLReader $xmlReader, DOMElement $oElement, Border $oBorder): void protected function loadStyleBorder(XMLReader $xmlReader, \DOMElement $oElement, Border $oBorder): void
{ {
if ($oElement->hasAttribute('w')) { if ($oElement->hasAttribute('w')) {
$oBorder->setLineWidth($oElement->getAttribute('w') / 12700); $oBorder->setLineWidth($oElement->getAttribute('w') / 12700);
@ -1271,54 +1271,54 @@ class PowerPoint2007 implements ReaderInterface
} }
$oElementNoFill = $xmlReader->getElement('a:noFill', $oElement); $oElementNoFill = $xmlReader->getElement('a:noFill', $oElement);
if ($oElementNoFill instanceof DOMElement && Border::LINE_SINGLE == $oBorder->getLineStyle()) { if ($oElementNoFill instanceof \DOMElement && Border::LINE_SINGLE == $oBorder->getLineStyle()) {
$oBorder->setLineStyle(Border::LINE_NONE); $oBorder->setLineStyle(Border::LINE_NONE);
} }
$oElementColor = $xmlReader->getElement('a:solidFill/a:srgbClr', $oElement); $oElementColor = $xmlReader->getElement('a:solidFill/a:srgbClr', $oElement);
if ($oElementColor instanceof DOMElement) { if ($oElementColor instanceof \DOMElement) {
$oBorder->setColor($this->loadStyleColor($xmlReader, $oElementColor)); $oBorder->setColor($this->loadStyleColor($xmlReader, $oElementColor));
} }
$oElementDashStyle = $xmlReader->getElement('a:prstDash', $oElement); $oElementDashStyle = $xmlReader->getElement('a:prstDash', $oElement);
if ($oElementDashStyle instanceof DOMElement && $oElementDashStyle->hasAttribute('val')) { if ($oElementDashStyle instanceof \DOMElement && $oElementDashStyle->hasAttribute('val')) {
$oBorder->setDashStyle($oElementDashStyle->getAttribute('val')); $oBorder->setDashStyle($oElementDashStyle->getAttribute('val'));
} }
} }
protected function loadStyleColor(XMLReader $xmlReader, DOMElement $oElement): Color protected function loadStyleColor(XMLReader $xmlReader, \DOMElement $oElement): Color
{ {
$oColor = new Color(); $oColor = new Color();
$oColor->setRGB($oElement->getAttribute('val')); $oColor->setRGB($oElement->getAttribute('val'));
$oElementAlpha = $xmlReader->getElement('a:alpha', $oElement); $oElementAlpha = $xmlReader->getElement('a:alpha', $oElement);
if ($oElementAlpha instanceof DOMElement && $oElementAlpha->hasAttribute('val')) { if ($oElementAlpha instanceof \DOMElement && $oElementAlpha->hasAttribute('val')) {
$alpha = strtoupper(dechex((($oElementAlpha->getAttribute('val') / 1000) / 100) * 255)); $alpha = \strtoupper(\dechex((($oElementAlpha->getAttribute('val') / 1000) / 100) * 255));
$oColor->setRGB($oElement->getAttribute('val'), $alpha); $oColor->setRGB($oElement->getAttribute('val'), $alpha);
} }
return $oColor; return $oColor;
} }
protected function loadStyleFill(XMLReader $xmlReader, DOMElement $oElement): ?Fill protected function loadStyleFill(XMLReader $xmlReader, \DOMElement $oElement): ?Fill
{ {
// Gradient fill // Gradient fill
$oElementFill = $xmlReader->getElement('a:gradFill', $oElement); $oElementFill = $xmlReader->getElement('a:gradFill', $oElement);
if ($oElementFill instanceof DOMElement) { if ($oElementFill instanceof \DOMElement) {
$oFill = new Fill(); $oFill = new Fill();
$oFill->setFillType(Fill::FILL_GRADIENT_LINEAR); $oFill->setFillType(Fill::FILL_GRADIENT_LINEAR);
$oElementColor = $xmlReader->getElement('a:gsLst/a:gs[@pos="0"]/a:srgbClr', $oElementFill); $oElementColor = $xmlReader->getElement('a:gsLst/a:gs[@pos="0"]/a:srgbClr', $oElementFill);
if ($oElementColor instanceof DOMElement && $oElementColor->hasAttribute('val')) { if ($oElementColor instanceof \DOMElement && $oElementColor->hasAttribute('val')) {
$oFill->setStartColor($this->loadStyleColor($xmlReader, $oElementColor)); $oFill->setStartColor($this->loadStyleColor($xmlReader, $oElementColor));
} }
$oElementColor = $xmlReader->getElement('a:gsLst/a:gs[@pos="100000"]/a:srgbClr', $oElementFill); $oElementColor = $xmlReader->getElement('a:gsLst/a:gs[@pos="100000"]/a:srgbClr', $oElementFill);
if ($oElementColor instanceof DOMElement && $oElementColor->hasAttribute('val')) { if ($oElementColor instanceof \DOMElement && $oElementColor->hasAttribute('val')) {
$oFill->setEndColor($this->loadStyleColor($xmlReader, $oElementColor)); $oFill->setEndColor($this->loadStyleColor($xmlReader, $oElementColor));
} }
$oRotation = $xmlReader->getElement('a:lin', $oElementFill); $oRotation = $xmlReader->getElement('a:lin', $oElementFill);
if ($oRotation instanceof DOMElement && $oRotation->hasAttribute('ang')) { if ($oRotation instanceof \DOMElement && $oRotation->hasAttribute('ang')) {
$oFill->setRotation(CommonDrawing::angleToDegrees((int) $oRotation->getAttribute('ang'))); $oFill->setRotation(CommonDrawing::angleToDegrees((int) $oRotation->getAttribute('ang')));
} }
@ -1327,12 +1327,12 @@ class PowerPoint2007 implements ReaderInterface
// Solid fill // Solid fill
$oElementFill = $xmlReader->getElement('a:solidFill', $oElement); $oElementFill = $xmlReader->getElement('a:solidFill', $oElement);
if ($oElementFill instanceof DOMElement) { if ($oElementFill instanceof \DOMElement) {
$oFill = new Fill(); $oFill = new Fill();
$oFill->setFillType(Fill::FILL_SOLID); $oFill->setFillType(Fill::FILL_SOLID);
$oElementColor = $xmlReader->getElement('a:srgbClr', $oElementFill); $oElementColor = $xmlReader->getElement('a:srgbClr', $oElementFill);
if ($oElementColor instanceof DOMElement) { if ($oElementColor instanceof \DOMElement) {
$oFill->setStartColor($this->loadStyleColor($xmlReader, $oElementColor)); $oFill->setStartColor($this->loadStyleColor($xmlReader, $oElementColor));
} }
@ -1350,7 +1350,7 @@ class PowerPoint2007 implements ReaderInterface
/* @phpstan-ignore-next-line */ /* @phpstan-ignore-next-line */
if ($xmlReader->getDomFromString($sPart)) { if ($xmlReader->getDomFromString($sPart)) {
foreach ($xmlReader->getElements('*') as $oNode) { foreach ($xmlReader->getElements('*') as $oNode) {
if (!($oNode instanceof DOMElement)) { if (!($oNode instanceof \DOMElement)) {
continue; continue;
} }
$this->arrayRels[$fileRels][$oNode->getAttribute('Id')] = [ $this->arrayRels[$fileRels][$oNode->getAttribute('Id')] = [
@ -1364,16 +1364,16 @@ class PowerPoint2007 implements ReaderInterface
/** /**
* @param AbstractSlide|Note $oSlide * @param AbstractSlide|Note $oSlide
* @param DOMNodeList<DOMNode> $oElements * @param \DOMNodeList<\DOMNode> $oElements
* *
* @throws FeatureNotImplementedException * @throws FeatureNotImplementedException
* *
* @internal param $baseFile * @internal param $baseFile
*/ */
protected function loadSlideShapes($oSlide, DOMNodeList $oElements, XMLReader $xmlReader): void protected function loadSlideShapes($oSlide, \DOMNodeList $oElements, XMLReader $xmlReader): void
{ {
foreach ($oElements as $oNode) { foreach ($oElements as $oNode) {
if (!($oNode instanceof DOMElement)) { if (!($oNode instanceof \DOMElement)) {
continue; continue;
} }
switch ($oNode->tagName) { switch ($oNode->tagName) {

View File

@ -397,7 +397,7 @@ class PowerPoint97 implements ReaderInterface
public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool public function fileSupportsUnserializePhpPresentation(string $pFilename = ''): bool
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!\file_exists($pFilename)) {
throw new FileNotFoundException($pFilename); throw new FileNotFoundException($pFilename);
} }
@ -408,7 +408,7 @@ class PowerPoint97 implements ReaderInterface
$ole->read($pFilename); $ole->read($pFilename);
return true; return true;
} catch (Exception $e) { } catch (\Exception $e) {
return false; return false;
} }
} }
@ -652,8 +652,8 @@ class PowerPoint97 implements ReaderInterface
$recLen = self::getInt4d($stream, $pos + 4); $recLen = self::getInt4d($stream, $pos + 4);
return [ return [
'recVer' => ($rec >> 0) & bindec('1111'), 'recVer' => ($rec >> 0) & \bindec('1111'),
'recInstance' => ($rec >> 4) & bindec('111111111111'), 'recInstance' => ($rec >> 4) & \bindec('111111111111'),
'recType' => $recType, 'recType' => $recType,
'recLen' => $recLen, 'recLen' => $recLen,
]; ];
@ -664,7 +664,7 @@ class PowerPoint97 implements ReaderInterface
*/ */
public static function getInt1d(string $data, int $pos): int public static function getInt1d(string $data, int $pos): int
{ {
return ord($data[$pos]); return \ord($data[$pos]);
} }
/** /**
@ -672,7 +672,7 @@ class PowerPoint97 implements ReaderInterface
*/ */
public static function getInt2d(string $data, int $pos): int public static function getInt2d(string $data, int $pos): int
{ {
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8); return \ord($data[$pos]) | (\ord($data[$pos + 1]) << 8);
} }
/** /**
@ -683,15 +683,15 @@ class PowerPoint97 implements ReaderInterface
// FIX: represent numbers correctly on 64-bit system // FIX: represent numbers correctly on 64-bit system
// http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334 // http://sourceforge.net/tracker/index.php?func=detail&aid=1487372&group_id=99160&atid=623334
// Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems // Hacked by Andreas Rehm 2006 to ensure correct result of the <<24 block on 32 and 64bit systems
$or24 = ord($data[$pos + 3]); $or24 = \ord($data[$pos + 3]);
$ord24 = ($or24 & 127) << 24; $ord24 = ($or24 & 127) << 24;
if ($or24 >= 128) { if ($or24 >= 128) {
// negative number // negative number
$ord24 = -abs((256 - $or24) << 24); $ord24 = -\abs((256 - $or24) << 24);
} }
return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $ord24; return \ord($data[$pos]) | (\ord($data[$pos + 1]) << 8) | (\ord($data[$pos + 2]) << 16) | $ord24;
} }
/** /**
@ -781,7 +781,7 @@ class PowerPoint97 implements ReaderInterface
$char = self::getInt2d($stream, $pos); $char = self::getInt2d($stream, $pos);
$pos += 2; $pos += 2;
$exObjList['recLen'] -= 2; $exObjList['recLen'] -= 2;
$this->arrayHyperlinks[$exHyperlinkId]['text'] .= chr($char); $this->arrayHyperlinks[$exHyperlinkId]['text'] .= \chr($char);
} }
} }
// targetAtom // targetAtom
@ -794,7 +794,7 @@ class PowerPoint97 implements ReaderInterface
$char = self::getInt2d($stream, $pos); $char = self::getInt2d($stream, $pos);
$pos += 2; $pos += 2;
$exObjList['recLen'] -= 2; $exObjList['recLen'] -= 2;
$this->arrayHyperlinks[$exHyperlinkId]['url'] .= chr($char); $this->arrayHyperlinks[$exHyperlinkId]['url'] .= \chr($char);
} }
} }
// locationAtom // locationAtom
@ -807,7 +807,7 @@ class PowerPoint97 implements ReaderInterface
$char = self::getInt2d($stream, $pos); $char = self::getInt2d($stream, $pos);
$pos += 2; $pos += 2;
$exObjList['recLen'] -= 2; $exObjList['recLen'] -= 2;
$string .= chr($char); $string .= \chr($char);
} }
} }
break; break;
@ -845,7 +845,7 @@ class PowerPoint97 implements ReaderInterface
$char = self::getInt2d($stream, $pos); $char = self::getInt2d($stream, $pos);
$pos += 2; $pos += 2;
$fontCollection['recLen'] -= 2; $fontCollection['recLen'] -= 2;
$string .= chr($char); $string .= \chr($char);
} }
$this->arrayFonts[] = $string; $this->arrayFonts[] = $string;
@ -1238,7 +1238,7 @@ class PowerPoint97 implements ReaderInterface
++$arrayReturn['length']; ++$arrayReturn['length'];
--$data['recLen']; --$data['recLen'];
// BLIPFileData // BLIPFileData
$arrayReturn['picture'] = substr($this->streamPictures, $pos + $arrayReturn['length'], $data['recLen']); $arrayReturn['picture'] = \substr($this->streamPictures, $pos + $arrayReturn['length'], $data['recLen']);
$arrayReturn['length'] += $data['recLen']; $arrayReturn['length'] += $data['recLen'];
break; break;
default: default:
@ -1431,10 +1431,10 @@ class PowerPoint97 implements ReaderInterface
//@link : http://msdn.microsoft.com/en-us/library/dd947973(v=office.12).aspx //@link : http://msdn.microsoft.com/en-us/library/dd947973(v=office.12).aspx
if (0x0000 == $rhChild['recInstance']) { if (0x0000 == $rhChild['recInstance']) {
//@todo : MouseClickTextInteractiveInfoAtom //@todo : MouseClickTextInteractiveInfoAtom
$arrayReturn['hyperlink'][count($arrayReturn['hyperlink']) - 1]['start'] = self::getInt4d($stream, $pos + +$arrayReturn['length']); $arrayReturn['hyperlink'][\count($arrayReturn['hyperlink']) - 1]['start'] = self::getInt4d($stream, $pos + +$arrayReturn['length']);
$arrayReturn['length'] += 4; $arrayReturn['length'] += 4;
$arrayReturn['hyperlink'][count($arrayReturn['hyperlink']) - 1]['end'] = self::getInt4d($stream, $pos + +$arrayReturn['length']); $arrayReturn['hyperlink'][\count($arrayReturn['hyperlink']) - 1]['end'] = self::getInt4d($stream, $pos + +$arrayReturn['length']);
$arrayReturn['length'] += 4; $arrayReturn['length'] += 4;
} }
if (0x0001 == $rhChild['recInstance']) { if (0x0001 == $rhChild['recInstance']) {
@ -1552,7 +1552,7 @@ class PowerPoint97 implements ReaderInterface
// Informations about group are not defined // Informations about group are not defined
$arrayDimensions = []; $arrayDimensions = [];
$bIsGroup = false; $bIsGroup = false;
if (is_object($this->oCurrentGroup)) { if (\is_object($this->oCurrentGroup)) {
if (!$this->bFirstShapeGroup) { if (!$this->bFirstShapeGroup) {
if ($clientAnchor['length'] > 0) { if ($clientAnchor['length'] > 0) {
// $this->oCurrentGroup->setOffsetX($clientAnchor['left']); // $this->oCurrentGroup->setOffsetX($clientAnchor['left']);
@ -1578,7 +1578,7 @@ class PowerPoint97 implements ReaderInterface
// isDrawing // isDrawing
$drawingPib = $shpPrimaryOptions['pib']; $drawingPib = $shpPrimaryOptions['pib'];
if (isset($this->arrayPictures[$drawingPib - 1])) { if (isset($this->arrayPictures[$drawingPib - 1])) {
$gdImage = imagecreatefromstring($this->arrayPictures[$drawingPib - 1]); $gdImage = \imagecreatefromstring($this->arrayPictures[$drawingPib - 1]);
$arrayReturn['shape'] = new Drawing\Gd(); $arrayReturn['shape'] = new Drawing\Gd();
$arrayReturn['shape']->setImageResource($gdImage); $arrayReturn['shape']->setImageResource($gdImage);
} }
@ -1621,7 +1621,7 @@ class PowerPoint97 implements ReaderInterface
} }
} }
// Texte // Texte
$sText = substr(isset($clientTextbox['text']) ? $clientTextbox['text'] : '', $start, $clientTextbox['part' . $inc]['partLength']); $sText = \substr(isset($clientTextbox['text']) ? $clientTextbox['text'] : '', $start, $clientTextbox['part' . $inc]['partLength']);
$sHyperlinkURL = ''; $sHyperlinkURL = '';
if (empty($sText)) { if (empty($sText)) {
// Is there a hyperlink ? // Is there a hyperlink ?
@ -1637,9 +1637,9 @@ class PowerPoint97 implements ReaderInterface
} }
// New paragraph // New paragraph
$bCreateParagraph = false; $bCreateParagraph = false;
if (false !== strpos($sText, "\r")) { if (false !== \strpos($sText, "\r")) {
$bCreateParagraph = true; $bCreateParagraph = true;
$sText = str_replace("\r", '', $sText); $sText = \str_replace("\r", '', $sText);
} }
// TextRun // TextRun
$txtRun = $arrayReturn['shape']->createTextRun($sText); $txtRun = $arrayReturn['shape']->createTextRun($sText);
@ -1787,10 +1787,10 @@ class PowerPoint97 implements ReaderInterface
$data['recLen'] -= $fileBlock['length']; $data['recLen'] -= $fileBlock['length'];
// Core // Core
//@todo //@todo
if (!is_null($fileBlock['shape'])) { if (!\is_null($fileBlock['shape'])) {
switch ($this->inMainType) { switch ($this->inMainType) {
case self::RT_NOTES: case self::RT_NOTES:
$arrayIdxSlide = array_flip($this->arrayNotes); $arrayIdxSlide = \array_flip($this->arrayNotes);
if ($this->currentNote > 0 && isset($arrayIdxSlide[$this->currentNote])) { if ($this->currentNote > 0 && isset($arrayIdxSlide[$this->currentNote])) {
$oSlide = $this->oPhpPresentation->getSlide($arrayIdxSlide[$this->currentNote]); $oSlide = $this->oPhpPresentation->getSlide($arrayIdxSlide[$this->currentNote]);
if (0 == $oSlide->getNote()->getShapeCollection()->count()) { if (0 == $oSlide->getNote()->getShapeCollection()->count()) {
@ -1843,9 +1843,9 @@ class PowerPoint97 implements ReaderInterface
$optOp = self::getInt4d($this->streamPowerpointDocument, $pos + $arrayReturn['length']); $optOp = self::getInt4d($this->streamPowerpointDocument, $pos + $arrayReturn['length']);
$arrayReturn['length'] += 4; $arrayReturn['length'] += 4;
$officeArtFOPTE[] = [ $officeArtFOPTE[] = [
'opid' => ($opid >> 0) & bindec('11111111111111'), 'opid' => ($opid >> 0) & \bindec('11111111111111'),
'fBid' => ($opid >> 14) & bindec('1'), 'fBid' => ($opid >> 14) & \bindec('1'),
'fComplex' => ($opid >> 15) & bindec('1'), 'fComplex' => ($opid >> 15) & \bindec('1'),
'op' => $optOp, 'op' => $optOp,
]; ];
} }
@ -1975,9 +1975,9 @@ class PowerPoint97 implements ReaderInterface
$arrayReturn['length'] += 4; $arrayReturn['length'] += 4;
$data['recLen'] -= 4; $data['recLen'] -= 4;
$officeArtFOPTE[] = [ $officeArtFOPTE[] = [
'opid' => ($opid >> 0) & bindec('11111111111111'), 'opid' => ($opid >> 0) & \bindec('11111111111111'),
'fBid' => ($opid >> 14) & bindec('1'), 'fBid' => ($opid >> 14) & \bindec('1'),
'fComplex' => ($opid >> 15) & bindec('1'), 'fComplex' => ($opid >> 15) & \bindec('1'),
'op' => $optOp, 'op' => $optOp,
]; ];
} }
@ -2120,17 +2120,17 @@ class PowerPoint97 implements ReaderInterface
case 0x0181: case 0x0181:
// Fill : fillColor // Fill : fillColor
//@link : http://msdn.microsoft.com/en-us/library/dd921332(v=office.12).aspx //@link : http://msdn.microsoft.com/en-us/library/dd921332(v=office.12).aspx
$strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, '0', STR_PAD_LEFT); $strColor = \str_pad(\dechex(($opt['op'] >> 0) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, '0', STR_PAD_LEFT); $strColor .= \str_pad(\dechex(($opt['op'] >> 8) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex(($opt['op'] >> 16) & bindec('11111111')), 2, '0', STR_PAD_LEFT); $strColor .= \str_pad(\dechex(($opt['op'] >> 16) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
// echo 'fillColor : '.$strColor.EOL; // echo 'fillColor : '.$strColor.EOL;
break; break;
case 0x0183: case 0x0183:
// Fill : fillBackColor // Fill : fillBackColor
//@link : http://msdn.microsoft.com/en-us/library/dd950634(v=office.12).aspx //@link : http://msdn.microsoft.com/en-us/library/dd950634(v=office.12).aspx
$strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, '0', STR_PAD_LEFT); $strColor = \str_pad(\dechex(($opt['op'] >> 0) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, '0', STR_PAD_LEFT); $strColor .= \str_pad(\dechex(($opt['op'] >> 8) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex(($opt['op'] >> 16) & bindec('11111111')), 2, '0', STR_PAD_LEFT); $strColor .= \str_pad(\dechex(($opt['op'] >> 16) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
// echo 'fillBackColor : '.$strColor.EOL; // echo 'fillBackColor : '.$strColor.EOL;
break; break;
case 0x0193: case 0x0193:
@ -2150,9 +2150,9 @@ class PowerPoint97 implements ReaderInterface
case 0x01C0: case 0x01C0:
// Line Style : lineColor // Line Style : lineColor
//@link : http://msdn.microsoft.com/en-us/library/dd920397(v=office.12).aspx //@link : http://msdn.microsoft.com/en-us/library/dd920397(v=office.12).aspx
$strColor = str_pad(dechex(($opt['op'] >> 0) & bindec('11111111')), 2, '0', STR_PAD_LEFT); $strColor = \str_pad(\dechex(($opt['op'] >> 0) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex(($opt['op'] >> 8) & bindec('11111111')), 2, '0', STR_PAD_LEFT); $strColor .= \str_pad(\dechex(($opt['op'] >> 8) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex(($opt['op'] >> 16) & bindec('11111111')), 2, '0', STR_PAD_LEFT); $strColor .= \str_pad(\dechex(($opt['op'] >> 16) & \bindec('11111111')), 2, '0', STR_PAD_LEFT);
$arrayReturn['lineColor'] = $strColor; $arrayReturn['lineColor'] = $strColor;
break; break;
case 0x01C1: case 0x01C1:
@ -2277,10 +2277,10 @@ class PowerPoint97 implements ReaderInterface
// data // data
$data = self::getInt4d($this->streamPowerpointDocument, $pos + $arrayReturn['length']); $data = self::getInt4d($this->streamPowerpointDocument, $pos + $arrayReturn['length']);
$arrayReturn['length'] += 4; $arrayReturn['length'] += 4;
$arrayReturn['fGroup'] = ($data >> 0) & bindec('1'); $arrayReturn['fGroup'] = ($data >> 0) & \bindec('1');
$arrayReturn['fChild'] = ($data >> 1) & bindec('1'); $arrayReturn['fChild'] = ($data >> 1) & \bindec('1');
$arrayReturn['fPatriarch'] = ($data >> 2) & bindec('1'); $arrayReturn['fPatriarch'] = ($data >> 2) & \bindec('1');
$arrayReturn['fDeleted'] = ($data >> 3) & bindec('1'); $arrayReturn['fDeleted'] = ($data >> 3) & \bindec('1');
} }
return $arrayReturn; return $arrayReturn;
@ -2399,7 +2399,7 @@ class PowerPoint97 implements ReaderInterface
]; ];
do { do {
$dataHeaderRG = $this->loadRecordHeader($stream, $pos + $arrayReturn['length']); $dataHeaderRG = $this->loadRecordHeader($stream, $pos + $arrayReturn['length']);
if (in_array($dataHeaderRG['recType'], $array)) { if (\in_array($dataHeaderRG['recType'], $array)) {
switch ($dataHeaderRG['recType']) { switch ($dataHeaderRG['recType']) {
case self::RT_PROGTAGS: case self::RT_PROGTAGS:
$dataRG = $this->readRecordShapeProgTagsContainer($stream, $pos + $arrayReturn['length']); $dataRG = $this->readRecordShapeProgTagsContainer($stream, $pos + $arrayReturn['length']);
@ -2418,7 +2418,7 @@ class PowerPoint97 implements ReaderInterface
throw new FeatureNotImplementedException(); throw new FeatureNotImplementedException();
} }
} }
} while (in_array($dataHeaderRG['recType'], $array)); } while (\in_array($dataHeaderRG['recType'], $array));
} }
return $arrayReturn; return $arrayReturn;
@ -2445,7 +2445,7 @@ class PowerPoint97 implements ReaderInterface
$pos += 4; $pos += 4;
$rHeader['recLen'] -= 4; $rHeader['recLen'] -= 4;
//$persistId = ($data >> 0) & bindec('11111111111111111111'); //$persistId = ($data >> 0) & bindec('11111111111111111111');
$cPersist = ($data >> 20) & bindec('111111111111'); $cPersist = ($data >> 20) & \bindec('111111111111');
$rgPersistOffset = []; $rgPersistOffset = [];
for ($inc = 0; $inc < $cPersist; ++$inc) { for ($inc = 0; $inc < $cPersist; ++$inc) {
@ -3023,46 +3023,46 @@ class PowerPoint97 implements ReaderInterface
$arrayReturn['length'] += 4; $arrayReturn['length'] += 4;
$masksData = []; $masksData = [];
$masksData['bold'] = ($masks >> 0) & bindec('1'); $masksData['bold'] = ($masks >> 0) & \bindec('1');
$masksData['italic'] = ($masks >> 1) & bindec('1'); $masksData['italic'] = ($masks >> 1) & \bindec('1');
$masksData['underline'] = ($masks >> 2) & bindec('1'); $masksData['underline'] = ($masks >> 2) & \bindec('1');
$masksData['unused1'] = ($masks >> 3) & bindec('1'); $masksData['unused1'] = ($masks >> 3) & \bindec('1');
$masksData['shadow'] = ($masks >> 4) & bindec('1'); $masksData['shadow'] = ($masks >> 4) & \bindec('1');
$masksData['fehint'] = ($masks >> 5) & bindec('1'); $masksData['fehint'] = ($masks >> 5) & \bindec('1');
$masksData['unused2'] = ($masks >> 6) & bindec('1'); $masksData['unused2'] = ($masks >> 6) & \bindec('1');
$masksData['kumi'] = ($masks >> 7) & bindec('1'); $masksData['kumi'] = ($masks >> 7) & \bindec('1');
$masksData['unused3'] = ($masks >> 8) & bindec('1'); $masksData['unused3'] = ($masks >> 8) & \bindec('1');
$masksData['emboss'] = ($masks >> 9) & bindec('1'); $masksData['emboss'] = ($masks >> 9) & \bindec('1');
$masksData['fHasStyle'] = ($masks >> 10) & bindec('1111'); $masksData['fHasStyle'] = ($masks >> 10) & \bindec('1111');
$masksData['unused4'] = ($masks >> 14) & bindec('11'); $masksData['unused4'] = ($masks >> 14) & \bindec('11');
$masksData['typeface'] = ($masks >> 16) & bindec('1'); $masksData['typeface'] = ($masks >> 16) & \bindec('1');
$masksData['size'] = ($masks >> 17) & bindec('1'); $masksData['size'] = ($masks >> 17) & \bindec('1');
$masksData['color'] = ($masks >> 18) & bindec('1'); $masksData['color'] = ($masks >> 18) & \bindec('1');
$masksData['position'] = ($masks >> 19) & bindec('1'); $masksData['position'] = ($masks >> 19) & \bindec('1');
$masksData['pp10ext'] = ($masks >> 20) & bindec('1'); $masksData['pp10ext'] = ($masks >> 20) & \bindec('1');
$masksData['oldEATypeface'] = ($masks >> 21) & bindec('1'); $masksData['oldEATypeface'] = ($masks >> 21) & \bindec('1');
$masksData['ansiTypeface'] = ($masks >> 22) & bindec('1'); $masksData['ansiTypeface'] = ($masks >> 22) & \bindec('1');
$masksData['symbolTypeface'] = ($masks >> 23) & bindec('1'); $masksData['symbolTypeface'] = ($masks >> 23) & \bindec('1');
$masksData['newEATypeface'] = ($masks >> 24) & bindec('1'); $masksData['newEATypeface'] = ($masks >> 24) & \bindec('1');
$masksData['csTypeface'] = ($masks >> 25) & bindec('1'); $masksData['csTypeface'] = ($masks >> 25) & \bindec('1');
$masksData['pp11ext'] = ($masks >> 26) & bindec('1'); $masksData['pp11ext'] = ($masks >> 26) & \bindec('1');
if (1 == $masksData['bold'] || 1 == $masksData['italic'] || 1 == $masksData['underline'] || 1 == $masksData['shadow'] || 1 == $masksData['fehint'] || 1 == $masksData['kumi'] || 1 == $masksData['emboss'] || 1 == $masksData['fHasStyle']) { if (1 == $masksData['bold'] || 1 == $masksData['italic'] || 1 == $masksData['underline'] || 1 == $masksData['shadow'] || 1 == $masksData['fehint'] || 1 == $masksData['kumi'] || 1 == $masksData['emboss'] || 1 == $masksData['fHasStyle']) {
$data = self::getInt2d($stream, $pos + $arrayReturn['length']); $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += 2; $arrayReturn['length'] += 2;
$fontStyleFlags = []; $fontStyleFlags = [];
$fontStyleFlags['bold'] = ($data >> 0) & bindec('1'); $fontStyleFlags['bold'] = ($data >> 0) & \bindec('1');
$fontStyleFlags['italic'] = ($data >> 1) & bindec('1'); $fontStyleFlags['italic'] = ($data >> 1) & \bindec('1');
$fontStyleFlags['underline'] = ($data >> 2) & bindec('1'); $fontStyleFlags['underline'] = ($data >> 2) & \bindec('1');
$fontStyleFlags['unused1'] = ($data >> 3) & bindec('1'); $fontStyleFlags['unused1'] = ($data >> 3) & \bindec('1');
$fontStyleFlags['shadow'] = ($data >> 4) & bindec('1'); $fontStyleFlags['shadow'] = ($data >> 4) & \bindec('1');
$fontStyleFlags['fehint'] = ($data >> 5) & bindec('1'); $fontStyleFlags['fehint'] = ($data >> 5) & \bindec('1');
$fontStyleFlags['unused2'] = ($data >> 6) & bindec('1'); $fontStyleFlags['unused2'] = ($data >> 6) & \bindec('1');
$fontStyleFlags['kumi'] = ($data >> 7) & bindec('1'); $fontStyleFlags['kumi'] = ($data >> 7) & \bindec('1');
$fontStyleFlags['unused3'] = ($data >> 8) & bindec('1'); $fontStyleFlags['unused3'] = ($data >> 8) & \bindec('1');
$fontStyleFlags['emboss'] = ($data >> 9) & bindec('1'); $fontStyleFlags['emboss'] = ($data >> 9) & \bindec('1');
$fontStyleFlags['pp9rt'] = ($data >> 10) & bindec('1111'); $fontStyleFlags['pp9rt'] = ($data >> 10) & \bindec('1111');
$fontStyleFlags['unused4'] = ($data >> 14) & bindec('11'); $fontStyleFlags['unused4'] = ($data >> 14) & \bindec('11');
$arrayReturn['bold'] = (1 == $fontStyleFlags['bold']) ? true : false; $arrayReturn['bold'] = (1 == $fontStyleFlags['bold']) ? true : false;
$arrayReturn['italic'] = (1 == $fontStyleFlags['italic']) ? true : false; $arrayReturn['italic'] = (1 == $fontStyleFlags['italic']) ? true : false;
@ -3100,9 +3100,9 @@ class PowerPoint97 implements ReaderInterface
++$arrayReturn['length']; ++$arrayReturn['length'];
if (0xFE == $index) { if (0xFE == $index) {
$strColor = str_pad(dechex($red), 2, '0', STR_PAD_LEFT); $strColor = \str_pad(\dechex($red), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex($green), 2, '0', STR_PAD_LEFT); $strColor .= \str_pad(\dechex($green), 2, '0', STR_PAD_LEFT);
$strColor .= str_pad(dechex($blue), 2, '0', STR_PAD_LEFT); $strColor .= \str_pad(\dechex($blue), 2, '0', STR_PAD_LEFT);
$arrayReturn['color'] = new Color('FF' . $strColor); $arrayReturn['color'] = new Color('FF' . $strColor);
} }
@ -3142,47 +3142,47 @@ class PowerPoint97 implements ReaderInterface
$arrayReturn['length'] += 4; $arrayReturn['length'] += 4;
$masksData = []; $masksData = [];
$masksData['hasBullet'] = ($masks >> 0) & bindec('1'); $masksData['hasBullet'] = ($masks >> 0) & \bindec('1');
$masksData['bulletHasFont'] = ($masks >> 1) & bindec('1'); $masksData['bulletHasFont'] = ($masks >> 1) & \bindec('1');
$masksData['bulletHasColor'] = ($masks >> 2) & bindec('1'); $masksData['bulletHasColor'] = ($masks >> 2) & \bindec('1');
$masksData['bulletHasSize'] = ($masks >> 3) & bindec('1'); $masksData['bulletHasSize'] = ($masks >> 3) & \bindec('1');
$masksData['bulletFont'] = ($masks >> 4) & bindec('1'); $masksData['bulletFont'] = ($masks >> 4) & \bindec('1');
$masksData['bulletColor'] = ($masks >> 5) & bindec('1'); $masksData['bulletColor'] = ($masks >> 5) & \bindec('1');
$masksData['bulletSize'] = ($masks >> 6) & bindec('1'); $masksData['bulletSize'] = ($masks >> 6) & \bindec('1');
$masksData['bulletChar'] = ($masks >> 7) & bindec('1'); $masksData['bulletChar'] = ($masks >> 7) & \bindec('1');
$masksData['leftMargin'] = ($masks >> 8) & bindec('1'); $masksData['leftMargin'] = ($masks >> 8) & \bindec('1');
$masksData['unused'] = ($masks >> 9) & bindec('1'); $masksData['unused'] = ($masks >> 9) & \bindec('1');
$masksData['indent'] = ($masks >> 10) & bindec('1'); $masksData['indent'] = ($masks >> 10) & \bindec('1');
$masksData['align'] = ($masks >> 11) & bindec('1'); $masksData['align'] = ($masks >> 11) & \bindec('1');
$masksData['lineSpacing'] = ($masks >> 12) & bindec('1'); $masksData['lineSpacing'] = ($masks >> 12) & \bindec('1');
$masksData['spaceBefore'] = ($masks >> 13) & bindec('1'); $masksData['spaceBefore'] = ($masks >> 13) & \bindec('1');
$masksData['spaceAfter'] = ($masks >> 14) & bindec('1'); $masksData['spaceAfter'] = ($masks >> 14) & \bindec('1');
$masksData['defaultTabSize'] = ($masks >> 15) & bindec('1'); $masksData['defaultTabSize'] = ($masks >> 15) & \bindec('1');
$masksData['fontAlign'] = ($masks >> 16) & bindec('1'); $masksData['fontAlign'] = ($masks >> 16) & \bindec('1');
$masksData['charWrap'] = ($masks >> 17) & bindec('1'); $masksData['charWrap'] = ($masks >> 17) & \bindec('1');
$masksData['wordWrap'] = ($masks >> 18) & bindec('1'); $masksData['wordWrap'] = ($masks >> 18) & \bindec('1');
$masksData['overflow'] = ($masks >> 19) & bindec('1'); $masksData['overflow'] = ($masks >> 19) & \bindec('1');
$masksData['tabStops'] = ($masks >> 20) & bindec('1'); $masksData['tabStops'] = ($masks >> 20) & \bindec('1');
$masksData['textDirection'] = ($masks >> 21) & bindec('1'); $masksData['textDirection'] = ($masks >> 21) & \bindec('1');
$masksData['reserved1'] = ($masks >> 22) & bindec('1'); $masksData['reserved1'] = ($masks >> 22) & \bindec('1');
$masksData['bulletBlip'] = ($masks >> 23) & bindec('1'); $masksData['bulletBlip'] = ($masks >> 23) & \bindec('1');
$masksData['bulletScheme'] = ($masks >> 24) & bindec('1'); $masksData['bulletScheme'] = ($masks >> 24) & \bindec('1');
$masksData['bulletHasScheme'] = ($masks >> 25) & bindec('1'); $masksData['bulletHasScheme'] = ($masks >> 25) & \bindec('1');
$bulletFlags = []; $bulletFlags = [];
if (1 == $masksData['hasBullet'] || 1 == $masksData['bulletHasFont'] || 1 == $masksData['bulletHasColor'] || 1 == $masksData['bulletHasSize']) { if (1 == $masksData['hasBullet'] || 1 == $masksData['bulletHasFont'] || 1 == $masksData['bulletHasColor'] || 1 == $masksData['bulletHasSize']) {
$data = self::getInt2d($stream, $pos + $arrayReturn['length']); $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += 2; $arrayReturn['length'] += 2;
$bulletFlags['fHasBullet'] = ($data >> 0) & bindec('1'); $bulletFlags['fHasBullet'] = ($data >> 0) & \bindec('1');
$bulletFlags['fBulletHasFont'] = ($data >> 1) & bindec('1'); $bulletFlags['fBulletHasFont'] = ($data >> 1) & \bindec('1');
$bulletFlags['fBulletHasColor'] = ($data >> 2) & bindec('1'); $bulletFlags['fBulletHasColor'] = ($data >> 2) & \bindec('1');
$bulletFlags['fBulletHasSize'] = ($data >> 3) & bindec('1'); $bulletFlags['fBulletHasSize'] = ($data >> 3) & \bindec('1');
} }
if (1 == $masksData['bulletChar']) { if (1 == $masksData['bulletChar']) {
$data = self::getInt2d($stream, $pos + $arrayReturn['length']); $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += 2; $arrayReturn['length'] += 2;
$arrayReturn['bulletChar'] = chr($data); $arrayReturn['bulletChar'] = \chr($data);
} }
if (1 == $masksData['bulletFont']) { if (1 == $masksData['bulletFont']) {
// $data = self::getInt2d($stream, $pos); // $data = self::getInt2d($stream, $pos);
@ -3252,12 +3252,12 @@ class PowerPoint97 implements ReaderInterface
if (1 == $masksData['leftMargin']) { if (1 == $masksData['leftMargin']) {
$data = self::getInt2d($stream, $pos + $arrayReturn['length']); $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += 2; $arrayReturn['length'] += 2;
$arrayReturn['leftMargin'] = (int) round($data / 6); $arrayReturn['leftMargin'] = (int) \round($data / 6);
} }
if (1 == $masksData['indent']) { if (1 == $masksData['indent']) {
$data = self::getInt2d($stream, $pos + $arrayReturn['length']); $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += 2; $arrayReturn['length'] += 2;
$arrayReturn['indent'] = (int) round($data / 6); $arrayReturn['indent'] = (int) \round($data / 6);
} }
if (1 == $masksData['defaultTabSize']) { if (1 == $masksData['defaultTabSize']) {
// $data = self::getInt2d($stream, $pos + $arrayReturn['length']); // $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
@ -3303,24 +3303,24 @@ class PowerPoint97 implements ReaderInterface
$data = self::getInt4d($stream, $pos + $arrayReturn['length']); $data = self::getInt4d($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += 4; $arrayReturn['length'] += 4;
$masksData = []; $masksData = [];
$masksData['spell'] = ($data >> 0) & bindec('1'); $masksData['spell'] = ($data >> 0) & \bindec('1');
$masksData['lang'] = ($data >> 1) & bindec('1'); $masksData['lang'] = ($data >> 1) & \bindec('1');
$masksData['altLang'] = ($data >> 2) & bindec('1'); $masksData['altLang'] = ($data >> 2) & \bindec('1');
$masksData['unused1'] = ($data >> 3) & bindec('1'); $masksData['unused1'] = ($data >> 3) & \bindec('1');
$masksData['unused2'] = ($data >> 4) & bindec('1'); $masksData['unused2'] = ($data >> 4) & \bindec('1');
$masksData['fPp10ext'] = ($data >> 5) & bindec('1'); $masksData['fPp10ext'] = ($data >> 5) & \bindec('1');
$masksData['fBidi'] = ($data >> 6) & bindec('1'); $masksData['fBidi'] = ($data >> 6) & \bindec('1');
$masksData['unused3'] = ($data >> 7) & bindec('1'); $masksData['unused3'] = ($data >> 7) & \bindec('1');
$masksData['reserved1'] = ($data >> 8) & bindec('1'); $masksData['reserved1'] = ($data >> 8) & \bindec('1');
$masksData['smartTag'] = ($data >> 9) & bindec('1'); $masksData['smartTag'] = ($data >> 9) & \bindec('1');
if (1 == $masksData['spell']) { if (1 == $masksData['spell']) {
$data = self::getInt2d($stream, $pos + $arrayReturn['length']); $data = self::getInt2d($stream, $pos + $arrayReturn['length']);
$arrayReturn['length'] += 2; $arrayReturn['length'] += 2;
$masksSpell = []; $masksSpell = [];
$masksSpell['error'] = ($data >> 0) & bindec('1'); $masksSpell['error'] = ($data >> 0) & \bindec('1');
$masksSpell['clean'] = ($data >> 1) & bindec('1'); $masksSpell['clean'] = ($data >> 1) & \bindec('1');
$masksSpell['grammar'] = ($data >> 2) & bindec('1'); $masksSpell['grammar'] = ($data >> 2) & \bindec('1');
} }
if (1 == $masksData['lang']) { if (1 == $masksData['lang']) {
// $data = self::getInt2d($stream, $pos); // $data = self::getInt2d($stream, $pos);
@ -3362,19 +3362,19 @@ class PowerPoint97 implements ReaderInterface
$arrayReturn['length'] += 4; $arrayReturn['length'] += 4;
$masksData = []; $masksData = [];
$masksData['fDefaultTabSize'] = ($data >> 0) & bindec('1'); $masksData['fDefaultTabSize'] = ($data >> 0) & \bindec('1');
$masksData['fCLevels'] = ($data >> 1) & bindec('1'); $masksData['fCLevels'] = ($data >> 1) & \bindec('1');
$masksData['fTabStops'] = ($data >> 2) & bindec('1'); $masksData['fTabStops'] = ($data >> 2) & \bindec('1');
$masksData['fLeftMargin1'] = ($data >> 3) & bindec('1'); $masksData['fLeftMargin1'] = ($data >> 3) & \bindec('1');
$masksData['fLeftMargin2'] = ($data >> 4) & bindec('1'); $masksData['fLeftMargin2'] = ($data >> 4) & \bindec('1');
$masksData['fLeftMargin3'] = ($data >> 5) & bindec('1'); $masksData['fLeftMargin3'] = ($data >> 5) & \bindec('1');
$masksData['fLeftMargin4'] = ($data >> 6) & bindec('1'); $masksData['fLeftMargin4'] = ($data >> 6) & \bindec('1');
$masksData['fLeftMargin5'] = ($data >> 7) & bindec('1'); $masksData['fLeftMargin5'] = ($data >> 7) & \bindec('1');
$masksData['fIndent1'] = ($data >> 8) & bindec('1'); $masksData['fIndent1'] = ($data >> 8) & \bindec('1');
$masksData['fIndent2'] = ($data >> 9) & bindec('1'); $masksData['fIndent2'] = ($data >> 9) & \bindec('1');
$masksData['fIndent3'] = ($data >> 10) & bindec('1'); $masksData['fIndent3'] = ($data >> 10) & \bindec('1');
$masksData['fIndent4'] = ($data >> 11) & bindec('1'); $masksData['fIndent4'] = ($data >> 11) & \bindec('1');
$masksData['fIndent5'] = ($data >> 12) & bindec('1'); $masksData['fIndent5'] = ($data >> 12) & \bindec('1');
if (1 == $masksData['fCLevels']) { if (1 == $masksData['fCLevels']) {
throw new FeatureNotImplementedException(); throw new FeatureNotImplementedException();

View File

@ -49,7 +49,7 @@ class Serialized implements ReaderInterface
public function fileSupportsUnserializePhpPresentation(string $pFilename): bool public function fileSupportsUnserializePhpPresentation(string $pFilename): bool
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!\file_exists($pFilename)) {
throw new FileNotFoundException($pFilename); throw new FileNotFoundException($pFilename);
} }
@ -66,7 +66,7 @@ class Serialized implements ReaderInterface
public function load(string $pFilename): PhpPresentation public function load(string $pFilename): PhpPresentation
{ {
// Check if file exists // Check if file exists
if (!file_exists($pFilename)) { if (!\file_exists($pFilename)) {
throw new FileNotFoundException($pFilename); throw new FileNotFoundException($pFilename);
} }
@ -85,7 +85,7 @@ class Serialized implements ReaderInterface
*/ */
private function loadSerialized(string $pFilename): PhpPresentation private function loadSerialized(string $pFilename): PhpPresentation
{ {
$oArchive = new ZipArchive(); $oArchive = new \ZipArchive();
if (true !== $oArchive->open($pFilename)) { if (true !== $oArchive->open($pFilename)) {
throw new InvalidFileFormatException($pFilename, Serialized::class); throw new InvalidFileFormatException($pFilename, Serialized::class);
} }
@ -95,15 +95,15 @@ class Serialized implements ReaderInterface
throw new InvalidFileFormatException($pFilename, Serialized::class, 'The file PhpPresentation.xml is malformed'); throw new InvalidFileFormatException($pFilename, Serialized::class, 'The file PhpPresentation.xml is malformed');
} }
$xmlData = simplexml_load_string($xmlContent); $xmlData = \simplexml_load_string($xmlContent);
$file = unserialize(base64_decode((string) $xmlData->data)); $file = \unserialize(\base64_decode((string) $xmlData->data));
// Update media links // Update media links
for ($i = 0; $i < $file->getSlideCount(); ++$i) { for ($i = 0; $i < $file->getSlideCount(); ++$i) {
for ($j = 0; $j < $file->getSlide($i)->getShapeCollection()->count(); ++$j) { for ($j = 0; $j < $file->getSlide($i)->getShapeCollection()->count(); ++$j) {
if ($file->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof AbstractDrawingAdapter) { if ($file->getSlide($i)->getShapeCollection()->offsetGet($j) instanceof AbstractDrawingAdapter) {
$imgTemp = $file->getSlide($i)->getShapeCollection()->offsetGet($j); $imgTemp = $file->getSlide($i)->getShapeCollection()->offsetGet($j);
$imgPath = 'zip://' . $pFilename . '#media/' . $imgTemp->getImageIndex() . '/' . pathinfo($imgTemp->getPath(), PATHINFO_BASENAME); $imgPath = 'zip://' . $pFilename . '#media/' . $imgTemp->getImageIndex() . '/' . \pathinfo($imgTemp->getPath(), PATHINFO_BASENAME);
if ($imgTemp instanceof DrawingFile) { if ($imgTemp instanceof DrawingFile) {
$imgTemp->setPath($imgPath, false); $imgTemp->setPath($imgPath, false);
} else { } else {

View File

@ -164,7 +164,7 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
// Resize proportional? // Resize proportional?
if ($this->resizeProportional && 0 != $pValue && 0 != $this->width) { if ($this->resizeProportional && 0 != $pValue && 0 != $this->width) {
$ratio = $this->height / $this->width; $ratio = $this->height / $this->width;
$this->height = (int) round($ratio * $pValue); $this->height = (int) \round($ratio * $pValue);
} }
// Set width // Set width
@ -183,7 +183,7 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
// Resize proportional? // Resize proportional?
if ($this->resizeProportional && 0 != $pValue && 0 != $this->height) { if ($this->resizeProportional && 0 != $pValue && 0 != $this->height) {
$ratio = $this->width / $this->height; $ratio = $this->width / $this->height;
$this->width = (int) round($ratio * $pValue); $this->width = (int) \round($ratio * $pValue);
} }
// Set height // Set height
@ -205,10 +205,10 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
$yratio = $height / $this->height; $yratio = $height / $this->height;
if ($this->resizeProportional && !(0 == $width || 0 == $height)) { if ($this->resizeProportional && !(0 == $width || 0 == $height)) {
if (($xratio * $this->height) < $height) { if (($xratio * $this->height) < $height) {
$this->height = (int) ceil($xratio * $this->height); $this->height = (int) \ceil($xratio * $this->height);
$this->width = $width; $this->width = $width;
} else { } else {
$this->width = (int) ceil($yratio * $this->width); $this->width = (int) \ceil($yratio * $this->width);
$this->height = $height; $this->height = $height;
} }
} }
@ -245,6 +245,6 @@ abstract class AbstractGraphic extends AbstractShape implements ComparableInterf
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->name . $this->description . parent::getHashCode() . __CLASS__); return \md5($this->name . $this->description . parent::getHashCode() . __CLASS__);
} }
} }

View File

@ -171,7 +171,7 @@ class Chart extends AbstractGraphic implements ComparableInterface
*/ */
public function setDisplayBlankAs(string $value): self public function setDisplayBlankAs(string $value): self
{ {
if (in_array($value, [self::BLANKAS_GAP, self::BLANKAS_SPAN, self::BLANKAS_ZERO])) { if (\in_array($value, [self::BLANKAS_GAP, self::BLANKAS_SPAN, self::BLANKAS_ZERO])) {
$this->displayBlankAs = $value; $this->displayBlankAs = $value;
} }
@ -209,6 +209,6 @@ class Chart extends AbstractGraphic implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5(parent::getHashCode() . $this->title->getHashCode() . $this->legend->getHashCode() . $this->plotArea->getHashCode() . $this->view3D->getHashCode() . ($this->includeSpreadsheet ? 1 : 0) . __CLASS__); return \md5(parent::getHashCode() . $this->title->getHashCode() . $this->legend->getHashCode() . $this->plotArea->getHashCode() . $this->view3D->getHashCode() . ($this->includeSpreadsheet ? 1 : 0) . __CLASS__);
} }
} }

View File

@ -232,7 +232,7 @@ class Axis implements ComparableInterface
*/ */
public function setMinBounds(int $minBounds = null): self public function setMinBounds(int $minBounds = null): self
{ {
$this->minBounds = is_null($minBounds) ? null : $minBounds; $this->minBounds = \is_null($minBounds) ? null : $minBounds;
return $this; return $this;
} }
@ -252,7 +252,7 @@ class Axis implements ComparableInterface
*/ */
public function setMaxBounds(int $maxBounds = null): self public function setMaxBounds(int $maxBounds = null): self
{ {
$this->maxBounds = is_null($maxBounds) ? null : $maxBounds; $this->maxBounds = \is_null($maxBounds) ? null : $maxBounds;
return $this; return $this;
} }
@ -454,7 +454,7 @@ class Axis implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->title . $this->formatCode . __CLASS__); return \md5($this->title . $this->formatCode . __CLASS__);
} }
/** /**
@ -533,7 +533,7 @@ class Axis implements ComparableInterface
*/ */
public function setTickLabelPosition(string $value = self::TICK_LABEL_POSITION_NEXT_TO): self public function setTickLabelPosition(string $value = self::TICK_LABEL_POSITION_NEXT_TO): self
{ {
if (in_array($value, [ if (\in_array($value, [
self::TICK_LABEL_POSITION_HIGH, self::TICK_LABEL_POSITION_HIGH,
self::TICK_LABEL_POSITION_LOW, self::TICK_LABEL_POSITION_LOW,
self::TICK_LABEL_POSITION_NEXT_TO, self::TICK_LABEL_POSITION_NEXT_TO,

View File

@ -332,7 +332,7 @@ class Legend implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->position . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->font->getHashCode() . $this->border->getHashCode() . $this->fill->getHashCode() . $this->alignment->getHashCode() . ($this->visible ? 't' : 'f') . __CLASS__); return \md5($this->position . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->font->getHashCode() . $this->border->getHashCode() . $this->fill->getHashCode() . $this->alignment->getHashCode() . ($this->visible ? 't' : 'f') . __CLASS__);
} }
/** /**

View File

@ -95,7 +95,7 @@ class PlotArea implements ComparableInterface
*/ */
public function getType(): AbstractType public function getType(): AbstractType
{ {
if (is_null($this->type)) { if (\is_null($this->type)) {
throw new UndefinedChartTypeException(); throw new UndefinedChartTypeException();
} }
@ -208,7 +208,7 @@ class PlotArea implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5((is_null($this->type) ? 'null' : $this->type->getHashCode()) . $this->axisX->getHashCode() . $this->axisY->getHashCode() . $this->offsetX . $this->offsetY . $this->width . $this->height . __CLASS__); return \md5((\is_null($this->type) ? 'null' : $this->type->getHashCode()) . $this->axisX->getHashCode() . $this->axisY->getHashCode() . $this->offsetX . $this->offsetY . $this->width . $this->height . __CLASS__);
} }
/** /**

View File

@ -369,7 +369,7 @@ class Series implements ComparableInterface
public function hasShowSeparator(): bool public function hasShowSeparator(): bool
{ {
return !is_null($this->separator); return !\is_null($this->separator);
} }
public function setSeparator(?string $pValue): self public function setSeparator(?string $pValue): self
@ -477,7 +477,7 @@ class Series implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5((is_null($this->fill) ? 'null' : $this->fill->getHashCode()) . (is_null($this->font) ? 'null' : $this->font->getHashCode()) . var_export($this->values, true) . var_export($this, true) . __CLASS__); return \md5((\is_null($this->fill) ? 'null' : $this->fill->getHashCode()) . (\is_null($this->font) ? 'null' : $this->font->getHashCode()) . \var_export($this->values, true) . \var_export($this, true) . __CLASS__);
} }
/** /**
@ -515,7 +515,7 @@ class Series implements ComparableInterface
{ {
$this->font = clone $this->font; $this->font = clone $this->font;
$this->marker = clone $this->marker; $this->marker = clone $this->marker;
if (is_object($this->outline)) { if (\is_object($this->outline)) {
$this->outline = clone $this->outline; $this->outline = clone $this->outline;
} }
} }

View File

@ -272,7 +272,7 @@ class Title implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->text . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->font->getHashCode() . $this->alignment->getHashCode() . ($this->visible ? 't' : 'f') . __CLASS__); return \md5($this->text . $this->offsetX . $this->offsetY . $this->width . $this->height . $this->font->getHashCode() . $this->alignment->getHashCode() . ($this->visible ? 't' : 'f') . __CLASS__);
} }
/** /**

View File

@ -60,6 +60,6 @@ class AbstractTypeLine extends AbstractType
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->isSmooth() ? '1' : '0'); return \md5($this->isSmooth() ? '1' : '0');
} }
} }

View File

@ -39,6 +39,6 @@ class Area extends AbstractType implements ComparableInterface
$hash .= $series->getHashCode(); $hash .= $series->getHashCode();
} }
return md5($hash . __CLASS__); return \md5($hash . __CLASS__);
} }
} }

View File

@ -34,6 +34,6 @@ class Bar extends AbstractTypeBar implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5(parent::getHashCode() . __CLASS__); return \md5(parent::getHashCode() . __CLASS__);
} }
} }

View File

@ -34,6 +34,6 @@ class Bar3D extends AbstractTypeBar implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5(parent::getHashCode() . __CLASS__); return \md5(parent::getHashCode() . __CLASS__);
} }
} }

View File

@ -69,6 +69,6 @@ class Doughnut extends AbstractTypePie implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5(parent::getHashCode() . __CLASS__); return \md5(parent::getHashCode() . __CLASS__);
} }
} }

View File

@ -36,6 +36,6 @@ class Line extends AbstractTypeLine implements ComparableInterface
$hash .= $series->getHashCode(); $hash .= $series->getHashCode();
} }
return md5(parent::getHashCode() . $hash . __CLASS__); return \md5(parent::getHashCode() . $hash . __CLASS__);
} }
} }

View File

@ -34,6 +34,6 @@ class Pie extends AbstractTypePie implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5(parent::getHashCode() . __CLASS__); return \md5(parent::getHashCode() . __CLASS__);
} }
} }

View File

@ -34,6 +34,6 @@ class Pie3D extends AbstractTypePie implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5(parent::getHashCode() . __CLASS__); return \md5(parent::getHashCode() . __CLASS__);
} }
} }

View File

@ -36,6 +36,6 @@ class Radar extends AbstractType implements ComparableInterface
$hash .= $series->getHashCode(); $hash .= $series->getHashCode();
} }
return md5($hash . __CLASS__); return \md5($hash . __CLASS__);
} }
} }

View File

@ -36,6 +36,6 @@ class Scatter extends AbstractTypeLine implements ComparableInterface
$hash .= $series->getHashCode(); $hash .= $series->getHashCode();
} }
return md5(parent::getHashCode() . $hash . __CLASS__); return \md5(parent::getHashCode() . $hash . __CLASS__);
} }
} }

View File

@ -228,7 +228,7 @@ class View3D implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->rotationX . $this->rotationY . ($this->rightAngleAxes ? 't' : 'f') . $this->perspective . $this->heightPercent . $this->depthPercent . __CLASS__); return \md5($this->rotationX . $this->rotationY . ($this->rightAngleAxes ? 't' : 'f') . $this->perspective . $this->heightPercent . $this->depthPercent . __CLASS__);
} }
/** /**

View File

@ -47,7 +47,7 @@ class Comment extends AbstractShape implements ComparableInterface
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->setDate(time()); $this->setDate(\time());
} }
public function getAuthor(): ?Author public function getAuthor(): ?Author

View File

@ -104,6 +104,6 @@ class Author
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->getInitials() . $this->getName() . __CLASS__); return \md5($this->getInitials() . $this->getName() . __CLASS__);
} }
} }

View File

@ -57,7 +57,7 @@ class Base64 extends AbstractDrawingAdapter
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->uniqueName = md5(rand(0, 9999) . time() . rand(0, 9999)); $this->uniqueName = \md5(\rand(0, 9999) . \time() . \rand(0, 9999));
$this->data = ''; $this->data = '';
} }
@ -75,10 +75,10 @@ class Base64 extends AbstractDrawingAdapter
public function getContents(): string public function getContents(): string
{ {
list(, $imageContents) = explode(';', $this->getData()); list(, $imageContents) = \explode(';', $this->getData());
list(, $imageContents) = explode(',', $imageContents); list(, $imageContents) = \explode(',', $imageContents);
return base64_decode($imageContents); return \base64_decode($imageContents);
} }
/** /**
@ -86,10 +86,10 @@ class Base64 extends AbstractDrawingAdapter
*/ */
public function getExtension(): string public function getExtension(): string
{ {
list($data) = explode(';', $this->getData()); list($data) = \explode(';', $this->getData());
list(, $mime) = explode(':', $data); list(, $mime) = \explode(':', $data);
if (!array_key_exists($mime, $this->arrayMimeExtension)) { if (!\array_key_exists($mime, $this->arrayMimeExtension)) {
throw new UnauthorizedMimetypeException($mime, $this->arrayMimeExtension); throw new UnauthorizedMimetypeException($mime, $this->arrayMimeExtension);
} }
@ -103,22 +103,22 @@ class Base64 extends AbstractDrawingAdapter
public function getMimeType(): string public function getMimeType(): string
{ {
list($data) = explode(';', $this->getData()); list($data) = \explode(';', $this->getData());
list(, $mime) = explode(':', $data); list(, $mime) = \explode(':', $data);
if (!empty($mime)) { if (!empty($mime)) {
return $mime; return $mime;
} }
$sImage = $this->getContents(); $sImage = $this->getContents();
if (!function_exists('getimagesizefromstring')) { if (!\function_exists('getimagesizefromstring')) {
$uri = 'data://application/octet-stream;base64,' . base64_encode($sImage); $uri = 'data://application/octet-stream;base64,' . \base64_encode($sImage);
$image = getimagesize($uri); $image = \getimagesize($uri);
} else { } else {
$image = getimagesizefromstring($sImage); $image = \getimagesizefromstring($sImage);
} }
return image_type_to_mime_type($image[2]); return \image_type_to_mime_type($image[2]);
} }
/** /**

View File

@ -51,7 +51,7 @@ class File extends AbstractDrawingAdapter
public function setPath(string $pValue = '', bool $pVerifyFile = true): self public function setPath(string $pValue = '', bool $pVerifyFile = true): self
{ {
if ($pVerifyFile) { if ($pVerifyFile) {
if (!file_exists($pValue)) { if (!\file_exists($pValue)) {
throw new FileNotFoundException($pValue); throw new FileNotFoundException($pValue);
} }
} }
@ -59,7 +59,7 @@ class File extends AbstractDrawingAdapter
if ($pVerifyFile) { if ($pVerifyFile) {
if (0 == $this->width && 0 == $this->height) { if (0 == $this->width && 0 == $this->height) {
list($this->width, $this->height) = getimagesize($this->getPath()); list($this->width, $this->height) = \getimagesize($this->getPath());
} }
} }
@ -73,7 +73,7 @@ class File extends AbstractDrawingAdapter
public function getExtension(): string public function getExtension(): string
{ {
return pathinfo($this->getPath(), PATHINFO_EXTENSION); return \pathinfo($this->getPath(), PATHINFO_EXTENSION);
} }
/** /**
@ -84,21 +84,21 @@ class File extends AbstractDrawingAdapter
if (!CommonFile::fileExists($this->getPath())) { if (!CommonFile::fileExists($this->getPath())) {
throw new FileNotFoundException($this->getPath()); throw new FileNotFoundException($this->getPath());
} }
$image = getimagesizefromstring(CommonFile::fileGetContents($this->getPath())); $image = \getimagesizefromstring(CommonFile::fileGetContents($this->getPath()));
if (is_array($image)) { if (\is_array($image)) {
return image_type_to_mime_type($image[2]); return \image_type_to_mime_type($image[2]);
} }
return mime_content_type($this->getPath()); return \mime_content_type($this->getPath());
} }
public function getIndexedFilename(): string public function getIndexedFilename(): string
{ {
$output = str_replace('.' . $this->getExtension(), '', pathinfo($this->getPath(), PATHINFO_FILENAME)); $output = \str_replace('.' . $this->getExtension(), '', \pathinfo($this->getPath(), PATHINFO_FILENAME));
$output .= $this->getImageIndex(); $output .= $this->getImageIndex();
$output .= '.' . $this->getExtension(); $output .= '.' . $this->getExtension();
$output = str_replace(' ', '_', $output); $output = \str_replace(' ', '_', $output);
return $output; return $output;
} }

View File

@ -68,7 +68,7 @@ class Gd extends AbstractDrawingAdapter
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->uniqueName = md5(rand(0, 9999) . time() . rand(0, 9999)); $this->uniqueName = \md5(\rand(0, 9999) . \time() . \rand(0, 9999));
} }
/** /**
@ -92,10 +92,10 @@ class Gd extends AbstractDrawingAdapter
{ {
$this->imageResource = $value; $this->imageResource = $value;
if (!is_null($this->imageResource)) { if (!\is_null($this->imageResource)) {
// Get width/height // Get width/height
$this->width = imagesx($this->imageResource); $this->width = \imagesx($this->imageResource);
$this->height = imagesy($this->imageResource); $this->height = \imagesy($this->imageResource);
} }
return $this; return $this;
@ -149,22 +149,22 @@ class Gd extends AbstractDrawingAdapter
public function getContents(): string public function getContents(): string
{ {
ob_start(); \ob_start();
if (self::MIMETYPE_DEFAULT === $this->getMimeType()) { if (self::MIMETYPE_DEFAULT === $this->getMimeType()) {
imagealphablending($this->getImageResource(), false); \imagealphablending($this->getImageResource(), false);
imagesavealpha($this->getImageResource(), true); \imagesavealpha($this->getImageResource(), true);
} }
call_user_func($this->getRenderingFunction(), $this->getImageResource()); \call_user_func($this->getRenderingFunction(), $this->getImageResource());
$imageContents = ob_get_contents(); $imageContents = \ob_get_contents();
ob_end_clean(); \ob_end_clean();
return $imageContents; return $imageContents;
} }
public function getExtension(): string public function getExtension(): string
{ {
$extension = strtolower($this->getMimeType()); $extension = \strtolower($this->getMimeType());
$extension = explode('/', $extension); $extension = \explode('/', $extension);
$extension = $extension[1]; $extension = $extension[1];
return $extension; return $extension;

View File

@ -72,7 +72,7 @@ class ZipFile extends AbstractDrawingAdapter
public function getExtension(): string public function getExtension(): string
{ {
return pathinfo($this->getZipFileIn(), PATHINFO_EXTENSION); return \pathinfo($this->getZipFileIn(), PATHINFO_EXTENSION);
} }
/** /**
@ -85,39 +85,39 @@ class ZipFile extends AbstractDrawingAdapter
} }
$oArchive = new \ZipArchive(); $oArchive = new \ZipArchive();
$oArchive->open($this->getZipFileOut()); $oArchive->open($this->getZipFileOut());
if (!function_exists('getimagesizefromstring')) { if (!\function_exists('getimagesizefromstring')) {
$uri = 'data://application/octet-stream;base64,' . base64_encode($oArchive->getFromName($this->getZipFileIn())); $uri = 'data://application/octet-stream;base64,' . \base64_encode($oArchive->getFromName($this->getZipFileIn()));
$image = getimagesize($uri); $image = \getimagesize($uri);
} else { } else {
$image = getimagesizefromstring($oArchive->getFromName($this->getZipFileIn())); $image = \getimagesizefromstring($oArchive->getFromName($this->getZipFileIn()));
} }
return image_type_to_mime_type($image[2]); return \image_type_to_mime_type($image[2]);
} }
public function getIndexedFilename(): string public function getIndexedFilename(): string
{ {
$output = pathinfo($this->getZipFileIn(), PATHINFO_FILENAME); $output = \pathinfo($this->getZipFileIn(), PATHINFO_FILENAME);
$output = str_replace('.' . $this->getExtension(), '', $output); $output = \str_replace('.' . $this->getExtension(), '', $output);
$output .= $this->getImageIndex(); $output .= $this->getImageIndex();
$output .= '.' . $this->getExtension(); $output .= '.' . $this->getExtension();
$output = str_replace(' ', '_', $output); $output = \str_replace(' ', '_', $output);
return $output; return $output;
} }
protected function getZipFileOut(): string protected function getZipFileOut(): string
{ {
$path = str_replace('zip://', '', $this->getPath()); $path = \str_replace('zip://', '', $this->getPath());
$path = explode('#', $path); $path = \explode('#', $path);
return empty($path[0]) ? '' : $path[0]; return empty($path[0]) ? '' : $path[0];
} }
protected function getZipFileIn(): string protected function getZipFileIn(): string
{ {
$path = str_replace('zip://', '', $this->getPath()); $path = \str_replace('zip://', '', $this->getPath());
$path = explode('#', $path); $path = \explode('#', $path);
return empty($path[1]) ? '' : $path[1]; return empty($path[1]) ? '' : $path[1];
} }

View File

@ -30,7 +30,7 @@ class Group extends AbstractShape implements ShapeContainerInterface
/** /**
* Collection of shapes. * Collection of shapes.
* *
* @var array<int, AbstractShape>|ArrayObject<int, AbstractShape> * @var array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
*/ */
private $shapeCollection; private $shapeCollection;
@ -53,13 +53,13 @@ class Group extends AbstractShape implements ShapeContainerInterface
parent::__construct(); parent::__construct();
// Shape collection // Shape collection
$this->shapeCollection = new ArrayObject(); $this->shapeCollection = new \ArrayObject();
} }
/** /**
* Get collection of shapes. * Get collection of shapes.
* *
* @return array<int, AbstractShape>|ArrayObject<int, AbstractShape> * @return array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
*/ */
public function getShapeCollection() public function getShapeCollection()
{ {

View File

@ -159,7 +159,7 @@ class Hyperlink
*/ */
public function isInternal(): bool public function isInternal(): bool
{ {
return false !== strpos($this->url, 'ppaction://'); return false !== \strpos($this->url, 'ppaction://');
} }
/** /**
@ -169,7 +169,7 @@ class Hyperlink
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->url . $this->tooltip . __CLASS__); return \md5($this->url . $this->tooltip . __CLASS__);
} }
/** /**

View File

@ -55,6 +55,6 @@ class Line extends AbstractShape implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->getBorder()->getLineStyle() . parent::getHashCode() . __CLASS__); return \md5($this->getBorder()->getLineStyle() . parent::getHashCode() . __CLASS__);
} }
} }

View File

@ -30,7 +30,7 @@ class Media extends File implements ComparableInterface
{ {
public function getMimeType(): string public function getMimeType(): string
{ {
switch (strtolower($this->getExtension())) { switch (\strtolower($this->getExtension())) {
case 'mp4': case 'mp4':
$mimetype = 'video/mp4'; $mimetype = 'video/mp4';
break; break;

View File

@ -207,8 +207,8 @@ class RichText extends AbstractShape implements ComparableInterface
*/ */
public function setActiveParagraph(int $index = 0): Paragraph public function setActiveParagraph(int $index = 0): Paragraph
{ {
if ($index >= count($this->richTextParagraphs)) { if ($index >= \count($this->richTextParagraphs)) {
throw new OutOfBoundsException(0, count($this->richTextParagraphs), $index); throw new OutOfBoundsException(0, \count($this->richTextParagraphs), $index);
} }
$this->activeParagraph = $index; $this->activeParagraph = $index;
@ -223,8 +223,8 @@ class RichText extends AbstractShape implements ComparableInterface
*/ */
public function getParagraph(int $index = 0): Paragraph public function getParagraph(int $index = 0): Paragraph
{ {
if ($index >= count($this->richTextParagraphs)) { if ($index >= \count($this->richTextParagraphs)) {
throw new OutOfBoundsException(0, count($this->richTextParagraphs), $index); throw new OutOfBoundsException(0, \count($this->richTextParagraphs), $index);
} }
return $this->richTextParagraphs[$index]; return $this->richTextParagraphs[$index];
@ -235,7 +235,7 @@ class RichText extends AbstractShape implements ComparableInterface
*/ */
public function createParagraph(): Paragraph public function createParagraph(): Paragraph
{ {
$numParagraphs = count($this->richTextParagraphs); $numParagraphs = \count($this->richTextParagraphs);
if ($numParagraphs > 0) { if ($numParagraphs > 0) {
$alignment = clone $this->getActiveParagraph()->getAlignment(); $alignment = clone $this->getActiveParagraph()->getAlignment();
$font = clone $this->getActiveParagraph()->getFont(); $font = clone $this->getActiveParagraph()->getFont();
@ -243,7 +243,7 @@ class RichText extends AbstractShape implements ComparableInterface
} }
$this->richTextParagraphs[] = new Paragraph(); $this->richTextParagraphs[] = new Paragraph();
$this->activeParagraph = count($this->richTextParagraphs) - 1; $this->activeParagraph = \count($this->richTextParagraphs) - 1;
if (isset($alignment)) { if (isset($alignment)) {
$this->getActiveParagraph()->setAlignment($alignment); $this->getActiveParagraph()->setAlignment($alignment);
@ -351,7 +351,7 @@ class RichText extends AbstractShape implements ComparableInterface
public function setParagraphs(array $paragraphs = []): self public function setParagraphs(array $paragraphs = []): self
{ {
$this->richTextParagraphs = $paragraphs; $this->richTextParagraphs = $paragraphs;
$this->activeParagraph = count($this->richTextParagraphs) - 1; $this->activeParagraph = \count($this->richTextParagraphs) - 1;
return $this; return $this;
} }
@ -419,11 +419,11 @@ class RichText extends AbstractShape implements ComparableInterface
{ {
$this->autoFit = $value; $this->autoFit = $value;
if (!is_null($fontScale)) { if (!\is_null($fontScale)) {
$this->fontScale = $fontScale; $this->fontScale = $fontScale;
} }
if (!is_null($lnSpcReduction)) { if (!\is_null($lnSpcReduction)) {
$this->lnSpcReduction = $lnSpcReduction; $this->lnSpcReduction = $lnSpcReduction;
} }
@ -722,7 +722,7 @@ class RichText extends AbstractShape implements ComparableInterface
$hashElements .= $element->getHashCode(); $hashElements .= $element->getHashCode();
} }
return md5( return \md5(
$hashElements $hashElements
. $this->wrap . $this->wrap
. $this->autoFit . $this->autoFit

View File

@ -87,6 +87,6 @@ class BreakElement implements TextElementInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5(__CLASS__); return \md5(__CLASS__);
} }
} }

View File

@ -267,7 +267,7 @@ class Paragraph implements ComparableInterface
$hashElements .= $element->getHashCode(); $hashElements .= $element->getHashCode();
} }
return md5($hashElements . $this->font->getHashCode() . __CLASS__); return \md5($hashElements . $this->font->getHashCode() . __CLASS__);
} }
/** /**
@ -337,7 +337,7 @@ class Paragraph implements ComparableInterface
*/ */
public function setLineSpacingMode(string $lineSpacingMode): self public function setLineSpacingMode(string $lineSpacingMode): self
{ {
if (in_array($lineSpacingMode, [ if (\in_array($lineSpacingMode, [
self::LINE_SPACING_MODE_PERCENT, self::LINE_SPACING_MODE_PERCENT,
self::LINE_SPACING_MODE_POINT, self::LINE_SPACING_MODE_POINT,
])) { ])) {

View File

@ -75,6 +75,6 @@ class Run extends TextElement implements TextElementInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->getText() . $this->font->getHashCode() . __CLASS__); return \md5($this->getText() . $this->font->getHashCode() . __CLASS__);
} }
} }

View File

@ -92,12 +92,12 @@ class TextElement implements TextElementInterface
public function hasHyperlink(): bool public function hasHyperlink(): bool
{ {
return !is_null($this->hyperlink); return !\is_null($this->hyperlink);
} }
public function getHyperlink(): Hyperlink public function getHyperlink(): Hyperlink
{ {
if (is_null($this->hyperlink)) { if (\is_null($this->hyperlink)) {
$this->hyperlink = new Hyperlink(); $this->hyperlink = new Hyperlink();
} }
@ -147,6 +147,6 @@ class TextElement implements TextElementInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->text . (is_null($this->hyperlink) ? '' : $this->hyperlink->getHashCode()) . __CLASS__); return \md5($this->text . (\is_null($this->hyperlink) ? '' : $this->hyperlink->getHashCode()) . __CLASS__);
} }
} }

View File

@ -71,7 +71,7 @@ class Table extends AbstractGraphic implements ComparableInterface
if (!isset($this->rows[$row])) { if (!isset($this->rows[$row])) {
throw new OutOfBoundsException( throw new OutOfBoundsException(
0, 0,
(count($this->rows) - 1) < 0 ? 0 : count($this->rows) - 1, (\count($this->rows) - 1) < 0 ? 0 : \count($this->rows) - 1,
$row $row
); );
} }
@ -144,6 +144,6 @@ class Table extends AbstractGraphic implements ComparableInterface
$hashElements .= $row->getHashCode(); $hashElements .= $row->getHashCode();
} }
return md5($hashElements . __CLASS__); return \md5($hashElements . __CLASS__);
} }
} }

View File

@ -133,8 +133,8 @@ class Cell implements ComparableInterface
*/ */
public function setActiveParagraph($index = 0): Paragraph public function setActiveParagraph($index = 0): Paragraph
{ {
if ($index >= count($this->richTextParagraphs)) { if ($index >= \count($this->richTextParagraphs)) {
throw new OutOfBoundsException(0, count($this->richTextParagraphs), $index); throw new OutOfBoundsException(0, \count($this->richTextParagraphs), $index);
} }
$this->activeParagraph = $index; $this->activeParagraph = $index;
@ -151,8 +151,8 @@ class Cell implements ComparableInterface
*/ */
public function getParagraph(int $index = 0): Paragraph public function getParagraph(int $index = 0): Paragraph
{ {
if ($index >= count($this->richTextParagraphs)) { if ($index >= \count($this->richTextParagraphs)) {
throw new OutOfBoundsException(0, count($this->richTextParagraphs), $index); throw new OutOfBoundsException(0, \count($this->richTextParagraphs), $index);
} }
return $this->richTextParagraphs[$index]; return $this->richTextParagraphs[$index];
@ -164,7 +164,7 @@ class Cell implements ComparableInterface
public function createParagraph(): Paragraph public function createParagraph(): Paragraph
{ {
$this->richTextParagraphs[] = new Paragraph(); $this->richTextParagraphs[] = new Paragraph();
$totalRichTextParagraphs = count($this->richTextParagraphs); $totalRichTextParagraphs = \count($this->richTextParagraphs);
$this->activeParagraph = $totalRichTextParagraphs - 1; $this->activeParagraph = $totalRichTextParagraphs - 1;
if ($totalRichTextParagraphs > 1) { if ($totalRichTextParagraphs > 1) {
@ -277,7 +277,7 @@ class Cell implements ComparableInterface
public function setParagraphs(array $paragraphs = []): self public function setParagraphs(array $paragraphs = []): self
{ {
$this->richTextParagraphs = $paragraphs; $this->richTextParagraphs = $paragraphs;
$this->activeParagraph = count($this->richTextParagraphs) - 1; $this->activeParagraph = \count($this->richTextParagraphs) - 1;
return $this; return $this;
} }
@ -384,7 +384,7 @@ class Cell implements ComparableInterface
$hashElements .= $element->getHashCode(); $hashElements .= $element->getHashCode();
} }
return md5($hashElements . $this->fill->getHashCode() . $this->borders->getHashCode() . $this->width . __CLASS__); return \md5($hashElements . $this->fill->getHashCode() . $this->borders->getHashCode() . $this->width . __CLASS__);
} }
/** /**

View File

@ -89,7 +89,7 @@ class Row implements ComparableInterface
if (!isset($this->cells[$cell])) { if (!isset($this->cells[$cell])) {
throw new OutOfBoundsException( throw new OutOfBoundsException(
0, 0,
(count($this->cells) - 1) < 0 ? count($this->cells) - 1 : 0, (\count($this->cells) - 1) < 0 ? \count($this->cells) - 1 : 0,
$cell $cell
); );
} }
@ -137,7 +137,7 @@ class Row implements ComparableInterface
throw new OutOfBoundsException( throw new OutOfBoundsException(
0, 0,
(count($this->cells) - 1) < 0 ? count($this->cells) - 1 : 0, (\count($this->cells) - 1) < 0 ? \count($this->cells) - 1 : 0,
$this->activeCellIndex $this->activeCellIndex
); );
} }
@ -200,7 +200,7 @@ class Row implements ComparableInterface
$hashElements .= $cell->getHashCode(); $hashElements .= $cell->getHashCode();
} }
return md5($hashElements . $this->fill->getHashCode() . $this->height . __CLASS__); return \md5($hashElements . $this->fill->getHashCode() . $this->height . __CLASS__);
} }
/** /**

View File

@ -30,7 +30,7 @@ interface ShapeContainerInterface
/** /**
* Get collection of shapes. * Get collection of shapes.
* *
* @return array<int, AbstractShape>|ArrayObject<int, AbstractShape> * @return array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
*/ */
public function getShapeCollection(); public function getShapeCollection();

View File

@ -79,13 +79,13 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
// Shape collection // Shape collection
$this->shapeCollection = new \ArrayObject(); $this->shapeCollection = new \ArrayObject();
// Set identifier // Set identifier
$this->identifier = md5(rand(0, 9999) . time()); $this->identifier = \md5(\rand(0, 9999) . \time());
// Set Slide Layout // Set Slide Layout
if ($this->parent instanceof PhpPresentation) { if ($this->parent instanceof PhpPresentation) {
$arrayMasterSlides = $this->parent->getAllMasterSlides(); $arrayMasterSlides = $this->parent->getAllMasterSlides();
$oMasterSlide = reset($arrayMasterSlides); $oMasterSlide = \reset($arrayMasterSlides);
$arraySlideLayouts = $oMasterSlide->getAllSlideLayouts(); $arraySlideLayouts = $oMasterSlide->getAllSlideLayouts();
$oSlideLayout = reset($arraySlideLayouts); $oSlideLayout = \reset($arraySlideLayouts);
$this->setSlideLayout($oSlideLayout); $this->setSlideLayout($oSlideLayout);
} }
// Set note // Set note
@ -153,7 +153,7 @@ class Slide extends AbstractSlide implements ComparableInterface, ShapeContainer
public function setNote(Note $note = null): self public function setNote(Note $note = null): self
{ {
$this->slideNote = (is_null($note) ? new Note() : $note); $this->slideNote = (\is_null($note) ? new Note() : $note);
$this->slideNote->setParent($this); $this->slideNote->setParent($this);
return $this; return $this;

View File

@ -47,7 +47,7 @@ abstract class AbstractSlide implements ComparableInterface, ShapeContainerInter
/** /**
* Collection of shapes. * Collection of shapes.
* *
* @var array<int, AbstractShape>|ArrayObject<int, AbstractShape> * @var array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
*/ */
protected $shapeCollection = []; protected $shapeCollection = [];
/** /**
@ -102,7 +102,7 @@ abstract class AbstractSlide implements ComparableInterface, ShapeContainerInter
/** /**
* Get collection of shapes. * Get collection of shapes.
* *
* @return array<int, AbstractShape>|ArrayObject<int, AbstractShape> * @return array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
*/ */
public function getShapeCollection() public function getShapeCollection()
{ {
@ -112,7 +112,7 @@ abstract class AbstractSlide implements ComparableInterface, ShapeContainerInter
/** /**
* Get collection of shapes. * Get collection of shapes.
* *
* @param array<int, AbstractShape>|ArrayObject<int, AbstractShape> $shapeCollection * @param array<int, AbstractShape>|\ArrayObject<int, AbstractShape> $shapeCollection
* *
* @return AbstractSlide * @return AbstractSlide
*/ */
@ -198,7 +198,7 @@ abstract class AbstractSlide implements ComparableInterface, ShapeContainerInter
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->identifier . __CLASS__); return \md5($this->identifier . __CLASS__);
} }
/** /**

View File

@ -70,13 +70,13 @@ class Image extends AbstractBackground
public function setPath(string $pValue = '', bool $pVerifyFile = true) public function setPath(string $pValue = '', bool $pVerifyFile = true)
{ {
if ($pVerifyFile) { if ($pVerifyFile) {
if (!file_exists($pValue)) { if (!\file_exists($pValue)) {
throw new FileNotFoundException($pValue); throw new FileNotFoundException($pValue);
} }
if (0 == $this->width && 0 == $this->height) { if (0 == $this->width && 0 == $this->height) {
// Get width/height // Get width/height
list($this->width, $this->height) = getimagesize($pValue); list($this->width, $this->height) = \getimagesize($pValue);
} }
} }
$this->path = $pValue; $this->path = $pValue;
@ -91,7 +91,7 @@ class Image extends AbstractBackground
*/ */
public function getFilename(): string public function getFilename(): string
{ {
return $this->path ? basename($this->path) : ''; return $this->path ? \basename($this->path) : '';
} }
/** /**
@ -101,9 +101,9 @@ class Image extends AbstractBackground
*/ */
public function getExtension(): string public function getExtension(): string
{ {
$exploded = explode('.', $this->getFilename()); $exploded = \explode('.', $this->getFilename());
return $exploded[count($exploded) - 1]; return $exploded[\count($exploded) - 1];
} }
/** /**

View File

@ -24,7 +24,7 @@ use IteratorIterator;
use PhpOffice\PhpPresentation\PhpPresentation; use PhpOffice\PhpPresentation\PhpPresentation;
// @phpstan-ignore-next-line // @phpstan-ignore-next-line
class Iterator extends IteratorIterator class Iterator extends \IteratorIterator
{ {
/** /**
* Presentation to iterate. * Presentation to iterate.

View File

@ -40,7 +40,7 @@ class Note implements ComparableInterface, ShapeContainerInterface
/** /**
* Collection of shapes. * Collection of shapes.
* *
* @var array<int, AbstractShape>|ArrayObject<int, AbstractShape> * @var array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
*/ */
private $shapeCollection; private $shapeCollection;
@ -97,16 +97,16 @@ class Note implements ComparableInterface, ShapeContainerInterface
$this->parent = $pParent; $this->parent = $pParent;
// Shape collection // Shape collection
$this->shapeCollection = new ArrayObject(); $this->shapeCollection = new \ArrayObject();
// Set identifier // Set identifier
$this->identifier = md5(rand(0, 9999) . time()); $this->identifier = \md5(\rand(0, 9999) . \time());
} }
/** /**
* Get collection of shapes. * Get collection of shapes.
* *
* @return array<int, AbstractShape>|ArrayObject<int, AbstractShape> * @return array<int, AbstractShape>|\ArrayObject<int, AbstractShape>
*/ */
public function getShapeCollection() public function getShapeCollection()
{ {
@ -221,7 +221,7 @@ class Note implements ComparableInterface, ShapeContainerInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5($this->identifier . __CLASS__); return \md5($this->identifier . __CLASS__);
} }
/** /**

View File

@ -71,7 +71,7 @@ class SlideLayout extends AbstractSlide implements ComparableInterface, ShapeCon
// Shape collection // Shape collection
$this->shapeCollection = new \ArrayObject(); $this->shapeCollection = new \ArrayObject();
// Set identifier // Set identifier
$this->identifier = md5(rand(0, 9999) . time()); $this->identifier = \md5(\rand(0, 9999) . \time());
// Set a basic colorMap // Set a basic colorMap
$this->colorMap = new ColorMap(); $this->colorMap = new ColorMap();
} }

View File

@ -79,7 +79,7 @@ class SlideMaster extends AbstractSlide implements ComparableInterface, ShapeCon
// Shape collection // Shape collection
$this->shapeCollection = new \ArrayObject(); $this->shapeCollection = new \ArrayObject();
// Set identifier // Set identifier
$this->identifier = md5(rand(0, 9999) . time()); $this->identifier = \md5(\rand(0, 9999) . \time());
// Set a basic colorMap // Set a basic colorMap
$this->colorMap = new ColorMap(); $this->colorMap = new ColorMap();
// Set a white background // Set a white background

View File

@ -100,7 +100,7 @@ class Transition
public function setSpeed(?string $speed = self::SPEED_MEDIUM): self public function setSpeed(?string $speed = self::SPEED_MEDIUM): self
{ {
if (in_array($speed, [self::SPEED_FAST, self::SPEED_MEDIUM, self::SPEED_SLOW])) { if (\in_array($speed, [self::SPEED_FAST, self::SPEED_MEDIUM, self::SPEED_SLOW])) {
$this->speed = $speed; $this->speed = $speed;
} else { } else {
$this->speed = null; $this->speed = null;

View File

@ -212,7 +212,7 @@ class Alignment implements ComparableInterface
*/ */
public function setIndent(float $pValue = 0): self public function setIndent(float $pValue = 0): self
{ {
if ($pValue > 0 && !in_array($this->getHorizontal(), $this->supportedStyles)) { if ($pValue > 0 && !\in_array($this->getHorizontal(), $this->supportedStyles)) {
$pValue = 0; // indent not supported $pValue = 0; // indent not supported
} }
@ -234,7 +234,7 @@ class Alignment implements ComparableInterface
*/ */
public function setMarginLeft(float $pValue = 0): self public function setMarginLeft(float $pValue = 0): self
{ {
if ($pValue > 0 && !in_array($this->getHorizontal(), $this->supportedStyles)) { if ($pValue > 0 && !\in_array($this->getHorizontal(), $this->supportedStyles)) {
$pValue = 0; // margin left not supported $pValue = 0; // margin left not supported
} }
@ -256,7 +256,7 @@ class Alignment implements ComparableInterface
*/ */
public function setMarginRight(float $pValue = 0): self public function setMarginRight(float $pValue = 0): self
{ {
if ($pValue > 0 && !in_array($this->getHorizontal(), $this->supportedStyles)) { if ($pValue > 0 && !\in_array($this->getHorizontal(), $this->supportedStyles)) {
$pValue = 0; // margin right not supported $pValue = 0; // margin right not supported
} }
@ -343,7 +343,7 @@ class Alignment implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5( return \md5(
$this->horizontal $this->horizontal
. $this->vertical . $this->vertical
. $this->level . $this->level

View File

@ -194,7 +194,7 @@ class Border implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5( return \md5(
$this->lineStyle $this->lineStyle
. $this->lineWidth . $this->lineWidth
. $this->dashStyle . $this->dashStyle

View File

@ -159,7 +159,7 @@ class Borders implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5( return \md5(
$this->getLeft()->getHashCode() $this->getLeft()->getHashCode()
. $this->getRight()->getHashCode() . $this->getRight()->getHashCode()
. $this->getTop()->getHashCode() . $this->getTop()->getHashCode()

View File

@ -265,7 +265,7 @@ class Bullet implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5( return \md5(
$this->bulletType $this->bulletType
. $this->bulletFont . $this->bulletFont
. $this->bulletChar . $this->bulletChar

View File

@ -100,9 +100,9 @@ class Color implements ComparableInterface
public function getAlpha(): int public function getAlpha(): int
{ {
$alpha = 100; $alpha = 100;
if (strlen($this->argb) >= 6) { if (\strlen($this->argb) >= 6) {
$dec = hexdec(substr($this->argb, 0, 2)); $dec = \hexdec(\substr($this->argb, 0, 2));
$alpha = (int) number_format(($dec / 255) * 100, 0); $alpha = (int) \number_format(($dec / 255) * 100, 0);
} }
return $alpha; return $alpha;
@ -123,10 +123,10 @@ class Color implements ComparableInterface
if ($alpha > 100) { if ($alpha > 100) {
$alpha = 100; $alpha = 100;
} }
$alpha = round(($alpha / 100) * 255); $alpha = \round(($alpha / 100) * 255);
$alpha = dechex((int) $alpha); $alpha = \dechex((int) $alpha);
$alpha = str_pad($alpha, 2, '0', STR_PAD_LEFT); $alpha = \str_pad($alpha, 2, '0', STR_PAD_LEFT);
$this->argb = $alpha . substr($this->argb, 2); $this->argb = $alpha . \substr($this->argb, 2);
return $this; return $this;
} }
@ -138,10 +138,10 @@ class Color implements ComparableInterface
*/ */
public function getRGB() public function getRGB()
{ {
if (6 == strlen($this->argb)) { if (6 == \strlen($this->argb)) {
return $this->argb; return $this->argb;
} else { } else {
return substr($this->argb, 2); return \substr($this->argb, 2);
} }
} }
@ -173,7 +173,7 @@ class Color implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5( return \md5(
$this->argb $this->argb
. __CLASS__ . __CLASS__
); );

View File

@ -198,7 +198,7 @@ class Fill implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5( return \md5(
$this->getFillType() $this->getFillType()
. $this->getRotation() . $this->getRotation()
. $this->getStartColor()->getHashCode() . $this->getStartColor()->getHashCode()

View File

@ -376,7 +376,7 @@ class Font implements ComparableInterface
*/ */
public function setFormat(string $value = self::FORMAT_LATIN): self public function setFormat(string $value = self::FORMAT_LATIN): self
{ {
if (in_array($value, [ if (\in_array($value, [
self::FORMAT_COMPLEX_SCRIPT, self::FORMAT_COMPLEX_SCRIPT,
self::FORMAT_EAST_ASIAN, self::FORMAT_EAST_ASIAN,
self::FORMAT_LATIN, self::FORMAT_LATIN,
@ -394,7 +394,7 @@ class Font implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5( return \md5(
$this->name $this->name
. $this->size . $this->size
. ($this->bold ? 't' : 'f') . ($this->bold ? 't' : 'f')

View File

@ -232,7 +232,7 @@ class Shadow implements ComparableInterface
*/ */
public function getHashCode(): string public function getHashCode(): string
{ {
return md5(($this->visible ? 't' : 'f') . $this->blurRadius . $this->distance . $this->direction . $this->alignment . $this->color->getHashCode() . $this->alpha . __CLASS__); return \md5(($this->visible ? 't' : 'f') . $this->blurRadius . $this->distance . $this->direction . $this->alignment . $this->color->getHashCode() . $this->alpha . __CLASS__);
} }
/** /**

View File

@ -72,7 +72,7 @@ class TextStyle
private function checkLvl(?int $lvl): bool private function checkLvl(?int $lvl): bool
{ {
if (is_null($lvl) || $lvl > 9) { if (\is_null($lvl) || $lvl > 9) {
return false; return false;
} }

View File

@ -105,31 +105,31 @@ abstract class AbstractWriter
// Get an array of all master slides // Get an array of all master slides
$aSlideMasters = $this->getPhpPresentation()->getAllMasterSlides(); $aSlideMasters = $this->getPhpPresentation()->getAllMasterSlides();
$aSlideMasterLayouts = array_map(function ($oSlideMaster) { $aSlideMasterLayouts = \array_map(function ($oSlideMaster) {
return $oSlideMaster->getAllSlideLayouts(); return $oSlideMaster->getAllSlideLayouts();
}, $aSlideMasters); }, $aSlideMasters);
// Get an array of all slide layouts // Get an array of all slide layouts
$aSlideLayouts = []; $aSlideLayouts = [];
array_walk_recursive($aSlideMasterLayouts, function ($oSlideLayout) use (&$aSlideLayouts) { \array_walk_recursive($aSlideMasterLayouts, function ($oSlideLayout) use (&$aSlideLayouts) {
$aSlideLayouts[] = $oSlideLayout; $aSlideLayouts[] = $oSlideLayout;
}); });
// Loop through PhpPresentation // Loop through PhpPresentation
foreach (array_merge($this->getPhpPresentation()->getAllSlides(), $aSlideMasters, $aSlideLayouts) as $oSlide) { foreach (\array_merge($this->getPhpPresentation()->getAllSlides(), $aSlideMasters, $aSlideLayouts) as $oSlide) {
$arrayReturn = $this->iterateCollection($oSlide->getShapeCollection()->getIterator()); $arrayReturn = $this->iterateCollection($oSlide->getShapeCollection()->getIterator());
$aDrawings = array_merge($aDrawings, $arrayReturn); $aDrawings = \array_merge($aDrawings, $arrayReturn);
} }
return $aDrawings; return $aDrawings;
} }
/** /**
* @param ArrayIterator<int, AbstractShape> $oIterator * @param \ArrayIterator<int, AbstractShape> $oIterator
* *
* @return array<int, AbstractShape> * @return array<int, AbstractShape>
*/ */
private function iterateCollection(ArrayIterator $oIterator): array private function iterateCollection(\ArrayIterator $oIterator): array
{ {
$arrayReturn = []; $arrayReturn = [];
if ($oIterator->count() <= 0) { if ($oIterator->count() <= 0) {
@ -144,7 +144,7 @@ abstract class AbstractWriter
$arrayReturn[] = $oShape; $arrayReturn[] = $oShape;
} elseif ($oShape instanceof Group) { } elseif ($oShape instanceof Group) {
$arrayGroup = $this->iterateCollection($oShape->getShapeCollection()->getIterator()); $arrayGroup = $this->iterateCollection($oShape->getShapeCollection()->getIterator());
$arrayReturn = array_merge($arrayReturn, $arrayGroup); $arrayReturn = \array_merge($arrayReturn, $arrayGroup);
} }
$oIterator->next(); $oIterator->next();
} }

View File

@ -86,8 +86,8 @@ class ODPresentation extends AbstractWriter implements WriterInterface
} }
// If $pFilename is php://output or php://stdout, make it a temporary file... // If $pFilename is php://output or php://stdout, make it a temporary file...
$originalFilename = $pFilename; $originalFilename = $pFilename;
if ('php://output' == strtolower($pFilename) || 'php://stdout' == strtolower($pFilename)) { if ('php://output' == \strtolower($pFilename) || 'php://stdout' == \strtolower($pFilename)) {
$pFilename = @tempnam('./', 'phppttmp'); $pFilename = @\tempnam('./', 'phppttmp');
if ('' == $pFilename) { if ('' == $pFilename) {
$pFilename = $originalFilename; $pFilename = $originalFilename;
} }
@ -105,7 +105,7 @@ class ODPresentation extends AbstractWriter implements WriterInterface
$arrayChart = []; $arrayChart = [];
$arrayFiles = []; $arrayFiles = [];
$oDir = new DirectoryIterator(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ODPresentation'); $oDir = new \DirectoryIterator(\dirname(__FILE__) . DIRECTORY_SEPARATOR . 'ODPresentation');
foreach ($oDir as $oFile) { foreach ($oDir as $oFile) {
if (!$oFile->isFile()) { if (!$oFile->isFile()) {
continue; continue;
@ -120,7 +120,7 @@ class ODPresentation extends AbstractWriter implements WriterInterface
$arrayFiles[$oFile->getBasename('.php')] = $class; $arrayFiles[$oFile->getBasename('.php')] = $class;
} }
ksort($arrayFiles); \ksort($arrayFiles);
foreach ($arrayFiles as $o) { foreach ($arrayFiles as $o) {
$oService = $o->newInstance(); $oService = $o->newInstance();
@ -138,10 +138,10 @@ class ODPresentation extends AbstractWriter implements WriterInterface
// If a temporary file was used, copy it to the correct file stream // If a temporary file was used, copy it to the correct file stream
if ($originalFilename != $pFilename) { if ($originalFilename != $pFilename) {
if (false === copy($pFilename, $originalFilename)) { if (false === \copy($pFilename, $originalFilename)) {
throw new FileCopyException($pFilename, $originalFilename); throw new FileCopyException($pFilename, $originalFilename);
} }
if (false === @unlink($pFilename)) { if (false === @\unlink($pFilename)) {
throw new FileRemoveException($pFilename); throw new FileRemoveException($pFilename);
} }
} }
@ -171,8 +171,8 @@ class ODPresentation extends AbstractWriter implements WriterInterface
{ {
$this->useDiskCaching = $pValue; $this->useDiskCaching = $pValue;
if (!is_null($directory)) { if (!\is_null($directory)) {
if (!is_dir($directory)) { if (!\is_dir($directory)) {
throw new DirectoryNotFoundException($directory); throw new DirectoryNotFoundException($directory);
} }
$this->diskCachingDirectory = $directory; $this->diskCachingDirectory = $directory;

View File

@ -170,7 +170,7 @@ class Content extends AbstractDecoratorWriter
if (!empty($this->arrStyleBullet)) { if (!empty($this->arrStyleBullet)) {
foreach ($this->arrStyleBullet as $key => $item) { foreach ($this->arrStyleBullet as $key => $item) {
$oStyle = $item['oStyle']; $oStyle = $item['oStyle'];
$arrLevel = explode(';', $item['level']); $arrLevel = \explode(';', $item['level']);
// style:style // style:style
$objWriter->startElement('text:list-style'); $objWriter->startElement('text:list-style');
$objWriter->writeAttribute('style:name', 'L_' . $key); $objWriter->writeAttribute('style:name', 'L_' . $key);
@ -179,7 +179,7 @@ class Content extends AbstractDecoratorWriter
$oAlign = $item['oAlign_' . $level]; $oAlign = $item['oAlign_' . $level];
// text:list-level-style-bullet // text:list-level-style-bullet
$objWriter->startElement('text:list-level-style-bullet'); $objWriter->startElement('text:list-level-style-bullet');
$objWriter->writeAttribute('text:level', intval($level) + 1); $objWriter->writeAttribute('text:level', \intval($level) + 1);
$objWriter->writeAttribute('text:bullet-char', $oStyle->getBulletChar()); $objWriter->writeAttribute('text:bullet-char', $oStyle->getBulletChar());
// style:list-level-properties // style:list-level-properties
$objWriter->startElement('style:list-level-properties'); $objWriter->startElement('style:list-level-properties');
@ -318,7 +318,7 @@ class Content extends AbstractDecoratorWriter
$pSlide = $this->getPresentation()->getSlide($i); $pSlide = $this->getPresentation()->getSlide($i);
$objWriter->startElement('draw:page'); $objWriter->startElement('draw:page');
$name = $pSlide->getName(); $name = $pSlide->getName();
if (!is_null($name)) { if (!\is_null($name)) {
$objWriter->writeAttribute('draw:name', $name); $objWriter->writeAttribute('draw:name', $name);
} }
$objWriter->writeAttribute('draw:master-page-name', 'Standard'); $objWriter->writeAttribute('draw:master-page-name', 'Standard');
@ -638,13 +638,13 @@ class Content extends AbstractDecoratorWriter
*/ */
// officeooo:annotation // officeooo:annotation
$objWriter->startElement('officeooo:annotation'); $objWriter->startElement('officeooo:annotation');
$objWriter->writeAttribute('svg:x', number_format(CommonDrawing::pixelsToCentimeters((int) $oShape->getOffsetX()), 2, '.', '') . 'cm'); $objWriter->writeAttribute('svg:x', \number_format(CommonDrawing::pixelsToCentimeters((int) $oShape->getOffsetX()), 2, '.', '') . 'cm');
$objWriter->writeAttribute('svg:y', number_format(CommonDrawing::pixelsToCentimeters((int) $oShape->getOffsetY()), 2, '.', '') . 'cm'); $objWriter->writeAttribute('svg:y', \number_format(CommonDrawing::pixelsToCentimeters((int) $oShape->getOffsetY()), 2, '.', '') . 'cm');
if ($oShape->getAuthor() instanceof Comment\Author) { if ($oShape->getAuthor() instanceof Comment\Author) {
$objWriter->writeElement('dc:creator', $oShape->getAuthor()->getName()); $objWriter->writeElement('dc:creator', $oShape->getAuthor()->getName());
} }
$objWriter->writeElement('dc:date', date('Y-m-d\TH:i:s', $oShape->getDate())); $objWriter->writeElement('dc:date', \date('Y-m-d\TH:i:s', $oShape->getDate()));
$objWriter->writeElement('text:p', $oShape->getText()); $objWriter->writeElement('text:p', $oShape->getText());
// ## officeooo:annotation // ## officeooo:annotation
@ -681,7 +681,7 @@ class Content extends AbstractDecoratorWriter
$arrayRows = $shape->getRows(); $arrayRows = $shape->getRows();
if (!empty($arrayRows)) { if (!empty($arrayRows)) {
$firstRow = reset($arrayRows); $firstRow = \reset($arrayRows);
$arrayCells = $firstRow->getCells(); $arrayCells = $firstRow->getCells();
// table:table // table:table
$objWriter->startElement('table:table'); $objWriter->startElement('table:table');
@ -862,11 +862,11 @@ class Content extends AbstractDecoratorWriter
$objWriter->startElement('style:graphic-properties'); $objWriter->startElement('style:graphic-properties');
$objWriter->writeAttribute('style:mirror', 'none'); $objWriter->writeAttribute('style:mirror', 'none');
$this->writeStylePartShadow($objWriter, $shape->getShadow()); $this->writeStylePartShadow($objWriter, $shape->getShadow());
if (is_bool($shape->hasAutoShrinkVertical())) { if (\is_bool($shape->hasAutoShrinkVertical())) {
$objWriter->writeAttribute('draw:auto-grow-height', var_export($shape->hasAutoShrinkVertical(), true)); $objWriter->writeAttribute('draw:auto-grow-height', \var_export($shape->hasAutoShrinkVertical(), true));
} }
if (is_bool($shape->hasAutoShrinkHorizontal())) { if (\is_bool($shape->hasAutoShrinkHorizontal())) {
$objWriter->writeAttribute('draw:auto-grow-width', var_export($shape->hasAutoShrinkHorizontal(), true)); $objWriter->writeAttribute('draw:auto-grow-width', \var_export($shape->hasAutoShrinkHorizontal(), true));
} }
// Fill // Fill
switch ($shape->getFill()->getFillType()) { switch ($shape->getFill()->getFillType()) {
@ -890,7 +890,7 @@ class Content extends AbstractDecoratorWriter
$objWriter->writeAttribute('draw:stroke', 'none'); $objWriter->writeAttribute('draw:stroke', 'none');
} else { } else {
$objWriter->writeAttribute('svg:stroke-color', '#' . $shape->getBorder()->getColor()->getRGB()); $objWriter->writeAttribute('svg:stroke-color', '#' . $shape->getBorder()->getColor()->getRGB());
$objWriter->writeAttribute('svg:stroke-width', number_format(CommonDrawing::pointsToCentimeters($shape->getBorder()->getLineWidth()), 3, '.', '') . 'cm'); $objWriter->writeAttribute('svg:stroke-width', \number_format(CommonDrawing::pointsToCentimeters($shape->getBorder()->getLineWidth()), 3, '.', '') . 'cm');
switch ($shape->getBorder()->getDashStyle()) { switch ($shape->getBorder()->getDashStyle()) {
case Border::DASH_SOLID: case Border::DASH_SOLID:
$objWriter->writeAttribute('draw:stroke', 'solid'); $objWriter->writeAttribute('draw:stroke', 'solid');
@ -936,7 +936,7 @@ class Content extends AbstractDecoratorWriter
$this->arrStyleBullet[$bulletStyleHashCode]['oStyle'] = $paragraph->getBulletStyle(); $this->arrStyleBullet[$bulletStyleHashCode]['oStyle'] = $paragraph->getBulletStyle();
$this->arrStyleBullet[$bulletStyleHashCode]['level'] = ''; $this->arrStyleBullet[$bulletStyleHashCode]['level'] = '';
} }
if (false === strpos($this->arrStyleBullet[$bulletStyleHashCode]['level'], ';' . $paragraph->getAlignment()->getLevel())) { if (false === \strpos($this->arrStyleBullet[$bulletStyleHashCode]['level'], ';' . $paragraph->getAlignment()->getLevel())) {
$this->arrStyleBullet[$bulletStyleHashCode]['level'] .= ';' . $paragraph->getAlignment()->getLevel(); $this->arrStyleBullet[$bulletStyleHashCode]['level'] .= ';' . $paragraph->getAlignment()->getLevel();
$this->arrStyleBullet[$bulletStyleHashCode]['oAlign_' . $paragraph->getAlignment()->getLevel()] = $paragraph->getAlignment(); $this->arrStyleBullet[$bulletStyleHashCode]['oAlign_' . $paragraph->getAlignment()->getLevel()] = $paragraph->getAlignment();
} }
@ -1129,7 +1129,7 @@ class Content extends AbstractDecoratorWriter
protected function writeSlideNote(XMLWriter $objWriter, Note $note): void protected function writeSlideNote(XMLWriter $objWriter, Note $note): void
{ {
$shapesNote = $note->getShapeCollection(); $shapesNote = $note->getShapeCollection();
if (count($shapesNote) > 0) { if (\count($shapesNote) > 0) {
$objWriter->startElement('presentation:notes'); $objWriter->startElement('presentation:notes');
foreach ($shapesNote as $shape) { foreach ($shapesNote as $shape) {
@ -1157,8 +1157,8 @@ class Content extends AbstractDecoratorWriter
// style:style/style:drawing-page-properties // style:style/style:drawing-page-properties
$objWriter->startElement('style:drawing-page-properties'); $objWriter->startElement('style:drawing-page-properties');
$objWriter->writeAttributeIf(!$slide->isVisible(), 'presentation:visibility', 'hidden'); $objWriter->writeAttributeIf(!$slide->isVisible(), 'presentation:visibility', 'hidden');
if (!is_null($oTransition = $slide->getTransition())) { if (!\is_null($oTransition = $slide->getTransition())) {
$objWriter->writeAttribute('presentation:duration', 'PT' . number_format($oTransition->getAdvanceTimeTrigger() / 1000, 6, '.', '') . 'S'); $objWriter->writeAttribute('presentation:duration', 'PT' . \number_format($oTransition->getAdvanceTimeTrigger() / 1000, 6, '.', '') . 'S');
$objWriter->writeAttributeIf($oTransition->hasManualTrigger(), 'presentation:transition-type', 'manual'); $objWriter->writeAttributeIf($oTransition->hasManualTrigger(), 'presentation:transition-type', 'manual');
$objWriter->writeAttributeIf($oTransition->hasTimeTrigger(), 'presentation:transition-type', 'automatic'); $objWriter->writeAttributeIf($oTransition->hasTimeTrigger(), 'presentation:transition-type', 'automatic');
switch ($oTransition->getSpeed()) { switch ($oTransition->getSpeed()) {

View File

@ -56,7 +56,7 @@ class Meta extends AbstractDecoratorWriter
// dc:creator // dc:creator
$objWriter->writeElement('dc:creator', $this->getPresentation()->getDocumentProperties()->getLastModifiedBy()); $objWriter->writeElement('dc:creator', $this->getPresentation()->getDocumentProperties()->getLastModifiedBy());
// dc:date // dc:date
$objWriter->writeElement('dc:date', gmdate('Y-m-d\TH:i:s.000', $this->getPresentation()->getDocumentProperties()->getModified())); $objWriter->writeElement('dc:date', \gmdate('Y-m-d\TH:i:s.000', $this->getPresentation()->getDocumentProperties()->getModified()));
// dc:description // dc:description
$objWriter->writeElement('dc:description', $this->getPresentation()->getDocumentProperties()->getDescription()); $objWriter->writeElement('dc:description', $this->getPresentation()->getDocumentProperties()->getDescription());
// dc:subject // dc:subject
@ -64,7 +64,7 @@ class Meta extends AbstractDecoratorWriter
// dc:title // dc:title
$objWriter->writeElement('dc:title', $this->getPresentation()->getDocumentProperties()->getTitle()); $objWriter->writeElement('dc:title', $this->getPresentation()->getDocumentProperties()->getTitle());
// meta:creation-date // meta:creation-date
$objWriter->writeElement('meta:creation-date', gmdate('Y-m-d\TH:i:s.000', $this->getPresentation()->getDocumentProperties()->getCreated())); $objWriter->writeElement('meta:creation-date', \gmdate('Y-m-d\TH:i:s.000', $this->getPresentation()->getDocumentProperties()->getCreated()));
// meta:initial-creator // meta:initial-creator
$objWriter->writeElement('meta:initial-creator', $this->getPresentation()->getDocumentProperties()->getCreator()); $objWriter->writeElement('meta:initial-creator', $this->getPresentation()->getDocumentProperties()->getCreator());
// meta:keyword // meta:keyword
@ -90,7 +90,7 @@ class Meta extends AbstractDecoratorWriter
break; break;
case DocumentProperties::PROPERTY_TYPE_DATE: case DocumentProperties::PROPERTY_TYPE_DATE:
$objWriter->writeAttribute('meta:value-type', 'date'); $objWriter->writeAttribute('meta:value-type', 'date');
$objWriter->writeRaw(date(DATE_W3C, (int) $propertyValue)); $objWriter->writeRaw(\date(DATE_W3C, (int) $propertyValue));
break; break;
case DocumentProperties::PROPERTY_TYPE_STRING: case DocumentProperties::PROPERTY_TYPE_STRING:
case DocumentProperties::PROPERTY_TYPE_UNKNOWN: case DocumentProperties::PROPERTY_TYPE_UNKNOWN:

View File

@ -93,12 +93,12 @@ class MetaInfManifest extends AbstractDecoratorWriter
foreach ($this->getPresentation()->getAllSlides() as $numSlide => $oSlide) { foreach ($this->getPresentation()->getAllSlides() as $numSlide => $oSlide) {
$oBkgImage = $oSlide->getBackground(); $oBkgImage = $oSlide->getBackground();
if ($oBkgImage instanceof Image) { if ($oBkgImage instanceof Image) {
$arrayImage = getimagesize($oBkgImage->getPath()); $arrayImage = \getimagesize($oBkgImage->getPath());
$mimeType = image_type_to_mime_type($arrayImage[2]); $mimeType = \image_type_to_mime_type($arrayImage[2]);
$objWriter->startElement('manifest:file-entry'); $objWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:media-type', $mimeType); $objWriter->writeAttribute('manifest:media-type', $mimeType);
$objWriter->writeAttribute('manifest:full-path', 'Pictures/' . str_replace(' ', '_', $oBkgImage->getIndexedFilename((string) $numSlide))); $objWriter->writeAttribute('manifest:full-path', 'Pictures/' . \str_replace(' ', '_', $oBkgImage->getIndexedFilename((string) $numSlide)));
$objWriter->endElement(); $objWriter->endElement();
} }
} }
@ -107,9 +107,9 @@ class MetaInfManifest extends AbstractDecoratorWriter
$pathThumbnail = $this->getPresentation()->getPresentationProperties()->getThumbnailPath(); $pathThumbnail = $this->getPresentation()->getPresentationProperties()->getThumbnailPath();
// Size : 128x128 pixel // Size : 128x128 pixel
// PNG : 8bit, non-interlaced with full alpha transparency // PNG : 8bit, non-interlaced with full alpha transparency
$gdImage = imagecreatefromstring(file_get_contents($pathThumbnail)); $gdImage = \imagecreatefromstring(\file_get_contents($pathThumbnail));
if ($gdImage) { if ($gdImage) {
imagedestroy($gdImage); \imagedestroy($gdImage);
$objWriter->startElement('manifest:file-entry'); $objWriter->startElement('manifest:file-entry');
$objWriter->writeAttribute('manifest:media-type', 'image/png'); $objWriter->writeAttribute('manifest:media-type', 'image/png');
$objWriter->writeAttribute('manifest:full-path', 'Thumbnails/thumbnail.png'); $objWriter->writeAttribute('manifest:full-path', 'Thumbnails/thumbnail.png');

View File

@ -342,7 +342,7 @@ class ObjectsChart extends AbstractDecoratorWriter
// style:graphic-properties // style:graphic-properties
$this->xmlContent->startElement('style:graphic-properties'); $this->xmlContent->startElement('style:graphic-properties');
$this->xmlContent->writeAttribute('draw:stroke', $axis->getOutline()->getFill()->getFillType()); $this->xmlContent->writeAttribute('draw:stroke', $axis->getOutline()->getFill()->getFillType());
$this->xmlContent->writeAttribute('svg:stroke-width', number_format(CommonDrawing::pointsToCentimeters($axis->getOutline()->getWidth()), 3, '.', '') . 'cm'); $this->xmlContent->writeAttribute('svg:stroke-width', \number_format(CommonDrawing::pointsToCentimeters($axis->getOutline()->getWidth()), 3, '.', '') . 'cm');
$this->xmlContent->writeAttribute('svg:stroke-color', '#' . $axis->getOutline()->getFill()->getStartColor()->getRGB()); $this->xmlContent->writeAttribute('svg:stroke-color', '#' . $axis->getOutline()->getFill()->getStartColor()->getRGB());
$this->xmlContent->endElement(); $this->xmlContent->endElement();
// style:style > style:text-properties // style:style > style:text-properties
@ -391,7 +391,7 @@ class ObjectsChart extends AbstractDecoratorWriter
$this->xmlContent->writeAttribute('style:family', 'chart'); $this->xmlContent->writeAttribute('style:family', 'chart');
// style:style > style:graphic-properties // style:style > style:graphic-properties
$this->xmlContent->startElement('style:graphic-properties'); $this->xmlContent->startElement('style:graphic-properties');
$this->xmlContent->writeAttribute('svg:stroke-width', number_format(CommonDrawing::pointsToCentimeters($oGridlines->getOutline()->getWidth()), 2, '.', '') . 'cm'); $this->xmlContent->writeAttribute('svg:stroke-width', \number_format(CommonDrawing::pointsToCentimeters($oGridlines->getOutline()->getWidth()), 2, '.', '') . 'cm');
$this->xmlContent->writeAttribute('svg:stroke-color', '#' . $oGridlines->getOutline()->getFill()->getStartColor()->getRGB()); $this->xmlContent->writeAttribute('svg:stroke-color', '#' . $oGridlines->getOutline()->getFill()->getStartColor()->getRGB());
$this->xmlContent->endElement(); $this->xmlContent->endElement();
// ##style:style // ##style:style
@ -617,7 +617,7 @@ class ObjectsChart extends AbstractDecoratorWriter
{ {
$chartType = $chart->getPlotArea()->getType(); $chartType = $chart->getPlotArea()->getType();
$numRange = count($series->getValues()); $numRange = \count($series->getValues());
// chart:series // chart:series
$this->xmlContent->startElement('chart:series'); $this->xmlContent->startElement('chart:series');
$this->xmlContent->writeAttribute('chart:values-cell-range-address', 'table-local.$' . $this->rangeCol . '$2:.$' . $this->rangeCol . '$' . ($numRange + 1)); $this->xmlContent->writeAttribute('chart:values-cell-range-address', 'table-local.$' . $this->rangeCol . '$2:.$' . $this->rangeCol . '$' . ($numRange + 1));
@ -662,7 +662,7 @@ class ObjectsChart extends AbstractDecoratorWriter
// > chart:data-point // > chart:data-point
$this->xmlContent->endElement(); $this->xmlContent->endElement();
} elseif ($chartType instanceof AbstractTypePie) { } elseif ($chartType instanceof AbstractTypePie) {
$count = count($series->getDataPointFills()); $count = \count($series->getDataPointFills());
for ($inc = 0; $inc < $count; ++$inc) { for ($inc = 0; $inc < $count; ++$inc) {
// chart:data-point // chart:data-point
$this->xmlContent->startElement('chart:data-point'); $this->xmlContent->startElement('chart:data-point');
@ -730,7 +730,7 @@ class ObjectsChart extends AbstractDecoratorWriter
break; break;
} }
$this->xmlContent->writeAttribute('chart:symbol-name', $symbolName); $this->xmlContent->writeAttribute('chart:symbol-name', $symbolName);
$symbolSize = number_format(CommonDrawing::pointsToCentimeters($oMarker->getSize()), 2, '.', ''); $symbolSize = \number_format(CommonDrawing::pointsToCentimeters($oMarker->getSize()), 2, '.', '');
$this->xmlContent->writeAttribute('chart:symbol-width', $symbolSize . 'cm'); $this->xmlContent->writeAttribute('chart:symbol-width', $symbolSize . 'cm');
$this->xmlContent->writeAttribute('chart:symbol-height', $symbolSize . 'cm'); $this->xmlContent->writeAttribute('chart:symbol-height', $symbolSize . 'cm');
} }
@ -760,7 +760,7 @@ class ObjectsChart extends AbstractDecoratorWriter
if ($oOutline instanceof Outline) { if ($oOutline instanceof Outline) {
$outlineWidth = $oOutline->getWidth(); $outlineWidth = $oOutline->getWidth();
if (!empty($outlineWidth)) { if (!empty($outlineWidth)) {
$outlineWidth = number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', ''); $outlineWidth = \number_format(CommonDrawing::pointsToCentimeters($outlineWidth), 3, '.', '');
} }
$outlineColor = $oOutline->getFill()->getStartColor()->getRGB(); $outlineColor = $oOutline->getFill()->getStartColor()->getRGB();
} }
@ -819,8 +819,8 @@ class ObjectsChart extends AbstractDecoratorWriter
// table:table-column // table:table-column
$this->xmlContent->startElement('table:table-column'); $this->xmlContent->startElement('table:table-column');
if (!empty($this->arrayData)) { if (!empty($this->arrayData)) {
$rowFirst = reset($this->arrayData); $rowFirst = \reset($this->arrayData);
$this->xmlContent->writeAttribute('table:number-columns-repeated', count($rowFirst) - 1); $this->xmlContent->writeAttribute('table:number-columns-repeated', \count($rowFirst) - 1);
} }
// > table:table-column // > table:table-column
$this->xmlContent->endElement(); $this->xmlContent->endElement();
@ -842,7 +842,7 @@ class ObjectsChart extends AbstractDecoratorWriter
$this->xmlContent->startElement('table:table-cell'); $this->xmlContent->startElement('table:table-cell');
$this->xmlContent->endElement(); $this->xmlContent->endElement();
} else { } else {
$rowFirst = reset($this->arrayData); $rowFirst = \reset($this->arrayData);
foreach ($rowFirst as $key => $cell) { foreach ($rowFirst as $key => $cell) {
// table:table-cell // table:table-cell
$this->xmlContent->startElement('table:table-cell'); $this->xmlContent->startElement('table:table-cell');
@ -880,13 +880,13 @@ class ObjectsChart extends AbstractDecoratorWriter
// table:table-cell // table:table-cell
$this->xmlContent->startElement('table:table-cell'); $this->xmlContent->startElement('table:table-cell');
$cellValueTypeFloat = is_null($cell) ? true : is_numeric($cell); $cellValueTypeFloat = \is_null($cell) ? true : \is_numeric($cell);
$this->xmlContent->writeAttributeIf(!$cellValueTypeFloat, 'office:value-type', 'string'); $this->xmlContent->writeAttributeIf(!$cellValueTypeFloat, 'office:value-type', 'string');
$this->xmlContent->writeAttributeIf($cellValueTypeFloat, 'office:value-type', 'float'); $this->xmlContent->writeAttributeIf($cellValueTypeFloat, 'office:value-type', 'float');
$this->xmlContent->writeAttributeIf($cellValueTypeFloat, 'office:value', is_null($cell) ? 'NaN' : $cell); $this->xmlContent->writeAttributeIf($cellValueTypeFloat, 'office:value', \is_null($cell) ? 'NaN' : $cell);
// text:p // text:p
$this->xmlContent->startElement('text:p'); $this->xmlContent->startElement('text:p');
$this->xmlContent->text(is_null($cell) ? 'NaN' : (string) $cell); $this->xmlContent->text(\is_null($cell) ? 'NaN' : (string) $cell);
$this->xmlContent->endElement(); $this->xmlContent->endElement();
// > table:table-cell // > table:table-cell
$this->xmlContent->endElement(); $this->xmlContent->endElement();

View File

@ -45,7 +45,7 @@ class Pictures extends AbstractDecoratorWriter
// Add background image slide // Add background image slide
$oBkgImage = $oSlide->getBackground(); $oBkgImage = $oSlide->getBackground();
if ($oBkgImage instanceof Image) { if ($oBkgImage instanceof Image) {
$this->getZip()->addFromString('Pictures/' . $oBkgImage->getIndexedFilename((string) $keySlide), file_get_contents($oBkgImage->getPath())); $this->getZip()->addFromString('Pictures/' . $oBkgImage->getIndexedFilename((string) $keySlide), \file_get_contents($oBkgImage->getPath()));
} }
} }

View File

@ -184,13 +184,13 @@ class Styles extends AbstractDecoratorWriter
{ {
$oFill = $shape->getFill(); $oFill = $shape->getFill();
if (Fill::FILL_GRADIENT_LINEAR == $oFill->getFillType() || Fill::FILL_GRADIENT_PATH == $oFill->getFillType()) { if (Fill::FILL_GRADIENT_LINEAR == $oFill->getFillType() || Fill::FILL_GRADIENT_PATH == $oFill->getFillType()) {
if (!in_array($oFill->getHashCode(), $this->arrayGradient)) { if (!\in_array($oFill->getHashCode(), $this->arrayGradient)) {
$this->writeGradientFill($objWriter, $oFill); $this->writeGradientFill($objWriter, $oFill);
} }
} }
$oBorder = $shape->getBorder(); $oBorder = $shape->getBorder();
if (Border::DASH_SOLID != $oBorder->getDashStyle()) { if (Border::DASH_SOLID != $oBorder->getDashStyle()) {
if (!in_array($oBorder->getDashStyle(), $this->arrayStrokeDash)) { if (!\in_array($oBorder->getDashStyle(), $this->arrayStrokeDash)) {
$objWriter->startElement('draw:stroke-dash'); $objWriter->startElement('draw:stroke-dash');
$objWriter->writeAttribute('draw:name', 'strokeDash_' . $oBorder->getDashStyle()); $objWriter->writeAttribute('draw:name', 'strokeDash_' . $oBorder->getDashStyle());
$objWriter->writeAttribute('draw:style', 'rect'); $objWriter->writeAttribute('draw:style', 'rect');
@ -270,7 +270,7 @@ class Styles extends AbstractDecoratorWriter
foreach ($shape->getRows() as $row) { foreach ($shape->getRows() as $row) {
foreach ($row->getCells() as $cell) { foreach ($row->getCells() as $cell) {
if (Fill::FILL_GRADIENT_LINEAR == $cell->getFill()->getFillType()) { if (Fill::FILL_GRADIENT_LINEAR == $cell->getFill()->getFillType()) {
if (!in_array($cell->getFill()->getHashCode(), $this->arrayGradient)) { if (!\in_array($cell->getFill()->getHashCode(), $this->arrayGradient)) {
$this->writeGradientFill($objWriter, $cell->getFill()); $this->writeGradientFill($objWriter, $cell->getFill());
} }
} }
@ -319,7 +319,7 @@ class Styles extends AbstractDecoratorWriter
{ {
$objWriter->startElement('draw:fill-image'); $objWriter->startElement('draw:fill-image');
$objWriter->writeAttribute('draw:name', 'background_' . (string) $numSlide); $objWriter->writeAttribute('draw:name', 'background_' . (string) $numSlide);
$objWriter->writeAttribute('xlink:href', 'Pictures/' . str_replace(' ', '_', $oBkgImage->getIndexedFilename((string) $numSlide))); $objWriter->writeAttribute('xlink:href', 'Pictures/' . \str_replace(' ', '_', $oBkgImage->getIndexedFilename((string) $numSlide)));
$objWriter->writeAttribute('xlink:type', 'simple'); $objWriter->writeAttribute('xlink:type', 'simple');
$objWriter->writeAttribute('xlink:show', 'embed'); $objWriter->writeAttribute('xlink:show', 'embed');
$objWriter->writeAttribute('xlink:actuate', 'onLoad'); $objWriter->writeAttribute('xlink:actuate', 'onLoad');

View File

@ -30,25 +30,25 @@ class ThumbnailsThumbnail extends AbstractDecoratorWriter
if ($pathThumbnail) { if ($pathThumbnail) {
// Size : 128x128 pixel // Size : 128x128 pixel
// PNG : 8bit, non-interlaced with full alpha transparency // PNG : 8bit, non-interlaced with full alpha transparency
$gdImage = imagecreatefromstring(file_get_contents($pathThumbnail)); $gdImage = \imagecreatefromstring(\file_get_contents($pathThumbnail));
if ($gdImage) { if ($gdImage) {
list($width, $height) = getimagesize($pathThumbnail); list($width, $height) = \getimagesize($pathThumbnail);
$gdRender = imagecreatetruecolor(128, 128); $gdRender = \imagecreatetruecolor(128, 128);
$colorBgAlpha = imagecolorallocatealpha($gdRender, 0, 0, 0, 127); $colorBgAlpha = \imagecolorallocatealpha($gdRender, 0, 0, 0, 127);
imagecolortransparent($gdRender, $colorBgAlpha); \imagecolortransparent($gdRender, $colorBgAlpha);
imagefill($gdRender, 0, 0, $colorBgAlpha); \imagefill($gdRender, 0, 0, $colorBgAlpha);
imagecopyresampled($gdRender, $gdImage, 0, 0, 0, 0, 128, 128, $width, $height); \imagecopyresampled($gdRender, $gdImage, 0, 0, 0, 0, 128, 128, $width, $height);
imagetruecolortopalette($gdRender, false, 255); \imagetruecolortopalette($gdRender, false, 255);
imagesavealpha($gdRender, true); \imagesavealpha($gdRender, true);
ob_start(); \ob_start();
imagepng($gdRender); \imagepng($gdRender);
$imageContents = ob_get_contents(); $imageContents = \ob_get_contents();
ob_end_clean(); \ob_end_clean();
imagedestroy($gdRender); \imagedestroy($gdRender);
imagedestroy($gdImage); \imagedestroy($gdImage);
$this->getZip()->addFromString('Thumbnails/thumbnail.png', $imageContents); $this->getZip()->addFromString('Thumbnails/thumbnail.png', $imageContents);
} }

View File

@ -85,8 +85,8 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
// If $pFilename is php://output or php://stdout, make it a temporary file... // If $pFilename is php://output or php://stdout, make it a temporary file...
$originalFilename = $pFilename; $originalFilename = $pFilename;
if ('php://output' == strtolower($pFilename) || 'php://stdout' == strtolower($pFilename)) { if ('php://output' == \strtolower($pFilename) || 'php://stdout' == \strtolower($pFilename)) {
$pFilename = @tempnam('./', 'phppttmp'); $pFilename = @\tempnam('./', 'phppttmp');
if ('' == $pFilename) { if ('' == $pFilename) {
$pFilename = $originalFilename; $pFilename = $originalFilename;
} }
@ -98,7 +98,7 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
$oZip = $this->getZipAdapter(); $oZip = $this->getZipAdapter();
$oZip->open($pFilename); $oZip->open($pFilename);
$oDir = new DirectoryIterator(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'PowerPoint2007'); $oDir = new \DirectoryIterator(\dirname(__FILE__) . DIRECTORY_SEPARATOR . 'PowerPoint2007');
$arrayFiles = []; $arrayFiles = [];
foreach ($oDir as $oFile) { foreach ($oDir as $oFile) {
if (!$oFile->isFile()) { if (!$oFile->isFile()) {
@ -106,7 +106,7 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
} }
$class = __NAMESPACE__ . '\\PowerPoint2007\\' . $oFile->getBasename('.php'); $class = __NAMESPACE__ . '\\PowerPoint2007\\' . $oFile->getBasename('.php');
$class = new ReflectionClass($class); $class = new \ReflectionClass($class);
if ($class->isAbstract() || !$class->isSubclassOf(AbstractDecoratorWriter::class)) { if ($class->isAbstract() || !$class->isSubclassOf(AbstractDecoratorWriter::class)) {
continue; continue;
@ -114,7 +114,7 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
$arrayFiles[$oFile->getBasename('.php')] = $class; $arrayFiles[$oFile->getBasename('.php')] = $class;
} }
ksort($arrayFiles); \ksort($arrayFiles);
foreach ($arrayFiles as $o) { foreach ($arrayFiles as $o) {
$oService = $o->newInstance(); $oService = $o->newInstance();
@ -130,10 +130,10 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
// If a temporary file was used, copy it to the correct file stream // If a temporary file was used, copy it to the correct file stream
if ($originalFilename != $pFilename) { if ($originalFilename != $pFilename) {
if (false === copy($pFilename, $originalFilename)) { if (false === \copy($pFilename, $originalFilename)) {
throw new FileCopyException($pFilename, $originalFilename); throw new FileCopyException($pFilename, $originalFilename);
} }
if (false === @unlink($pFilename)) { if (false === @\unlink($pFilename)) {
throw new FileRemoveException($pFilename); throw new FileRemoveException($pFilename);
} }
} }
@ -163,8 +163,8 @@ class PowerPoint2007 extends AbstractWriter implements WriterInterface
{ {
$this->useDiskCaching = $useDiskCaching; $this->useDiskCaching = $useDiskCaching;
if (!is_null($directory)) { if (!\is_null($directory)) {
if (!is_dir($directory)) { if (!\is_dir($directory)) {
throw new DirectoryNotFoundException($directory); throw new DirectoryNotFoundException($directory);
} }
$this->diskCachingDir = $directory; $this->diskCachingDir = $directory;

View File

@ -125,7 +125,7 @@ abstract class AbstractDecoratorWriter extends \PhpOffice\PhpPresentation\Writer
protected function writeColor(XMLWriter $objWriter, Color $color, ?int $alpha = null): void protected function writeColor(XMLWriter $objWriter, Color $color, ?int $alpha = null): void
{ {
if (is_null($alpha)) { if (\is_null($alpha)) {
$alpha = $color->getAlpha(); $alpha = $color->getAlpha();
} }
@ -283,12 +283,12 @@ abstract class AbstractDecoratorWriter extends \PhpOffice\PhpPresentation\Writer
*/ */
protected function absoluteZipPath(string $path): string protected function absoluteZipPath(string $path): string
{ {
$path = str_replace([ $path = \str_replace([
'/', '/',
'\\', '\\',
], DIRECTORY_SEPARATOR, $path); ], DIRECTORY_SEPARATOR, $path);
$parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), function (string $var) { $parts = \array_filter(\explode(DIRECTORY_SEPARATOR, $path), function (string $var) {
return (bool) strlen($var); return (bool) \strlen($var);
}); });
$absolutes = []; $absolutes = [];
foreach ($parts as $part) { foreach ($parts as $part) {
@ -296,12 +296,12 @@ abstract class AbstractDecoratorWriter extends \PhpOffice\PhpPresentation\Writer
continue; continue;
} }
if ('..' == $part) { if ('..' == $part) {
array_pop($absolutes); \array_pop($absolutes);
} else { } else {
$absolutes[] = $part; $absolutes[] = $part;
} }
} }
return implode('/', $absolutes); return \implode('/', $absolutes);
} }
} }

Some files were not shown because too many files have changed in this diff Show More