diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index 2511058279..531ee24544 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -46,6 +46,7 @@ public static function emuToPixels($pValue = 0) if ($pValue == 0) { return 0; } + return round($pValue / 9525); } @@ -71,9 +72,10 @@ public static function pointsToCentimeters($pValue = 0) if ($pValue == 0) { return 0; } - return ((($pValue * 1.333333333) / self::DPI_96) * 2.54); + + return (($pValue * 1.333333333) / self::DPI_96) * 2.54; } - + /** * Convert points width to pixels * @@ -85,6 +87,7 @@ public static function pointsToPixels($pValue = 0) if ($pValue == 0) { return 0; } + return $pValue * 1.333333333; } @@ -97,7 +100,7 @@ public static function pointsToPixels($pValue = 0) public static function pixelsToCentimeters($pValue = 0) { //return $pValue * 0.028; - return (($pValue / self::DPI_96) * 2.54); + return ($pValue / self::DPI_96) * 2.54; } /** @@ -111,6 +114,7 @@ public static function centimetersToPixels($pValue = 0) if ($pValue == 0) { return 0; } + return ($pValue / 2.54) * self::DPI_96; } @@ -136,13 +140,14 @@ public static function angleToDegrees($pValue = 0) if ($pValue == 0) { return 0; } + return round($pValue / 60000); } /** * Convert centimeters width to twips * - * @param integer $pValue + * @param int $pValue * @return float */ public static function centimetersToTwips($pValue = 0) @@ -150,13 +155,14 @@ public static function centimetersToTwips($pValue = 0) if ($pValue == 0) { return 0; } + return $pValue * 566.928; } /** * Convert twips width to centimeters * - * @param integer $pValue + * @param int $pValue * @return float */ public static function twipsToCentimeters($pValue = 0) @@ -164,13 +170,14 @@ public static function twipsToCentimeters($pValue = 0) if ($pValue == 0) { return 0; } + return $pValue / 566.928; } /** * Convert inches width to twips * - * @param integer $pValue + * @param int $pValue * @return float */ public static function inchesToTwips($pValue = 0) @@ -178,13 +185,14 @@ public static function inchesToTwips($pValue = 0) if ($pValue == 0) { return 0; } + return $pValue * 1440; } /** * Convert twips width to inches * - * @param integer $pValue + * @param int $pValue * @return float */ public static function twipsToInches($pValue = 0) @@ -192,13 +200,14 @@ public static function twipsToInches($pValue = 0) if ($pValue == 0) { return 0; } + return $pValue / 1440; } /** * Convert twips width to pixels * - * @param integer $pValue + * @param int $pValue * @return float */ public static function twipsToPixels($pValue = 0) @@ -206,6 +215,7 @@ public static function twipsToPixels($pValue = 0) if ($pValue == 0) { return 0; } + return round($pValue / 15.873984); } diff --git a/src/PhpWord/Shared/Text.php b/src/PhpWord/Shared/Text.php index b9bea3ad6c..c4a1ad620f 100644 --- a/src/PhpWord/Shared/Text.php +++ b/src/PhpWord/Shared/Text.php @@ -36,8 +36,8 @@ private static function buildControlCharacters() { for ($i = 0; $i <= 19; ++$i) { if ($i != 9 && $i != 10 && $i != 13) { - $find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_'; - $replace = chr($i); + $find = '_x' . sprintf('%04s', strtoupper(dechex($i))) . '_'; + $replace = chr($i); self::$controlCharacters[$find] = $replace; } } @@ -69,7 +69,7 @@ public static function controlCharacterPHP2OOXML($value = '') /** * Return a number formatted for being integrated in xml files * @param float $number - * @param integer $decimals + * @param int $decimals * @return string */ public static function numberFormat($number, $decimals) @@ -79,24 +79,25 @@ public static function numberFormat($number, $decimals) /** * @param int $dec - * @link http://stackoverflow.com/a/7153133/2235790 + * @see http://stackoverflow.com/a/7153133/2235790 * @author velcrow * @return string */ public static function chr($dec) { - if ($dec<=0x7F) { + if ($dec <= 0x7F) { return chr($dec); } - if ($dec<=0x7FF) { - return chr(($dec>>6)+192).chr(($dec&63)+128); + if ($dec <= 0x7FF) { + return chr(($dec >> 6) + 192) . chr(($dec & 63) + 128); } - if ($dec<=0xFFFF) { - return chr(($dec>>12)+224).chr((($dec>>6)&63)+128).chr(($dec&63)+128); + if ($dec <= 0xFFFF) { + return chr(($dec >> 12) + 224) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128); } - if ($dec<=0x1FFFFF) { - return chr(($dec>>18)+240).chr((($dec>>12)&63)+128).chr((($dec>>6)&63)+128).chr(($dec&63)+128); + if ($dec <= 0x1FFFFF) { + return chr(($dec >> 18) + 240) . chr((($dec >> 12) & 63) + 128) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128); } + return ''; } @@ -119,7 +120,7 @@ public static function controlCharacterOOXML2PHP($value = '') * Check if a string contains UTF-8 data * * @param string $value - * @return boolean + * @return bool */ public static function isUTF8($value = '') { @@ -161,7 +162,7 @@ public static function toUnicode($text) * @param string $text UTF8 text * @return array * @since 0.11.0 - * @link http://www.randomchaos.com/documents/?source=php_and_unicode + * @see http://www.randomchaos.com/documents/?source=php_and_unicode */ public static function utf8ToUnicode($text) { @@ -201,7 +202,7 @@ public static function utf8ToUnicode($text) * @param array $unicode * @return string * @since 0.11.0 - * @link http://www.randomchaos.com/documents/?source=php_and_unicode + * @see http://www.randomchaos.com/documents/?source=php_and_unicode */ private static function unicodeToEntities($unicode) { diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php index ca5cb558a9..3905c52f19 100644 --- a/src/PhpWord/Shared/XMLReader.php +++ b/src/PhpWord/Shared/XMLReader.php @@ -43,8 +43,8 @@ class XMLReader * * @param string $zipFile * @param string $xmlFile - * @return \DOMDocument|false * @throws \Exception + * @return \DOMDocument|false */ public function getDomFromZip($zipFile, $xmlFile) { @@ -112,8 +112,8 @@ public function getElements($path, \DOMElement $contextNode = null) * * @param string $prefix The prefix * @param string $namespaceURI The URI of the namespace - * @return bool true on success or false on failure * @throws \InvalidArgumentException If called before having loaded the DOM document + * @return bool true on success or false on failure */ public function registerNamespace($prefix, $namespaceURI) { @@ -123,6 +123,7 @@ public function registerNamespace($prefix, $namespaceURI) if ($this->xpath === null) { $this->xpath = new \DOMXpath($this->dom); } + return $this->xpath->registerNamespace($prefix, $namespaceURI); } @@ -192,7 +193,7 @@ public function getValue($path, \DOMElement $contextNode = null) * * @param string $path * @param \DOMElement $contextNode - * @return integer + * @return int */ public function countElements($path, \DOMElement $contextNode = null) { @@ -206,7 +207,7 @@ public function countElements($path, \DOMElement $contextNode = null) * * @param string $path * @param \DOMElement $contextNode - * @return boolean + * @return bool */ public function elementExists($path, \DOMElement $contextNode = null) { diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index 1d825dec1b..930ad62ee1 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -88,7 +88,7 @@ public function __destruct() return; } 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.'); } } @@ -104,10 +104,10 @@ public function getData() } $this->flush(); + return file_get_contents($this->tempFileName); } - /** * Write simple element and attribute(s) block * @@ -118,7 +118,6 @@ public function getData() * @param string $element * @param string|array $attributes * @param string $value - * @return void */ public function writeElementBlock($element, $attributes, $value = null) { @@ -139,7 +138,6 @@ public function writeElementBlock($element, $attributes, $value = null) * @param string $element * @param string $attribute * @param mixed $value - * @return void */ public function writeElementIf($condition, $element, $attribute = null, $value = null) { @@ -160,7 +158,6 @@ public function writeElementIf($condition, $element, $attribute = null, $value = * @param bool $condition * @param string $attribute * @param mixed $value - * @return void */ public function writeAttributeIf($condition, $attribute, $value) { @@ -179,6 +176,7 @@ public function writeAttribute($name, $value) if (is_float($value)) { $value = json_encode($value); } + return parent::writeAttribute($name, $value); } } diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php index 103e155636..fa8d8e6580 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php @@ -17,13 +17,13 @@ namespace PhpOffice\PhpWord; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Escaper\RegExp; use PhpOffice\PhpWord\Escaper\Xml; use PhpOffice\PhpWord\Exception\CopyFileException; use PhpOffice\PhpWord\Exception\CreateTemporaryFileException; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Shared\Text; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Shared\ZipArchive; class TemplateProcessor diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php index 19f5ac9620..adcf8ab4e3 100644 --- a/src/PhpWord/Writer/ODText/Element/Table.php +++ b/src/PhpWord/Writer/ODText/Element/Table.php @@ -17,9 +17,9 @@ namespace PhpOffice\PhpWord\Writer\ODText\Element; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\Row as RowElement; use PhpOffice\PhpWord\Element\Table as TableElement; +use PhpOffice\PhpWord\Shared\XMLWriter; /** * Table element writer diff --git a/src/PhpWord/Writer/ODText/Part/AbstractPart.php b/src/PhpWord/Writer/ODText/Part/AbstractPart.php index 67b7a7aeb2..4a7ace78ca 100644 --- a/src/PhpWord/Writer/ODText/Part/AbstractPart.php +++ b/src/PhpWord/Writer/ODText/Part/AbstractPart.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\ODText\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Settings; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Writer\Word2007\Part\AbstractPart as Word2007AbstractPart; diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php index 4a84896dae..b6a1c95e65 100644 --- a/src/PhpWord/Writer/ODText/Part/Content.php +++ b/src/PhpWord/Writer/ODText/Part/Content.php @@ -17,7 +17,6 @@ namespace PhpOffice\PhpWord\Writer\ODText\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\AbstractContainer; use PhpOffice\PhpWord\Element\Field; use PhpOffice\PhpWord\Element\Image; @@ -26,6 +25,7 @@ use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Element\TrackChange; use PhpOffice\PhpWord\PhpWord; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; diff --git a/src/PhpWord/Writer/ODText/Part/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php index c026e7bbc9..befd23a2ac 100644 --- a/src/PhpWord/Writer/ODText/Part/Styles.php +++ b/src/PhpWord/Writer/ODText/Part/Styles.php @@ -17,9 +17,9 @@ namespace PhpOffice\PhpWord\Writer\ODText\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Shared\Converter; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style; /** diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php index d4ec0f7d71..ee0fb2f901 100644 --- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php +++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php @@ -17,10 +17,10 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\AbstractElement as Element; use PhpOffice\PhpWord\Settings; use PhpOffice\PhpWord\Shared\Text as SharedText; +use PhpOffice\PhpWord\Shared\XMLWriter; /** * Abstract element writer diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php index 8a6aa80511..0a39403d67 100644 --- a/src/PhpWord/Writer/Word2007/Element/Container.php +++ b/src/PhpWord/Writer/Word2007/Element/Container.php @@ -17,10 +17,10 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\AbstractContainer as ContainerElement; use PhpOffice\PhpWord\Element\AbstractElement as Element; use PhpOffice\PhpWord\Element\TextBreak as TextBreakElement; +use PhpOffice\PhpWord\Shared\XMLWriter; /** * Container element writer (section, textrun, header, footnote, cell, etc.) diff --git a/src/PhpWord/Writer/Word2007/Element/FormField.php b/src/PhpWord/Writer/Word2007/Element/FormField.php index e1754d0f28..7206386431 100644 --- a/src/PhpWord/Writer/Word2007/Element/FormField.php +++ b/src/PhpWord/Writer/Word2007/Element/FormField.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\FormField as FormFieldElement; +use PhpOffice\PhpWord\Shared\XMLWriter; /** * FormField element writer diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php index 8fc4849d25..f136ba0b6c 100644 --- a/src/PhpWord/Writer/Word2007/Element/Image.php +++ b/src/PhpWord/Writer/Word2007/Element/Image.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\Image as ImageElement; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Font as FontStyle; use PhpOffice\PhpWord\Style\Frame as FrameStyle; use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Element/SDT.php b/src/PhpWord/Writer/Word2007/Element/SDT.php index e2d0d36841..e496424253 100644 --- a/src/PhpWord/Writer/Word2007/Element/SDT.php +++ b/src/PhpWord/Writer/Word2007/Element/SDT.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\SDT as SDTElement; +use PhpOffice\PhpWord\Shared\XMLWriter; /** * Structured document tag element writer diff --git a/src/PhpWord/Writer/Word2007/Element/Shape.php b/src/PhpWord/Writer/Word2007/Element/Shape.php index 445be7e46f..ef30c48436 100644 --- a/src/PhpWord/Writer/Word2007/Element/Shape.php +++ b/src/PhpWord/Writer/Word2007/Element/Shape.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\Shape as ShapeElement; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Shape as ShapeStyle; use PhpOffice\PhpWord\Writer\Word2007\Style\Shape as ShapeStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php index 78989f818b..3dac76fb4d 100644 --- a/src/PhpWord/Writer/Word2007/Element/TOC.php +++ b/src/PhpWord/Writer/Word2007/Element/TOC.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\TOC as TOCElement; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Writer\Word2007\Style\Font as FontStyleWriter; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php index 4067868d1a..25a44fb11a 100644 --- a/src/PhpWord/Writer/Word2007/Element/Table.php +++ b/src/PhpWord/Writer/Word2007/Element/Table.php @@ -17,10 +17,10 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Element; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\Cell as CellElement; use PhpOffice\PhpWord\Element\Row as RowElement; use PhpOffice\PhpWord\Element\Table as TableElement; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Style\Cell as CellStyle; use PhpOffice\PhpWord\Style\Row as RowStyle; use PhpOffice\PhpWord\Writer\Word2007\Style\Cell as CellStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php index e14b394e6b..4bee5c542a 100644 --- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php +++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php @@ -17,9 +17,9 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Exception\Exception; use PhpOffice\PhpWord\Settings; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Writer\AbstractWriter; /** diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php index e413d2735d..8907160b22 100644 --- a/src/PhpWord/Writer/Word2007/Part/Chart.php +++ b/src/PhpWord/Writer/Word2007/Part/Chart.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\Chart as ChartElement; +use PhpOffice\PhpWord\Shared\XMLWriter; /** * Word2007 chart part writer: word/charts/chartx.xml diff --git a/src/PhpWord/Writer/Word2007/Part/Comments.php b/src/PhpWord/Writer/Word2007/Part/Comments.php index 6bff63ee6d..5b867324cb 100644 --- a/src/PhpWord/Writer/Word2007/Part/Comments.php +++ b/src/PhpWord/Writer/Word2007/Part/Comments.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\Comment; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Writer\Word2007\Element\Container; /** diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php index 09ef13f01e..d2ab836b7e 100644 --- a/src/PhpWord/Writer/Word2007/Part/Document.php +++ b/src/PhpWord/Writer/Word2007/Part/Document.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\Section; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Writer\Word2007\Element\Container; use PhpOffice\PhpWord\Writer\Word2007\Style\Section as SectionStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php index 34bf737b1d..58c2e9b170 100644 --- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php +++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\Footnote; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Writer\Word2007\Element\Container; use PhpOffice\PhpWord\Writer\Word2007\Style\Paragraph as ParagraphStyleWriter; diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php index 0a3f934e2b..70f632f7f3 100644 --- a/src/PhpWord/Writer/Word2007/Part/Rels.php +++ b/src/PhpWord/Writer/Word2007/Part/Rels.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Part; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Exception\Exception; +use PhpOffice\PhpWord\Shared\XMLWriter; /** * Word2007 main relationship writer: _rels/.rels diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php index 7e17fbe76f..3624a7bef2 100644 --- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php +++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php @@ -17,8 +17,8 @@ namespace PhpOffice\PhpWord\Writer\Word2007\Style; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Settings; +use PhpOffice\PhpWord\Shared\XMLWriter; /** * Style writer diff --git a/tests/PhpWord/Shared/DrawingTest.php b/tests/PhpWord/Shared/DrawingTest.php index 906a32ce62..b7110923d3 100644 --- a/tests/PhpWord/Shared/DrawingTest.php +++ b/tests/PhpWord/Shared/DrawingTest.php @@ -20,12 +20,10 @@ /** * Test class for PhpOffice\PhpWord\Shared\Drawing * - * @coversDefaultClass PhpOffice\PhpWord\Shared\Drawing + * @coversDefaultClass \PhpOffice\PhpWord\Shared\Drawing */ class DrawingTest extends \PHPUnit\Framework\TestCase { - /** - */ public function testDegreesAngle() { $value = rand(1, 100); @@ -36,8 +34,6 @@ public function testDegreesAngle() $this->assertEquals(round($value / 60000), Drawing::angleToDegrees($value)); } - /** - */ public function testPixelsCentimeters() { $value = rand(1, 100); @@ -48,32 +44,26 @@ public function testPixelsCentimeters() $this->assertEquals($value / 2.54 * Drawing::DPI_96, Drawing::centimetersToPixels($value)); } - /** - */ public function testPixelsEMU() { $value = rand(1, 100); $this->assertEquals(0, Drawing::pixelsToEmu()); - $this->assertEquals(round($value*9525), Drawing::pixelsToEmu($value)); + $this->assertEquals(round($value * 9525), Drawing::pixelsToEmu($value)); $this->assertEquals(0, Drawing::emuToPixels()); - $this->assertEquals(round($value/9525), Drawing::emuToPixels($value)); + $this->assertEquals(round($value / 9525), Drawing::emuToPixels($value)); } - /** - */ public function testPixelsPoints() { $value = rand(1, 100); $this->assertEquals(0, Drawing::pixelsToPoints()); - $this->assertEquals($value*0.67777777, Drawing::pixelsToPoints($value)); + $this->assertEquals($value * 0.67777777, Drawing::pixelsToPoints($value)); $this->assertEquals(0, Drawing::pointsToPixels()); - $this->assertEquals($value* 1.333333333, Drawing::pointsToPixels($value)); + $this->assertEquals($value * 1.333333333, Drawing::pointsToPixels($value)); } - /** - */ public function testPointsCentimeters() { $value = rand(1, 100); @@ -82,8 +72,6 @@ public function testPointsCentimeters() $this->assertEquals($value * 1.333333333 / Drawing::DPI_96 * 2.54, Drawing::pointsToCentimeters($value)); } - /** - */ public function testTwips() { $value = rand(1, 100); diff --git a/tests/PhpWord/Shared/TextTest.php b/tests/PhpWord/Shared/TextTest.php index ded00e9614..6df19b1250 100644 --- a/tests/PhpWord/Shared/TextTest.php +++ b/tests/PhpWord/Shared/TextTest.php @@ -20,12 +20,10 @@ /** * Test class for Text * - * @coversDefaultClass PhpOffice\PhpWord\Shared\Text + * @coversDefaultClass \PhpOffice\PhpWord\Shared\Text */ class TextTest extends \PHPUnit\Framework\TestCase { - /** - */ public function testControlCharacters() { $this->assertEquals('', Text::controlCharacterPHP2OOXML()); @@ -33,7 +31,7 @@ public function testControlCharacters() $this->assertEquals('àéîöù', Text::controlCharacterPHP2OOXML('àéîöù')); $value = rand(0, 8); - $this->assertEquals('_x'.sprintf('%04s', strtoupper(dechex($value))).'_', Text::controlCharacterPHP2OOXML(chr($value))); + $this->assertEquals('_x' . sprintf('%04s', strtoupper(dechex($value))) . '_', Text::controlCharacterPHP2OOXML(chr($value))); $this->assertEquals('', Text::controlCharacterOOXML2PHP('')); $this->assertEquals(chr(0x08), Text::controlCharacterOOXML2PHP('_x0008_')); @@ -58,6 +56,7 @@ public function testChr() $this->assertEquals('🌃', Text::chr(0x1F303)); $this->assertEquals('', Text::chr(2097152)); } + /** * Is UTF8 */ diff --git a/tests/PhpWord/Shared/XMLReaderTest.php b/tests/PhpWord/Shared/XMLReaderTest.php index a34d650af1..4d0ee64ca7 100644 --- a/tests/PhpWord/Shared/XMLReaderTest.php +++ b/tests/PhpWord/Shared/XMLReaderTest.php @@ -20,7 +20,7 @@ /** * Test class for XMLReader * - * @coversDefaultClass PhpOffice\PhpWord\Shared\XMLReader + * @coversDefaultClass \PhpOffice\PhpWord\Shared\XMLReader */ class XMLReaderTest extends \PHPUnit\Framework\TestCase { @@ -57,7 +57,7 @@ public function testDomFromZip() /** * Test that read from non existing archive throws exception * - * @expectedException Exception + * @expectedException \Exception */ public function testThrowsExceptionOnNonExistingArchive() { @@ -124,7 +124,7 @@ public function testShouldParseXmlWithCustomNamespace() /** * Test that xpath fails if custom namespace is not registered * - * @expectedException InvalidArgumentException + * @expectedException \InvalidArgumentException */ public function testShouldThowExceptionIfTryingToRegisterNamespaceBeforeReadingDoc() { diff --git a/tests/PhpWord/Shared/XMLWriterTest.php b/tests/PhpWord/Shared/XMLWriterTest.php index 843ae7167b..e86cd50b02 100644 --- a/tests/PhpWord/Shared/XMLWriterTest.php +++ b/tests/PhpWord/Shared/XMLWriterTest.php @@ -24,23 +24,21 @@ */ class XMLWriterTest extends \PHPUnit\Framework\TestCase { - /** - */ public function testConstruct() { // Memory $object = new XMLWriter(); $object->startElement('element'); - $object->text('AAA'); + $object->text('AAA'); $object->endElement(); - $this->assertEquals('AAA'.chr(10), $object->getData()); + $this->assertEquals('AAA' . chr(10), $object->getData()); // Disk $object = new XMLWriter(XMLWriter::STORAGE_DISK); $object->startElement('element'); - $object->text('BBB'); + $object->text('BBB'); $object->endElement(); - $this->assertEquals('BBB'.chr(10), $object->getData()); + $this->assertEquals('BBB' . chr(10), $object->getData()); } public function testWriteAttribute() diff --git a/tests/PhpWord/Writer/Word2007/ElementTest.php b/tests/PhpWord/Writer/Word2007/ElementTest.php index 8193b3db2c..38b1ba75ab 100644 --- a/tests/PhpWord/Writer/Word2007/ElementTest.php +++ b/tests/PhpWord/Writer/Word2007/ElementTest.php @@ -17,11 +17,11 @@ namespace PhpOffice\PhpWord\Writer\Word2007; -use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\Element\Comment; use PhpOffice\PhpWord\Element\TextRun; use PhpOffice\PhpWord\Element\TrackChange; use PhpOffice\PhpWord\PhpWord; +use PhpOffice\PhpWord\Shared\XMLWriter; use PhpOffice\PhpWord\TestHelperDOCX; /**