diff --git a/src/PhpPresentation/AbstractShape.php b/src/PhpPresentation/AbstractShape.php index c73060f29..2015d0451 100644 --- a/src/PhpPresentation/AbstractShape.php +++ b/src/PhpPresentation/AbstractShape.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation; use PhpOffice\PhpPresentation\Shape\Hyperlink; diff --git a/src/PhpPresentation/Autoloader.php b/src/PhpPresentation/Autoloader.php index 02d112c13..6c7211fde 100644 --- a/src/PhpPresentation/Autoloader.php +++ b/src/PhpPresentation/Autoloader.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation; /** @@ -43,6 +45,9 @@ public static function autoload(string $class): void if (0 === strncmp(self::NAMESPACE_PREFIX, $class, $prefixLength)) { $file = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, $prefixLength)); $file = realpath(__DIR__ . (empty($file) ? '' : DIRECTORY_SEPARATOR) . $file . '.php'); + if (!$file) { + return; + } if (file_exists($file)) { /** @noinspection PhpIncludeInspection Dynamic includes */ require_once $file; diff --git a/src/PhpPresentation/ComparableInterface.php b/src/PhpPresentation/ComparableInterface.php index d4dbe569b..7fefbda1c 100644 --- a/src/PhpPresentation/ComparableInterface.php +++ b/src/PhpPresentation/ComparableInterface.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation; /** diff --git a/src/PhpPresentation/DocumentLayout.php b/src/PhpPresentation/DocumentLayout.php index b5ef68a2c..bf7910407 100644 --- a/src/PhpPresentation/DocumentLayout.php +++ b/src/PhpPresentation/DocumentLayout.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation; use PhpOffice\Common\Drawing; @@ -224,7 +226,7 @@ protected function convertUnit(float $value, string $fromUnit, string $toUnit): $value /= 914400; break; case self::UNIT_PIXEL: - $value = Drawing::emuToPixels($value); + $value = Drawing::emuToPixels((int) $value); break; case self::UNIT_POINT: $value /= 12700; diff --git a/src/PhpPresentation/DocumentProperties.php b/src/PhpPresentation/DocumentProperties.php index 85fb89442..ab4542043 100644 --- a/src/PhpPresentation/DocumentProperties.php +++ b/src/PhpPresentation/DocumentProperties.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation; /** @@ -398,9 +400,9 @@ public function isCustomPropertySet(string $propertyName): bool * * @param string $propertyName * - * @return string|null + * @return mixed|null */ - public function getCustomPropertyValue(string $propertyName): ?string + public function getCustomPropertyValue(string $propertyName) { if ($this->isCustomPropertySet($propertyName)) { return $this->customProperties[$propertyName]['value']; diff --git a/src/PhpPresentation/GeometryCalculator.php b/src/PhpPresentation/GeometryCalculator.php index 8d309bf8d..7eccbf895 100644 --- a/src/PhpPresentation/GeometryCalculator.php +++ b/src/PhpPresentation/GeometryCalculator.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation; /** diff --git a/src/PhpPresentation/HashTable.php b/src/PhpPresentation/HashTable.php index 59b95c67c..242b582a7 100644 --- a/src/PhpPresentation/HashTable.php +++ b/src/PhpPresentation/HashTable.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation; /** diff --git a/src/PhpPresentation/IOFactory.php b/src/PhpPresentation/IOFactory.php index b29df5b14..5a34cd171 100644 --- a/src/PhpPresentation/IOFactory.php +++ b/src/PhpPresentation/IOFactory.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation; use PhpOffice\PhpPresentation\Reader\ReaderInterface; @@ -51,7 +53,7 @@ public static function createWriter(PhpPresentation $phpPresentation, string $na * * @throws \Exception */ - public static function createReader(string $name = ''): ReaderInterface + public static function createReader(string $name): ReaderInterface { $class = 'PhpOffice\\PhpPresentation\\Reader\\' . $name; diff --git a/src/PhpPresentation/PhpPresentation.php b/src/PhpPresentation/PhpPresentation.php index 91adcb8c3..4e3c4665d 100644 --- a/src/PhpPresentation/PhpPresentation.php +++ b/src/PhpPresentation/PhpPresentation.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation; use ArrayObject; diff --git a/src/PhpPresentation/PresentationProperties.php b/src/PhpPresentation/PresentationProperties.php index 8a76d887a..a8ee8eff3 100644 --- a/src/PhpPresentation/PresentationProperties.php +++ b/src/PhpPresentation/PresentationProperties.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation; class PresentationProperties diff --git a/src/PhpPresentation/Reader/ODPresentation.php b/src/PhpPresentation/Reader/ODPresentation.php index a9578b541..0ba6288c4 100644 --- a/src/PhpPresentation/Reader/ODPresentation.php +++ b/src/PhpPresentation/Reader/ODPresentation.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Reader; use DateTime; diff --git a/src/PhpPresentation/Reader/PowerPoint2007.php b/src/PhpPresentation/Reader/PowerPoint2007.php index c7b62a0b1..3b19e7cb6 100644 --- a/src/PhpPresentation/Reader/PowerPoint2007.php +++ b/src/PhpPresentation/Reader/PowerPoint2007.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Reader; use DateTime; @@ -540,24 +542,25 @@ protected function loadMasterSlide(string $sPart, string $baseFile): void } else { $level = str_replace('a:lvl', '', $oElementLvl->nodeName); $level = str_replace('pPr', '', $level); + $level = intval($level); } if ($oElementLvl->hasAttribute('algn')) { $oRTParagraph->getAlignment()->setHorizontal($oElementLvl->getAttribute('algn')); } if ($oElementLvl->hasAttribute('marL')) { - $val = $oElementLvl->getAttribute('marL'); - $val = CommonDrawing::emuToPixels($val); + $val = (int) $oElementLvl->getAttribute('marL'); + $val = CommonDrawing::emuToPixels((int) $val); $oRTParagraph->getAlignment()->setMarginLeft($val); } if ($oElementLvl->hasAttribute('marR')) { - $val = $oElementLvl->getAttribute('marR'); - $val = CommonDrawing::emuToPixels($val); + $val = (int) $oElementLvl->getAttribute('marR'); + $val = CommonDrawing::emuToPixels((int) $val); $oRTParagraph->getAlignment()->setMarginRight($val); } if ($oElementLvl->hasAttribute('indent')) { - $val = $oElementLvl->getAttribute('indent'); - $val = CommonDrawing::emuToPixels($val); + $val = (int) $oElementLvl->getAttribute('indent'); + $val = CommonDrawing::emuToPixels((int) $val); $oRTParagraph->getAlignment()->setIndent($val); } $oElementLvlDefRPR = $xmlReader->getElement('a:defRPr', $oElementLvl); @@ -840,27 +843,27 @@ protected function loadShapeDrawing(XMLReader $document, DOMElement $node, Abstr $oElement = $document->getElement('p:spPr/a:xfrm', $node); if ($oElement instanceof DOMElement) { if ($oElement->hasAttribute('rot')) { - $oShape->setRotation((int) CommonDrawing::angleToDegrees($oElement->getAttribute('rot'))); + $oShape->setRotation((int) CommonDrawing::angleToDegrees((int) $oElement->getAttribute('rot'))); } } $oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node); if ($oElement instanceof DOMElement) { if ($oElement->hasAttribute('x')) { - $oShape->setOffsetX(CommonDrawing::emuToPixels($oElement->getAttribute('x'))); + $oShape->setOffsetX(CommonDrawing::emuToPixels((int) $oElement->getAttribute('x'))); } if ($oElement->hasAttribute('y')) { - $oShape->setOffsetY(CommonDrawing::emuToPixels($oElement->getAttribute('y'))); + $oShape->setOffsetY(CommonDrawing::emuToPixels((int) $oElement->getAttribute('y'))); } } $oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node); if ($oElement instanceof DOMElement) { if ($oElement->hasAttribute('cx')) { - $oShape->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('cx'))); + $oShape->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cx'))); } if ($oElement->hasAttribute('cy')) { - $oShape->setHeight(CommonDrawing::emuToPixels($oElement->getAttribute('cy'))); + $oShape->setHeight(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cy'))); } } @@ -871,13 +874,13 @@ protected function loadShapeDrawing(XMLReader $document, DOMElement $node, Abstr $oSubElement = $document->getElement('a:outerShdw', $oElement); if ($oSubElement instanceof DOMElement) { if ($oSubElement->hasAttribute('blurRad')) { - $oShape->getShadow()->setBlurRadius(CommonDrawing::emuToPixels($oSubElement->getAttribute('blurRad'))); + $oShape->getShadow()->setBlurRadius(CommonDrawing::emuToPixels((int) $oSubElement->getAttribute('blurRad'))); } if ($oSubElement->hasAttribute('dist')) { - $oShape->getShadow()->setDistance(CommonDrawing::emuToPixels($oSubElement->getAttribute('dist'))); + $oShape->getShadow()->setDistance(CommonDrawing::emuToPixels((int) $oSubElement->getAttribute('dist'))); } if ($oSubElement->hasAttribute('dir')) { - $oShape->getShadow()->setDirection((int) CommonDrawing::angleToDegrees($oSubElement->getAttribute('dir'))); + $oShape->getShadow()->setDirection((int) CommonDrawing::angleToDegrees((int) $oSubElement->getAttribute('dir'))); } if ($oSubElement->hasAttribute('algn')) { $oShape->getShadow()->setAlignment($oSubElement->getAttribute('algn')); @@ -922,26 +925,26 @@ protected function loadShapeRichText(XMLReader $document, DOMElement $node, Abst $oElement = $document->getElement('p:spPr/a:xfrm', $node); if ($oElement instanceof DOMElement && $oElement->hasAttribute('rot')) { - $oShape->setRotation((int) CommonDrawing::angleToDegrees($oElement->getAttribute('rot'))); + $oShape->setRotation((int) CommonDrawing::angleToDegrees((int) $oElement->getAttribute('rot'))); } $oElement = $document->getElement('p:spPr/a:xfrm/a:off', $node); if ($oElement instanceof DOMElement) { if ($oElement->hasAttribute('x')) { - $oShape->setOffsetX(CommonDrawing::emuToPixels($oElement->getAttribute('x'))); + $oShape->setOffsetX(CommonDrawing::emuToPixels((int) $oElement->getAttribute('x'))); } if ($oElement->hasAttribute('y')) { - $oShape->setOffsetY(CommonDrawing::emuToPixels($oElement->getAttribute('y'))); + $oShape->setOffsetY(CommonDrawing::emuToPixels((int) $oElement->getAttribute('y'))); } } $oElement = $document->getElement('p:spPr/a:xfrm/a:ext', $node); if ($oElement instanceof DOMElement) { if ($oElement->hasAttribute('cx')) { - $oShape->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('cx'))); + $oShape->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cx'))); } if ($oElement->hasAttribute('cy')) { - $oShape->setHeight(CommonDrawing::emuToPixels($oElement->getAttribute('cy'))); + $oShape->setHeight(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cy'))); } } @@ -987,20 +990,20 @@ protected function loadShapeTable(XMLReader $document, DOMElement $node, Abstrac $oElement = $document->getElement('p:xfrm/a:off', $node); if ($oElement instanceof DOMElement) { if ($oElement->hasAttribute('x')) { - $oShape->setOffsetX(CommonDrawing::emuToPixels($oElement->getAttribute('x'))); + $oShape->setOffsetX(CommonDrawing::emuToPixels((int) $oElement->getAttribute('x'))); } if ($oElement->hasAttribute('y')) { - $oShape->setOffsetY(CommonDrawing::emuToPixels($oElement->getAttribute('y'))); + $oShape->setOffsetY(CommonDrawing::emuToPixels((int) $oElement->getAttribute('y'))); } } $oElement = $document->getElement('p:xfrm/a:ext', $node); if ($oElement instanceof DOMElement) { if ($oElement->hasAttribute('cx')) { - $oShape->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('cx'))); + $oShape->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cx'))); } if ($oElement->hasAttribute('cy')) { - $oShape->setHeight(CommonDrawing::emuToPixels($oElement->getAttribute('cy'))); + $oShape->setHeight(CommonDrawing::emuToPixels((int) $oElement->getAttribute('cy'))); } } @@ -1009,7 +1012,7 @@ protected function loadShapeTable(XMLReader $document, DOMElement $node, Abstrac $oShape->createRow(); foreach ($arrayElements as $key => $oElement) { if ($oElement instanceof DOMElement && $oElement->getAttribute('w')) { - $oShape->getRow(0)->getCell($key)->setWidth(CommonDrawing::emuToPixels($oElement->getAttribute('w'))); + $oShape->getRow(0)->getCell($key)->setWidth(CommonDrawing::emuToPixels((int) $oElement->getAttribute('w'))); } } @@ -1023,7 +1026,7 @@ protected function loadShapeTable(XMLReader $document, DOMElement $node, Abstrac $oRow = $oShape->createRow(); } if ($oElementRow->hasAttribute('h')) { - $oRow->setHeight(CommonDrawing::emuToPixels($oElementRow->getAttribute('h'))); + $oRow->setHeight(CommonDrawing::emuToPixels((int) $oElementRow->getAttribute('h'))); } $arrayElementsCell = $document->getElements('a:tc', $oElementRow); foreach ($arrayElementsCell as $keyCell => $oElementCell) { @@ -1125,13 +1128,13 @@ protected function loadParagraph(XMLReader $document, DOMElement $oElement, $oSh $oParagraph->getAlignment()->setVertical($oSubElement->getAttribute('fontAlgn')); } if ($oSubElement->hasAttribute('marL')) { - $oParagraph->getAlignment()->setMarginLeft(CommonDrawing::emuToPixels($oSubElement->getAttribute('marL'))); + $oParagraph->getAlignment()->setMarginLeft(CommonDrawing::emuToPixels((int) $oSubElement->getAttribute('marL'))); } if ($oSubElement->hasAttribute('marR')) { - $oParagraph->getAlignment()->setMarginRight(CommonDrawing::emuToPixels($oSubElement->getAttribute('marR'))); + $oParagraph->getAlignment()->setMarginRight(CommonDrawing::emuToPixels((int) $oSubElement->getAttribute('marR'))); } if ($oSubElement->hasAttribute('indent')) { - $oParagraph->getAlignment()->setIndent(CommonDrawing::emuToPixels($oSubElement->getAttribute('indent'))); + $oParagraph->getAlignment()->setIndent(CommonDrawing::emuToPixels((int) $oSubElement->getAttribute('indent'))); } if ($oSubElement->hasAttribute('lvl')) { $oParagraph->getAlignment()->setLevel((int) $oSubElement->getAttribute('lvl')); @@ -1339,7 +1342,7 @@ protected function loadStyleFill(XMLReader $xmlReader, DOMElement $oElement): ?F $oRotation = $xmlReader->getElement('a:lin', $oElementFill); if ($oRotation instanceof DOMElement && $oRotation->hasAttribute('ang')) { - $oFill->setRotation(CommonDrawing::angleToDegrees($oRotation->getAttribute('ang'))); + $oFill->setRotation(CommonDrawing::angleToDegrees((int) $oRotation->getAttribute('ang'))); } return $oFill; diff --git a/src/PhpPresentation/Reader/PowerPoint97.php b/src/PhpPresentation/Reader/PowerPoint97.php index 18251cc75..9c086f69f 100644 --- a/src/PhpPresentation/Reader/PowerPoint97.php +++ b/src/PhpPresentation/Reader/PowerPoint97.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Reader; use PhpOffice\Common\Microsoft\OLERead; @@ -31,6 +33,7 @@ use PhpOffice\PhpPresentation\Style\Alignment; use PhpOffice\PhpPresentation\Style\Bullet; use PhpOffice\PhpPresentation\Style\Color; +use PhpOffice\PhpPresentation\Style\Font; /** * Serialized format reader. @@ -1654,7 +1657,9 @@ private function readRecordOfficeArtSpContainer(string $stream, int $pos) $txtRun->getFont()->setItalic($clientTextbox['part' . $inc]['italic']); } if (isset($clientTextbox['part' . $inc]['underline'])) { - $txtRun->getFont()->setUnderline($clientTextbox['part' . $inc]['underline']); + $txtRun->getFont()->setUnderline( + $clientTextbox['part' . $inc]['underline'] ? Font::UNDERLINE_SINGLE : Font::UNDERLINE_NONE + ); } if (isset($clientTextbox['part' . $inc]['fontName'])) { $txtRun->getFont()->setName($clientTextbox['part' . $inc]['fontName']); @@ -1953,7 +1958,7 @@ private function readRecordOfficeArtFDG(string $stream, int $pos): array /** * The OfficeArtFOPT record specifies a table of OfficeArtRGFOPTE records. * - * @return array + * @return array * * @see https://msdn.microsoft.com/en-us/library/dd943404(v=office.12).aspx */ @@ -2004,22 +2009,22 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array case 0x0081: // Text : dxTextLeft //@link : http://msdn.microsoft.com/en-us/library/dd953234(v=office.12).aspx - $arrayReturn['insetLeft'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']); + $arrayReturn['insetLeft'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']); break; case 0x0082: // Text : dyTextTop //@link : http://msdn.microsoft.com/en-us/library/dd925068(v=office.12).aspx - $arrayReturn['insetTop'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']); + $arrayReturn['insetTop'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']); break; case 0x0083: // Text : dxTextRight //@link : http://msdn.microsoft.com/en-us/library/dd906782(v=office.12).aspx - $arrayReturn['insetRight'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']); + $arrayReturn['insetRight'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']); break; case 0x0084: // Text : dyTextBottom //@link : http://msdn.microsoft.com/en-us/library/dd772858(v=office.12).aspx - $arrayReturn['insetBottom'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']); + $arrayReturn['insetBottom'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']); break; case 0x0085: // Text : WrapText @@ -2139,12 +2144,12 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array case 0x0193: // Fill : fillRectRight //@link : http://msdn.microsoft.com/en-us/library/dd951294(v=office.12).aspx - // echo 'fillRectRight : '.\PhpOffice\Common\Drawing::emuToPixels($opt['op']).EOL; + // echo 'fillRectRight : '.\PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']).EOL; break; case 0x0194: // Fill : fillRectBottom //@link : http://msdn.microsoft.com/en-us/library/dd910194(v=office.12).aspx - // echo 'fillRectBottom : '.\PhpOffice\Common\Drawing::emuToPixels($opt['op']).EOL; + // echo 'fillRectBottom : '.\PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']).EOL; break; case 0x01BF: // Fill : Fill Style Boolean Properties @@ -2170,7 +2175,7 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array case 0x01CB: // Line Style : lineWidth //@link : http://msdn.microsoft.com/en-us/library/dd926964(v=office.12).aspx - $arrayReturn['lineWidth'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']); + $arrayReturn['lineWidth'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']); break; case 0x01D6: // Line Style : lineJoinStyle @@ -2195,12 +2200,12 @@ private function readRecordOfficeArtFOPT(string $stream, int $pos): array case 0x0205: // Shadow Style : shadowOffsetX //@link : http://msdn.microsoft.com/en-us/library/dd945280(v=office.12).aspx - $arrayReturn['shadowOffsetX'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']); + $arrayReturn['shadowOffsetX'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']); break; case 0x0206: // Shadow Style : shadowOffsetY //@link : http://msdn.microsoft.com/en-us/library/dd907855(v=office.12).aspx - $arrayReturn['shadowOffsetY'] = \PhpOffice\Common\Drawing::emuToPixels($opt['op']); + $arrayReturn['shadowOffsetY'] = \PhpOffice\Common\Drawing::emuToPixels((int) $opt['op']); break; case 0x023F: // Shadow Style : Shadow Style Boolean Properties diff --git a/src/PhpPresentation/Reader/ReaderInterface.php b/src/PhpPresentation/Reader/ReaderInterface.php index 5966da33b..41bc7c34f 100644 --- a/src/PhpPresentation/Reader/ReaderInterface.php +++ b/src/PhpPresentation/Reader/ReaderInterface.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Reader; use PhpOffice\PhpPresentation\PhpPresentation; diff --git a/src/PhpPresentation/Reader/Serialized.php b/src/PhpPresentation/Reader/Serialized.php index 30d4320b0..f0cb9fe6b 100644 --- a/src/PhpPresentation/Reader/Serialized.php +++ b/src/PhpPresentation/Reader/Serialized.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Reader; use Exception; diff --git a/src/PhpPresentation/Shape/AbstractGraphic.php b/src/PhpPresentation/Shape/AbstractGraphic.php index 0192e1a93..e7a4e731d 100644 --- a/src/PhpPresentation/Shape/AbstractGraphic.php +++ b/src/PhpPresentation/Shape/AbstractGraphic.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Shape; use PhpOffice\PhpPresentation\AbstractShape; diff --git a/src/PhpPresentation/Shape/AutoShape.php b/src/PhpPresentation/Shape/AutoShape.php index e69b4c0f4..3d2c21ca5 100644 --- a/src/PhpPresentation/Shape/AutoShape.php +++ b/src/PhpPresentation/Shape/AutoShape.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Shape; use PhpOffice\PhpPresentation\AbstractShape; diff --git a/src/PhpPresentation/Shape/Chart.php b/src/PhpPresentation/Shape/Chart.php index 7cebcb3b2..3d56b7378 100644 --- a/src/PhpPresentation/Shape/Chart.php +++ b/src/PhpPresentation/Shape/Chart.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Shape; use PhpOffice\PhpPresentation\ComparableInterface; diff --git a/src/PhpPresentation/Shape/Chart/Axis.php b/src/PhpPresentation/Shape/Chart/Axis.php index bc0d88d6b..e82a85eb0 100644 --- a/src/PhpPresentation/Shape/Chart/Axis.php +++ b/src/PhpPresentation/Shape/Chart/Axis.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Shape\Chart; use PhpOffice\PhpPresentation\ComparableInterface; diff --git a/src/PhpPresentation/Shape/Chart/Gridlines.php b/src/PhpPresentation/Shape/Chart/Gridlines.php index bf41d442d..83f124886 100644 --- a/src/PhpPresentation/Shape/Chart/Gridlines.php +++ b/src/PhpPresentation/Shape/Chart/Gridlines.php @@ -1,4 +1,22 @@ path); + return $this->path ? basename($this->path) : ''; } /** @@ -82,7 +100,7 @@ public function getFilename() */ public function getExtension(): string { - $exploded = explode('.', basename($this->path)); + $exploded = explode('.', $this->getFilename()); return $exploded[count($exploded) - 1]; } diff --git a/src/PhpPresentation/Slide/Background/SchemeColor.php b/src/PhpPresentation/Slide/Background/SchemeColor.php index bd063b3a6..3cb785df5 100644 --- a/src/PhpPresentation/Slide/Background/SchemeColor.php +++ b/src/PhpPresentation/Slide/Background/SchemeColor.php @@ -1,4 +1,22 @@ argb) >= 6) { $dec = hexdec(substr($this->argb, 0, 2)); - $alpha = number_format(($dec / 255) * 100, 2); + $alpha = (int) number_format(($dec / 255) * 100, 0); } return $alpha; @@ -113,7 +115,7 @@ public function getAlpha() * * @return $this */ - public function setAlpha($alpha = 100) + public function setAlpha(int $alpha = 100): self { if ($alpha < 0) { $alpha = 0; diff --git a/src/PhpPresentation/Style/ColorMap.php b/src/PhpPresentation/Style/ColorMap.php index 12fbc81fa..f95a3bc55 100644 --- a/src/PhpPresentation/Style/ColorMap.php +++ b/src/PhpPresentation/Style/ColorMap.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Style; /** diff --git a/src/PhpPresentation/Style/Fill.php b/src/PhpPresentation/Style/Fill.php index dc1e18d68..cfb13a2f6 100644 --- a/src/PhpPresentation/Style/Fill.php +++ b/src/PhpPresentation/Style/Fill.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Style; use PhpOffice\PhpPresentation\ComparableInterface; diff --git a/src/PhpPresentation/Style/Font.php b/src/PhpPresentation/Style/Font.php index 87b841c22..2e25b257a 100644 --- a/src/PhpPresentation/Style/Font.php +++ b/src/PhpPresentation/Style/Font.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Style; use PhpOffice\PhpPresentation\ComparableInterface; diff --git a/src/PhpPresentation/Style/Outline.php b/src/PhpPresentation/Style/Outline.php index 69e598ec9..99714e27d 100644 --- a/src/PhpPresentation/Style/Outline.php +++ b/src/PhpPresentation/Style/Outline.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Style; /** diff --git a/src/PhpPresentation/Style/SchemeColor.php b/src/PhpPresentation/Style/SchemeColor.php index f170a71bb..040e103b1 100644 --- a/src/PhpPresentation/Style/SchemeColor.php +++ b/src/PhpPresentation/Style/SchemeColor.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Style; class SchemeColor extends Color diff --git a/src/PhpPresentation/Style/Shadow.php b/src/PhpPresentation/Style/Shadow.php index a1575bff3..826dd47d9 100644 --- a/src/PhpPresentation/Style/Shadow.php +++ b/src/PhpPresentation/Style/Shadow.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Style; use PhpOffice\PhpPresentation\ComparableInterface; diff --git a/src/PhpPresentation/Style/TextStyle.php b/src/PhpPresentation/Style/TextStyle.php index d18b1f2ee..0670f7645 100644 --- a/src/PhpPresentation/Style/TextStyle.php +++ b/src/PhpPresentation/Style/TextStyle.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Style; use PhpOffice\PhpPresentation\Shape\RichText\Paragraph as RichTextParagraph; diff --git a/src/PhpPresentation/Writer/AbstractDecoratorWriter.php b/src/PhpPresentation/Writer/AbstractDecoratorWriter.php index 4791f3c80..e77b00e28 100644 --- a/src/PhpPresentation/Writer/AbstractDecoratorWriter.php +++ b/src/PhpPresentation/Writer/AbstractDecoratorWriter.php @@ -1,4 +1,22 @@ startElement('style:list-level-properties'); if ($oAlign->getIndent() < 0) { - $objWriter->writeAttribute('text:space-before', CommonDrawing::pixelsToCentimeters($oAlign->getMarginLeft() - (-1 * $oAlign->getIndent())) . 'cm'); - $objWriter->writeAttribute('text:min-label-width', CommonDrawing::pixelsToCentimeters(-1 * $oAlign->getIndent()) . 'cm'); + $objWriter->writeAttribute('text:space-before', CommonDrawing::pixelsToCentimeters((int) ($oAlign->getMarginLeft() - (-1 * $oAlign->getIndent()))) . 'cm'); + $objWriter->writeAttribute('text:min-label-width', CommonDrawing::pixelsToCentimeters((int) (-1 * $oAlign->getIndent())) . 'cm'); } else { - $objWriter->writeAttribute('text:space-before', (CommonDrawing::pixelsToCentimeters($oAlign->getMarginLeft() - $oAlign->getIndent())) . 'cm'); - $objWriter->writeAttribute('text:min-label-width', CommonDrawing::pixelsToCentimeters($oAlign->getIndent()) . 'cm'); + $objWriter->writeAttribute('text:space-before', (CommonDrawing::pixelsToCentimeters((int) ($oAlign->getMarginLeft() - $oAlign->getIndent()))) . 'cm'); + $objWriter->writeAttribute('text:min-label-width', CommonDrawing::pixelsToCentimeters((int) $oAlign->getIndent()) . 'cm'); } $objWriter->endElement(); @@ -374,10 +392,10 @@ public function writeShapeMedia(XMLWriter $objWriter, Media $shape): void // draw:frame $objWriter->startElement('draw:frame'); $objWriter->writeAttribute('draw:name', $shape->getName()); - $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm'); - $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm'); - $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm'); - $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm'); + $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getWidth()), 3) . 'cm'); + $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getHeight()), 3) . 'cm'); + $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetX()), 3) . 'cm'); + $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetY()), 3) . 'cm'); $objWriter->writeAttribute('draw:style-name', 'gr' . $this->shapeId); // draw:frame > draw:plugin $objWriter->startElement('draw:plugin'); @@ -423,10 +441,10 @@ public function writeShapeDrawing(XMLWriter $objWriter, ShapeDrawing\AbstractDra // draw:frame $objWriter->startElement('draw:frame'); $objWriter->writeAttribute('draw:name', $shape->getName()); - $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm'); - $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm'); - $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm'); - $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm'); + $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getWidth()), 3) . 'cm'); + $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getHeight()), 3) . 'cm'); + $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetX()), 3) . 'cm'); + $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetY()), 3) . 'cm'); $objWriter->writeAttribute('draw:style-name', 'gr' . $this->shapeId); // draw:image $objWriter->startElement('draw:image'); @@ -470,10 +488,10 @@ public function writeShapeTxt(XMLWriter $objWriter, RichText $shape): void // draw:frame $objWriter->startElement('draw:frame'); $objWriter->writeAttribute('draw:style-name', 'gr' . $this->shapeId); - $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm'); - $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm'); - $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm'); - $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm'); + $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getWidth()), 3) . 'cm'); + $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getHeight()), 3) . 'cm'); + $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetX()), 3) . 'cm'); + $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetY()), 3) . 'cm'); // draw:text-box $objWriter->startElement('draw:text-box'); @@ -629,8 +647,8 @@ public function writeShapeComment(XMLWriter $objWriter, Comment $oShape): void */ // officeooo:annotation $objWriter->startElement('officeooo:annotation'); - $objWriter->writeAttribute('svg:x', number_format(CommonDrawing::pixelsToCentimeters($oShape->getOffsetX()), 2, '.', '') . 'cm'); - $objWriter->writeAttribute('svg:y', number_format(CommonDrawing::pixelsToCentimeters($oShape->getOffsetY()), 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'); if ($oShape->getAuthor() instanceof Comment\Author) { $objWriter->writeElement('dc:creator', $oShape->getAuthor()->getName()); @@ -647,10 +665,10 @@ public function writeShapeLine(XMLWriter $objWriter, Line $shape): void // draw:line $objWriter->startElement('draw:line'); $objWriter->writeAttribute('draw:style-name', 'gr' . $this->shapeId); - $objWriter->writeAttribute('svg:x1', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm'); - $objWriter->writeAttribute('svg:y1', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm'); - $objWriter->writeAttribute('svg:x2', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX() + $shape->getWidth()), 3) . 'cm'); - $objWriter->writeAttribute('svg:y2', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY() + $shape->getHeight()), 3) . 'cm'); + $objWriter->writeAttribute('svg:x1', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetX()), 3) . 'cm'); + $objWriter->writeAttribute('svg:y1', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetY()), 3) . 'cm'); + $objWriter->writeAttribute('svg:x2', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetX() + $shape->getWidth()), 3) . 'cm'); + $objWriter->writeAttribute('svg:y2', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetY() + $shape->getHeight()), 3) . 'cm'); // text:p $objWriter->writeElement('text:p'); @@ -667,10 +685,10 @@ public function writeShapeTable(XMLWriter $objWriter, Table $shape): void { // draw:frame $objWriter->startElement('draw:frame'); - $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm'); - $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm'); - $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm'); - $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm'); + $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetX()), 3) . 'cm'); + $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetY()), 3) . 'cm'); + $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getHeight()), 3) . 'cm'); + $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getWidth()), 3) . 'cm'); $arrayRows = $shape->getRows(); if (!empty($arrayRows)) { @@ -768,10 +786,10 @@ public function writeShapeChart(XMLWriter $objWriter, Chart $shape): void // draw:frame $objWriter->startElement('draw:frame'); $objWriter->writeAttribute('draw:name', $shape->getTitle()->getText()); - $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetX()), 3) . 'cm'); - $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getOffsetY()), 3) . 'cm'); - $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getHeight()), 3) . 'cm'); - $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($shape->getWidth()), 3) . 'cm'); + $objWriter->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetX()), 3) . 'cm'); + $objWriter->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getOffsetY()), 3) . 'cm'); + $objWriter->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getHeight()), 3) . 'cm'); + $objWriter->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $shape->getWidth()), 3) . 'cm'); // draw:object $objWriter->startElement('draw:object'); @@ -1365,7 +1383,7 @@ protected function writeStylePartShadow(XMLWriter $objWriter, Shadow $oShadow): $objWriter->writeAttribute('draw:shadow', 'visible'); $objWriter->writeAttribute('draw:shadow-color', '#' . $oShadow->getColor()->getRGB()); - $distanceCms = CommonDrawing::pixelsToCentimeters($oShadow->getDistance()); + $distanceCms = CommonDrawing::pixelsToCentimeters((int) $oShadow->getDistance()); if (0 == $oShadow->getDirection() || 360 == $oShadow->getDirection()) { $objWriter->writeAttribute('draw:shadow-offset-x', $distanceCms . 'cm'); $objWriter->writeAttribute('draw:shadow-offset-y', '0cm'); diff --git a/src/PhpPresentation/Writer/ODPresentation/Meta.php b/src/PhpPresentation/Writer/ODPresentation/Meta.php index 0afaa895a..b91d7d5d8 100644 --- a/src/PhpPresentation/Writer/ODPresentation/Meta.php +++ b/src/PhpPresentation/Writer/ODPresentation/Meta.php @@ -1,4 +1,22 @@ writeAttribute('meta:value-type', 'float'); - $objWriter->writeRaw($propertyValue); + $objWriter->writeRaw((string) $propertyValue); break; case DocumentProperties::PROPERTY_TYPE_BOOLEAN: $objWriter->writeAttribute('meta:value-type', 'boolean'); @@ -79,7 +97,7 @@ public function render() case DocumentProperties::PROPERTY_TYPE_UNKNOWN: default: $objWriter->writeAttribute('meta:value-type', 'string'); - $objWriter->writeRaw($propertyValue); + $objWriter->writeRaw((string) $propertyValue); break; } $objWriter->endElement(); diff --git a/src/PhpPresentation/Writer/ODPresentation/MetaInfManifest.php b/src/PhpPresentation/Writer/ODPresentation/MetaInfManifest.php index 45330e38a..0265d47bf 100644 --- a/src/PhpPresentation/Writer/ODPresentation/MetaInfManifest.php +++ b/src/PhpPresentation/Writer/ODPresentation/MetaInfManifest.php @@ -1,4 +1,22 @@ xmlContent->startElement('office:chart'); // office:chart $this->xmlContent->startElement('chart:chart'); - $this->xmlContent->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getWidth()), 3) . 'cm'); - $this->xmlContent->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getHeight()), 3) . 'cm'); + $this->xmlContent->writeAttribute('svg:width', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $chart->getWidth()), 3) . 'cm'); + $this->xmlContent->writeAttribute('svg:height', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $chart->getHeight()), 3) . 'cm'); $this->xmlContent->writeAttribute('xlink:href', '.'); $this->xmlContent->writeAttribute('xlink:type', 'simple'); $this->xmlContent->writeAttribute('chart:style-name', 'styleChart'); @@ -458,8 +476,8 @@ private function writeLegend(Chart $chart): void break; } $this->xmlContent->writeAttribute('chart:legend-position', $position); - $this->xmlContent->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getLegend()->getOffsetX()), 3) . 'cm'); - $this->xmlContent->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($chart->getLegend()->getOffsetY()), 3) . 'cm'); + $this->xmlContent->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $chart->getLegend()->getOffsetX()), 3) . 'cm'); + $this->xmlContent->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $chart->getLegend()->getOffsetY()), 3) . 'cm'); $this->xmlContent->writeAttribute('style:legend-expansion', 'high'); $this->xmlContent->writeAttribute('chart:style-name', 'styleLegend'); // > chart:legend @@ -913,8 +931,8 @@ private function writeTitle(Title $oTitle): void } // chart:title $this->xmlContent->startElement('chart:title'); - $this->xmlContent->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters($oTitle->getOffsetX()), 3) . 'cm'); - $this->xmlContent->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters($oTitle->getOffsetY()), 3) . 'cm'); + $this->xmlContent->writeAttribute('svg:x', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $oTitle->getOffsetX()), 3) . 'cm'); + $this->xmlContent->writeAttribute('svg:y', Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $oTitle->getOffsetY()), 3) . 'cm'); $this->xmlContent->writeAttribute('chart:style-name', 'styleTitle'); // > text:p $this->xmlContent->startElement('text:p'); diff --git a/src/PhpPresentation/Writer/ODPresentation/Pictures.php b/src/PhpPresentation/Writer/ODPresentation/Pictures.php index 16af2c76c..405c6b184 100644 --- a/src/PhpPresentation/Writer/ODPresentation/Pictures.php +++ b/src/PhpPresentation/Writer/ODPresentation/Pictures.php @@ -1,4 +1,22 @@ writeAttribute('fo:margin-bottom', '0cm'); $objWriter->writeAttribute('fo:margin-left', '0cm'); $objWriter->writeAttribute('fo:margin-right', '0cm'); - $objWriter->writeAttribute('fo:page-width', Text::numberFormat(CommonDrawing::pixelsToCentimeters(CommonDrawing::emuToPixels($this->getPresentation()->getLayout()->getCX())), 1) . 'cm'); - $objWriter->writeAttribute('fo:page-height', Text::numberFormat(CommonDrawing::pixelsToCentimeters(CommonDrawing::emuToPixels($this->getPresentation()->getLayout()->getCY())), 1) . 'cm'); + $objWriter->writeAttribute('fo:page-width', Text::numberFormat(CommonDrawing::pixelsToCentimeters(CommonDrawing::emuToPixels((int) $this->getPresentation()->getLayout()->getCX())), 1) . 'cm'); + $objWriter->writeAttribute('fo:page-height', Text::numberFormat(CommonDrawing::pixelsToCentimeters(CommonDrawing::emuToPixels((int) $this->getPresentation()->getLayout()->getCY())), 1) . 'cm'); $printOrientation = 'portrait'; if ($this->getPresentation()->getLayout()->getCX() > $this->getPresentation()->getLayout()->getCY()) { $printOrientation = 'landscape'; diff --git a/src/PhpPresentation/Writer/ODPresentation/ThumbnailsThumbnail.php b/src/PhpPresentation/Writer/ODPresentation/ThumbnailsThumbnail.php index 087dd042d..7e9988983 100644 --- a/src/PhpPresentation/Writer/ODPresentation/ThumbnailsThumbnail.php +++ b/src/PhpPresentation/Writer/ODPresentation/ThumbnailsThumbnail.php @@ -1,4 +1,22 @@ startElement('a:lin'); - $objWriter->writeAttribute('ang', CommonDrawing::degreesToAngle($pFill->getRotation())); + $objWriter->writeAttribute('ang', CommonDrawing::degreesToAngle((int) $pFill->getRotation())); $objWriter->writeAttribute('scaled', '0'); $objWriter->endElement(); diff --git a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php index 4b3bea8a8..dbb7c53fd 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/AbstractSlide.php @@ -16,6 +16,8 @@ * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Writer\PowerPoint2007; use ArrayObject; @@ -206,7 +208,7 @@ protected function writeShapeText(XMLWriter $objWriter, RichText $shape, int $sh if (!$shape->isPlaceholder()) { // p:sp\p:spPr\a:xfrm $objWriter->startElement('a:xfrm'); - $objWriter->writeAttributeIf(0 != $shape->getRotation(), 'rot', CommonDrawing::degreesToAngle($shape->getRotation())); + $objWriter->writeAttributeIf(0 != $shape->getRotation(), 'rot', CommonDrawing::degreesToAngle((int) $shape->getRotation())); // p:sp\p:spPr\a:xfrm\a:off $objWriter->startElement('a:off'); $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX())); @@ -763,7 +765,7 @@ protected function writeShadow(XMLWriter $objWriter, Shadow $oShadow): void $objWriter->startElement('a:outerShdw'); $objWriter->writeAttribute('blurRad', CommonDrawing::pixelsToEmu($oShadow->getBlurRadius())); $objWriter->writeAttribute('dist', CommonDrawing::pixelsToEmu($oShadow->getDistance())); - $objWriter->writeAttribute('dir', CommonDrawing::degreesToAngle($oShadow->getDirection())); + $objWriter->writeAttribute('dir', CommonDrawing::degreesToAngle((int) $oShadow->getDirection())); $objWriter->writeAttribute('algn', $oShadow->getAlignment()); $objWriter->writeAttribute('rotWithShape', '0'); @@ -1116,7 +1118,7 @@ protected function writeShapeAutoShape(XMLWriter $objWriter, AutoShape $shape, i // p:sp\p:spPr\a:xfrm $objWriter->startElement('a:xfrm'); - $objWriter->writeAttributeIf($shape->getRotation() != 0, 'rot', CommonDrawing::degreesToAngle($shape->getRotation())); + $objWriter->writeAttributeIf($shape->getRotation() != 0, 'rot', CommonDrawing::degreesToAngle((int) $shape->getRotation())); // p:sp\p:spPr\a:xfrm\a:off $objWriter->startElement('a:off'); $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX())); @@ -1210,7 +1212,7 @@ protected function writeShapeChart(XMLWriter $objWriter, ShapeChart $shape, int $objWriter->endElement(); // p:xfrm $objWriter->startElement('p:xfrm'); - $objWriter->writeAttributeIf(0 != $shape->getRotation(), 'rot', CommonDrawing::degreesToAngle($shape->getRotation())); + $objWriter->writeAttributeIf(0 != $shape->getRotation(), 'rot', CommonDrawing::degreesToAngle((int) $shape->getRotation())); // a:off $objWriter->startElement('a:off'); $objWriter->writeAttribute('x', CommonDrawing::pixelsToEmu($shape->getOffsetX())); @@ -1377,7 +1379,7 @@ protected function writeShapePic(XMLWriter $objWriter, AbstractGraphic $shape, i $objWriter->startElement('p:spPr'); // a:xfrm $objWriter->startElement('a:xfrm'); - $objWriter->writeAttributeIf(0 != $shape->getRotation(), 'rot', CommonDrawing::degreesToAngle($shape->getRotation())); + $objWriter->writeAttributeIf(0 != $shape->getRotation(), 'rot', CommonDrawing::degreesToAngle((int) $shape->getRotation())); // a:off $objWriter->startElement('a:off'); diff --git a/src/PhpPresentation/Writer/PowerPoint2007/CommentAuthors.php b/src/PhpPresentation/Writer/PowerPoint2007/CommentAuthors.php index 437feba36..4471b612f 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/CommentAuthors.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/CommentAuthors.php @@ -1,4 +1,22 @@ writeAttribute('name', $customProperty); switch ($propertyType) { case DocumentProperties::PROPERTY_TYPE_INTEGER: - $objWriter->writeElement('vt:i4', $propertyValue); + $objWriter->writeElement('vt:i4', (string) $propertyValue); break; case DocumentProperties::PROPERTY_TYPE_FLOAT: - $objWriter->writeElement('vt:r8', $propertyValue); + $objWriter->writeElement('vt:r8', (string) $propertyValue); break; case DocumentProperties::PROPERTY_TYPE_BOOLEAN: - $objWriter->writeElement('vt:bool', ($propertyValue) ? 'true' : 'false'); + $objWriter->writeElement('vt:bool', $propertyValue ? 'true' : 'false'); break; case DocumentProperties::PROPERTY_TYPE_DATE: $objWriter->startElement('vt:filetime'); @@ -67,7 +85,7 @@ public function render() $objWriter->endElement(); break; default: - $objWriter->writeElement('vt:lpwstr', $propertyValue); + $objWriter->writeElement('vt:lpwstr', (string) $propertyValue); break; } $objWriter->endElement(); diff --git a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsThumbnail.php b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsThumbnail.php index f6dde3826..b9ec15199 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/DocPropsThumbnail.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/DocPropsThumbnail.php @@ -1,4 +1,22 @@ startElement('a:outerShdw'); $objWriter->writeAttribute('blurRad', CommonDrawing::pixelsToEmu($chart->getShadow()->getBlurRadius())); $objWriter->writeAttribute('dist', CommonDrawing::pixelsToEmu($chart->getShadow()->getDistance())); - $objWriter->writeAttribute('dir', CommonDrawing::degreesToAngle($chart->getShadow()->getDirection())); + $objWriter->writeAttribute('dir', CommonDrawing::degreesToAngle((int) $chart->getShadow()->getDirection())); $objWriter->writeAttribute('algn', $chart->getShadow()->getAlignment()); $objWriter->writeAttribute('rotWithShape', '0'); @@ -845,7 +863,7 @@ protected function writeTypeBar(XMLWriter $objWriter, Bar $subject, bool $includ $objWriter->startElement('c:dPt'); // c:idx - $this->writeElementWithValAttribute($objWriter, 'c:idx', $key); + $this->writeElementWithValAttribute($objWriter, 'c:idx', (string) $key); if (Fill::FILL_NONE != $value->getFillType()) { // c:spPr @@ -1058,7 +1076,7 @@ protected function writeTypeBar3D(XMLWriter $objWriter, Bar3D $subject, bool $in $objWriter->startElement('c:dPt'); // c:idx - $this->writeElementWithValAttribute($objWriter, 'c:idx', $key); + $this->writeElementWithValAttribute($objWriter, 'c:idx', (string) $key); if (Fill::FILL_NONE != $value->getFillType()) { // c:spPr @@ -1244,7 +1262,7 @@ protected function writeTypeDoughnut(XMLWriter $objWriter, Doughnut $subject, bo foreach ($dataPointFills as $key => $value) { // c:dPt $objWriter->startElement('c:dPt'); - $this->writeElementWithValAttribute($objWriter, 'c:idx', $key); + $this->writeElementWithValAttribute($objWriter, 'c:idx', (string) $key); // c:dPt/c:spPr $objWriter->startElement('c:spPr'); $this->writeFill($objWriter, $value); @@ -1403,7 +1421,7 @@ protected function writeTypePie(XMLWriter $objWriter, Pie $subject, bool $includ foreach ($dataPointFills as $key => $value) { // c:dPt $objWriter->startElement('c:dPt'); - $this->writeElementWithValAttribute($objWriter, 'c:idx', $key); + $this->writeElementWithValAttribute($objWriter, 'c:idx', (string) $key); // c:dPt/c:spPr $objWriter->startElement('c:spPr'); $this->writeFill($objWriter, $value); @@ -1573,7 +1591,7 @@ protected function writeTypePie3D(XMLWriter $objWriter, Pie3D $subject, bool $in foreach ($dataPointFills as $key => $value) { // c:dPt $objWriter->startElement('c:dPt'); - $this->writeElementWithValAttribute($objWriter, 'c:idx', $key); + $this->writeElementWithValAttribute($objWriter, 'c:idx', (string) $key); // c:dPt/c:spPr $objWriter->startElement('c:spPr'); $this->writeFill($objWriter, $value); @@ -2362,7 +2380,7 @@ protected function writeAxis(XMLWriter $objWriter, Chart\Axis $oAxis, string $ty // a:bodyPr $objWriter->startElement('a:bodyPr'); - $objWriter->writeAttributeIf($oAxis->getTitleRotation() != 0, 'rot', CommonDrawing::degreesToAngle($oAxis->getTitleRotation())); + $objWriter->writeAttributeIf($oAxis->getTitleRotation() != 0, 'rot', CommonDrawing::degreesToAngle((int) $oAxis->getTitleRotation())); $objWriter->endElement(); // a:lstStyle diff --git a/src/PhpPresentation/Writer/PowerPoint2007/PptComments.php b/src/PhpPresentation/Writer/PowerPoint2007/PptComments.php index 0bae8b149..060fec0bf 100644 --- a/src/PhpPresentation/Writer/PowerPoint2007/PptComments.php +++ b/src/PhpPresentation/Writer/PowerPoint2007/PptComments.php @@ -1,4 +1,22 @@ expectException(\Exception::class); $this->expectExceptionMessage('"" is not a valid reader'); - IOFactory::createReader(); + IOFactory::createReader(''); } public function testLoad(): void diff --git a/tests/PhpPresentation/Tests/PhpPresentationTest.php b/tests/PhpPresentation/Tests/PhpPresentationTest.php index 83232f0f8..8d5acc2a0 100644 --- a/tests/PhpPresentation/Tests/PhpPresentationTest.php +++ b/tests/PhpPresentation/Tests/PhpPresentationTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests; use PhpOffice\PhpPresentation\DocumentLayout; diff --git a/tests/PhpPresentation/Tests/PresentationPropertiesTest.php b/tests/PhpPresentation/Tests/PresentationPropertiesTest.php index 8a076b7f1..56d88f5d4 100644 --- a/tests/PhpPresentation/Tests/PresentationPropertiesTest.php +++ b/tests/PhpPresentation/Tests/PresentationPropertiesTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests; use PhpOffice\PhpPresentation\PresentationProperties; diff --git a/tests/PhpPresentation/Tests/Reader/ODPresentationTest.php b/tests/PhpPresentation/Tests/Reader/ODPresentationTest.php index 235cdc9b9..ddbfdf03f 100644 --- a/tests/PhpPresentation/Tests/Reader/ODPresentationTest.php +++ b/tests/PhpPresentation/Tests/Reader/ODPresentationTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Reader; use PhpOffice\PhpPresentation\PresentationProperties; diff --git a/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php b/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php index 45eb67bd4..57c5133ec 100644 --- a/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php +++ b/tests/PhpPresentation/Tests/Reader/PowerPoint2007Test.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Reader; use PhpOffice\PhpPresentation\DocumentLayout; diff --git a/tests/PhpPresentation/Tests/Reader/PowerPoint97Test.php b/tests/PhpPresentation/Tests/Reader/PowerPoint97Test.php index 86bb14280..87c9c403c 100644 --- a/tests/PhpPresentation/Tests/Reader/PowerPoint97Test.php +++ b/tests/PhpPresentation/Tests/Reader/PowerPoint97Test.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Reader; use PhpOffice\PhpPresentation\Reader\PowerPoint97; diff --git a/tests/PhpPresentation/Tests/Reader/SerializedTest.php b/tests/PhpPresentation/Tests/Reader/SerializedTest.php index 164b5debf..f1d057cd0 100644 --- a/tests/PhpPresentation/Tests/Reader/SerializedTest.php +++ b/tests/PhpPresentation/Tests/Reader/SerializedTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Reader; use PhpOffice\PhpPresentation\Reader\Serialized; diff --git a/tests/PhpPresentation/Tests/Shape/AbstractGraphicTest.php b/tests/PhpPresentation/Tests/Shape/AbstractGraphicTest.php index 2428f8c79..54d6cf41e 100644 --- a/tests/PhpPresentation/Tests/Shape/AbstractGraphicTest.php +++ b/tests/PhpPresentation/Tests/Shape/AbstractGraphicTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Shape; use PhpOffice\PhpPresentation\Shape\AbstractGraphic; diff --git a/tests/PhpPresentation/Tests/Shape/AutoShapeTest.php b/tests/PhpPresentation/Tests/Shape/AutoShapeTest.php index dbeea6713..9e235e2df 100644 --- a/tests/PhpPresentation/Tests/Shape/AutoShapeTest.php +++ b/tests/PhpPresentation/Tests/Shape/AutoShapeTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Shape; use PhpOffice\PhpPresentation\Shape\AutoShape; diff --git a/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php b/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php index 7ae33da24..8696d3874 100644 --- a/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php +++ b/tests/PhpPresentation/Tests/Shape/Chart/AxisTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Shape\Chart; use PhpOffice\PhpPresentation\Shape\Chart\Axis; diff --git a/tests/PhpPresentation/Tests/Shape/Chart/GridlinesTest.php b/tests/PhpPresentation/Tests/Shape/Chart/GridlinesTest.php index d7e725cfb..fe0e96451 100644 --- a/tests/PhpPresentation/Tests/Shape/Chart/GridlinesTest.php +++ b/tests/PhpPresentation/Tests/Shape/Chart/GridlinesTest.php @@ -1,4 +1,22 @@ assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB()); $this->assertEquals(100, $object->getAlpha()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB('AA0000FF')); - $this->assertEquals(66.67, $object->getAlpha()); + $this->assertEquals(67, $object->getAlpha()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setARGB(Color::COLOR_BLUE)); $this->assertEquals(100, $object->getAlpha()); $this->assertInstanceOf('PhpOffice\\PhpPresentation\\Style\\Color', $object->setAlpha($randAlpha)); diff --git a/tests/PhpPresentation/Tests/Style/FillTest.php b/tests/PhpPresentation/Tests/Style/FillTest.php index 8e9e88571..2ac5eb183 100644 --- a/tests/PhpPresentation/Tests/Style/FillTest.php +++ b/tests/PhpPresentation/Tests/Style/FillTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Style; use PhpOffice\PhpPresentation\Style\Color; diff --git a/tests/PhpPresentation/Tests/Style/FontTest.php b/tests/PhpPresentation/Tests/Style/FontTest.php index 0952f5459..47deb3f0b 100644 --- a/tests/PhpPresentation/Tests/Style/FontTest.php +++ b/tests/PhpPresentation/Tests/Style/FontTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Style; use PhpOffice\PhpPresentation\Style\Color; diff --git a/tests/PhpPresentation/Tests/Style/OutlineTest.php b/tests/PhpPresentation/Tests/Style/OutlineTest.php index 48632922d..30411f12b 100644 --- a/tests/PhpPresentation/Tests/Style/OutlineTest.php +++ b/tests/PhpPresentation/Tests/Style/OutlineTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Style; use PhpOffice\PhpPresentation\Style\Fill; diff --git a/tests/PhpPresentation/Tests/Style/ShadowTest.php b/tests/PhpPresentation/Tests/Style/ShadowTest.php index 2336bb70e..ec2286982 100644 --- a/tests/PhpPresentation/Tests/Style/ShadowTest.php +++ b/tests/PhpPresentation/Tests/Style/ShadowTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Style; use PhpOffice\PhpPresentation\Style\Color; diff --git a/tests/PhpPresentation/Tests/Style/TextStyleTest.php b/tests/PhpPresentation/Tests/Style/TextStyleTest.php index d84f7d771..b85da8f1f 100644 --- a/tests/PhpPresentation/Tests/Style/TextStyleTest.php +++ b/tests/PhpPresentation/Tests/Style/TextStyleTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Style; use PhpOffice\PhpPresentation\Shape\RichText\Paragraph; diff --git a/tests/PhpPresentation/Tests/Writer/AbstractWriter.php b/tests/PhpPresentation/Tests/Writer/AbstractWriter.php index b0f348eab..7da382b97 100644 --- a/tests/PhpPresentation/Tests/Writer/AbstractWriter.php +++ b/tests/PhpPresentation/Tests/Writer/AbstractWriter.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * - * @copyright 2009-2017 PHPPresentation contributors - * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * * @see https://github.com/PHPOffice/PHPPresentation + * + * @copyright 2009-2015 PHPPresentation contributors + * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Writer; use PhpOffice\PhpPresentation\AbstractShape; diff --git a/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php b/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php index 5b2fda6f4..101ed117c 100644 --- a/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php +++ b/tests/PhpPresentation/Tests/Writer/AbstractWriterTest.php @@ -10,12 +10,14 @@ * file that was distributed with this source code. For the full list of * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. * + * @see https://github.com/PHPOffice/PHPPresentation + * * @copyright 2009-2015 PHPPresentation contributors * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 - * - * @see https://github.com/PHPOffice/PHPPresentation */ +declare(strict_types=1); + namespace PhpOffice\PhpPresentation\Tests\Writer; use PhpOffice\Common\Adapter\Zip\ZipInterface; diff --git a/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php b/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php index 1b8e093dd..c67a78bc9 100644 --- a/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php +++ b/tests/PhpPresentation/Tests/Writer/ODPresentation/ContentTest.php @@ -1,4 +1,22 @@ setOffsetY($expectedY); $this->oPresentation->getActiveSlide()->addShape($oMedia); - $expectedWidth = Text::numberFormat(CommonDrawing::pixelsToCentimeters($expectedWidth), 3) . 'cm'; - $expectedHeight = Text::numberFormat(CommonDrawing::pixelsToCentimeters($expectedHeight), 3) . 'cm'; - $expectedX = Text::numberFormat(CommonDrawing::pixelsToCentimeters($expectedX), 3) . 'cm'; - $expectedY = Text::numberFormat(CommonDrawing::pixelsToCentimeters($expectedY), 3) . 'cm'; + $expectedWidth = Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $expectedWidth), 3) . 'cm'; + $expectedHeight = Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $expectedHeight), 3) . 'cm'; + $expectedX = Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $expectedX), 3) . 'cm'; + $expectedY = Text::numberFormat(CommonDrawing::pixelsToCentimeters((int) $expectedY), 3) . 'cm'; $element = '/office:document-content/office:body/office:presentation/draw:page/draw:frame'; $this->assertZipXmlElementExists('content.xml', $element); @@ -512,9 +530,9 @@ public function testRichTextShadow(): void $this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-x', '0cm'); } else { if ($inc > 90 && $inc < 270) { - $this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-x', '-' . Drawing::pixelsToCentimeters($randDistance) . 'cm'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-x', '-' . Drawing::pixelsToCentimeters((int) $randDistance) . 'cm'); } else { - $this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-x', Drawing::pixelsToCentimeters($randDistance) . 'cm'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-x', Drawing::pixelsToCentimeters((int) $randDistance) . 'cm'); } } // Y @@ -522,9 +540,9 @@ public function testRichTextShadow(): void $this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-y', '0cm'); } else { if (($inc > 0 && $inc < 180) || 360 == $inc) { - $this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-y', Drawing::pixelsToCentimeters($randDistance) . 'cm'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-y', Drawing::pixelsToCentimeters((int) $randDistance) . 'cm'); } else { - $this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-y', '-' . Drawing::pixelsToCentimeters($randDistance) . 'cm'); + $this->assertZipXmlAttributeEquals('content.xml', $element, 'draw:shadow-offset-y', '-' . Drawing::pixelsToCentimeters((int) $randDistance) . 'cm'); } } $this->assertIsSchemaOpenDocumentValid('1.2'); diff --git a/tests/PhpPresentation/Tests/Writer/ODPresentation/MetaInfManifestTest.php b/tests/PhpPresentation/Tests/Writer/ODPresentation/MetaInfManifestTest.php index 88a5326c1..be0019b23 100644 --- a/tests/PhpPresentation/Tests/Writer/ODPresentation/MetaInfManifestTest.php +++ b/tests/PhpPresentation/Tests/Writer/ODPresentation/MetaInfManifestTest.php @@ -1,4 +1,22 @@ assertZipXmlElementExists($pathShape, $element); $this->assertZipXmlAttributeExists($pathShape, $element, 'rot'); - $this->assertZipXmlAttributeEquals($pathShape, $element, 'rot', Drawing::degreesToAngle($value)); + $this->assertZipXmlAttributeEquals($pathShape, $element, 'rot', Drawing::degreesToAngle((int) $value)); } public function testAxisVisibility(): void diff --git a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptCommentsTest.php b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptCommentsTest.php index 3e202c61d..8c67c8ac7 100644 --- a/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptCommentsTest.php +++ b/tests/PhpPresentation/Tests/Writer/PowerPoint2007/PptCommentsTest.php @@ -1,4 +1,22 @@