$styles['bgColor'] = trim($val, '# ');
+
break;
case 'valign':
// cells e.g.
if (preg_match('#(?:top|bottom|middle|baseline)#i', $val, $matches)) {
$styles['valign'] = self::mapAlignVertical($matches[0]);
}
+
break;
}
}
@@ -148,71 +160,71 @@ protected static function parseInlineStyle($node, $styles = array())
/**
* Parse a node and add a corresponding element to the parent element.
*
- * @param \DOMNode $node node to parse
+ * @param DOMNode $node node to parse
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element object to add an element corresponding with the node
* @param array $styles Array with all styles
* @param array $data Array to transport data to a next level in the DOM tree, for example level of listitems
*/
- protected static function parseNode($node, $element, $styles = array(), $data = array())
+ protected static function parseNode($node, $element, $styles = [], $data = []): void
{
// Populate styles array
- $styleTypes = array('font', 'paragraph', 'list', 'table', 'row', 'cell');
+ $styleTypes = ['font', 'paragraph', 'list', 'table', 'row', 'cell'];
foreach ($styleTypes as $styleType) {
if (!isset($styles[$styleType])) {
- $styles[$styleType] = array();
+ $styles[$styleType] = [];
}
}
// Node mapping table
- $nodes = array(
- // $method $node $element $styles $data $argument1 $argument2
- 'p' => array('Paragraph', $node, $element, $styles, null, null, null),
- 'h1' => array('Heading', null, $element, $styles, null, 'Heading1', null),
- 'h2' => array('Heading', null, $element, $styles, null, 'Heading2', null),
- 'h3' => array('Heading', null, $element, $styles, null, 'Heading3', null),
- 'h4' => array('Heading', null, $element, $styles, null, 'Heading4', null),
- 'h5' => array('Heading', null, $element, $styles, null, 'Heading5', null),
- 'h6' => array('Heading', null, $element, $styles, null, 'Heading6', null),
- '#text' => array('Text', $node, $element, $styles, null, null, null),
- 'strong' => array('Property', null, null, $styles, null, 'bold', true),
- 'b' => array('Property', null, null, $styles, null, 'bold', true),
- 'em' => array('Property', null, null, $styles, null, 'italic', true),
- 'i' => array('Property', null, null, $styles, null, 'italic', true),
- 'u' => array('Property', null, null, $styles, null, 'underline', 'single'),
- 'sup' => array('Property', null, null, $styles, null, 'superScript', true),
- 'sub' => array('Property', null, null, $styles, null, 'subScript', true),
- 'span' => array('Span', $node, null, $styles, null, null, null),
- 'font' => array('Span', $node, null, $styles, null, null, null),
- 'table' => array('Table', $node, $element, $styles, null, null, null),
- 'tr' => array('Row', $node, $element, $styles, null, null, null),
- 'td' => array('Cell', $node, $element, $styles, null, null, null),
- 'th' => array('Cell', $node, $element, $styles, null, null, null),
- 'ul' => array('List', $node, $element, $styles, $data, null, null),
- 'ol' => array('List', $node, $element, $styles, $data, null, null),
- 'li' => array('ListItem', $node, $element, $styles, $data, null, null),
- 'img' => array('Image', $node, $element, $styles, null, null, null),
- 'br' => array('LineBreak', null, $element, $styles, null, null, null),
- 'a' => array('Link', $node, $element, $styles, null, null, null),
- 'input' => array('Input', $node, $element, $styles, null, null, null),
- 'hr' => array('HorizRule', $node, $element, $styles, null, null, null),
- );
+ $nodes = [
+ // $method $node $element $styles $data $argument1 $argument2
+ 'p' => ['Paragraph', $node, $element, $styles, null, null, null],
+ 'h1' => ['Heading', null, $element, $styles, null, 'Heading1', null],
+ 'h2' => ['Heading', null, $element, $styles, null, 'Heading2', null],
+ 'h3' => ['Heading', null, $element, $styles, null, 'Heading3', null],
+ 'h4' => ['Heading', null, $element, $styles, null, 'Heading4', null],
+ 'h5' => ['Heading', null, $element, $styles, null, 'Heading5', null],
+ 'h6' => ['Heading', null, $element, $styles, null, 'Heading6', null],
+ '#text' => ['Text', $node, $element, $styles, null, null, null],
+ 'strong' => ['Property', null, null, $styles, null, 'bold', true],
+ 'b' => ['Property', null, null, $styles, null, 'bold', true],
+ 'em' => ['Property', null, null, $styles, null, 'italic', true],
+ 'i' => ['Property', null, null, $styles, null, 'italic', true],
+ 'u' => ['Property', null, null, $styles, null, 'underline', 'single'],
+ 'sup' => ['Property', null, null, $styles, null, 'superScript', true],
+ 'sub' => ['Property', null, null, $styles, null, 'subScript', true],
+ 'span' => ['Span', $node, null, $styles, null, null, null],
+ 'font' => ['Span', $node, null, $styles, null, null, null],
+ 'table' => ['Table', $node, $element, $styles, null, null, null],
+ 'tr' => ['Row', $node, $element, $styles, null, null, null],
+ 'td' => ['Cell', $node, $element, $styles, null, null, null],
+ 'th' => ['Cell', $node, $element, $styles, null, null, null],
+ 'ul' => ['List', $node, $element, $styles, $data, null, null],
+ 'ol' => ['List', $node, $element, $styles, $data, null, null],
+ 'li' => ['ListItem', $node, $element, $styles, $data, null, null],
+ 'img' => ['Image', $node, $element, $styles, null, null, null],
+ 'br' => ['LineBreak', null, $element, $styles, null, null, null],
+ 'a' => ['Link', $node, $element, $styles, null, null, null],
+ 'input' => ['Input', $node, $element, $styles, null, null, null],
+ 'hr' => ['HorizRule', $node, $element, $styles, null, null, null],
+ ];
$newElement = null;
- $keys = array('node', 'element', 'styles', 'data', 'argument1', 'argument2');
+ $keys = ['node', 'element', 'styles', 'data', 'argument1', 'argument2'];
if (isset($nodes[$node->nodeName])) {
// Execute method based on node mapping table and return $newElement or null
// Arguments are passed by reference
- $arguments = array();
- $args = array();
- list($method, $args[0], $args[1], $args[2], $args[3], $args[4], $args[5]) = $nodes[$node->nodeName];
- for ($i = 0; $i <= 5; $i++) {
+ $arguments = [];
+ $args = [];
+ [$method, $args[0], $args[1], $args[2], $args[3], $args[4], $args[5]] = $nodes[$node->nodeName];
+ for ($i = 0; $i <= 5; ++$i) {
if ($args[$i] !== null) {
$arguments[$keys[$i]] = &$args[$i];
}
}
$method = "parse{$method}";
- $newElement = call_user_func_array(array('PhpOffice\PhpWord\Shared\Html', $method), array_values($arguments));
+ $newElement = call_user_func_array(['PhpOffice\PhpWord\Shared\Html', $method], array_values($arguments));
// Retrieve back variables from arguments
foreach ($keys as $key) {
@@ -232,12 +244,12 @@ protected static function parseNode($node, $element, $styles = array(), $data =
/**
* Parse child nodes.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array $styles
* @param array $data
*/
- protected static function parseChildNodes($node, $element, $styles, $data)
+ protected static function parseChildNodes($node, $element, $styles, $data): void
{
if ('li' != $node->nodeName) {
$cNodes = $node->childNodes;
@@ -252,12 +264,13 @@ protected static function parseChildNodes($node, $element, $styles, $data)
}
/**
- * Parse paragraph node
+ * Parse paragraph node.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array &$styles
- * @return \PhpOffice\PhpWord\Element\TextRun|\PhpOffice\PhpWord\Element\PageBreak
+ *
+ * @return \PhpOffice\PhpWord\Element\PageBreak|\PhpOffice\PhpWord\Element\TextRun
*/
protected static function parseParagraph($node, $element, &$styles)
{
@@ -270,13 +283,13 @@ protected static function parseParagraph($node, $element, &$styles)
}
/**
- * Parse input node
+ * Parse input node.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array &$styles
*/
- protected static function parseInput($node, $element, &$styles)
+ protected static function parseInput($node, $element, &$styles): void
{
$attributes = $node->attributes;
if (null === $attributes->getNamedItem('type')) {
@@ -289,16 +302,18 @@ protected static function parseInput($node, $element, &$styles)
$checked = ($checked = $attributes->getNamedItem('checked')) && $checked->value === 'true' ? true : false;
$textrun = $element->addTextRun($styles['paragraph']);
$textrun->addFormField('checkbox')->setValue($checked);
+
break;
}
}
/**
- * Parse heading node
+ * Parse heading node.
*
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array &$styles
* @param string $argument1 Name of heading style
+ *
* @return \PhpOffice\PhpWord\Element\TextRun
*
* @todo Think of a clever way of defining header styles, now it is only based on the assumption, that
@@ -313,13 +328,13 @@ protected static function parseHeading($element, &$styles, $argument1)
}
/**
- * Parse text node
+ * Parse text node.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array &$styles
*/
- protected static function parseText($node, $element, &$styles)
+ protected static function parseText($node, $element, &$styles): void
{
$styles['font'] = self::recursiveParseStylesInHierarchy($node, $styles['font']);
@@ -328,40 +343,41 @@ protected static function parseText($node, $element, &$styles)
$styles['paragraph']['alignment'] = $styles['font']['alignment'];
}
- if (is_callable(array($element, 'addText'))) {
+ if (is_callable([$element, 'addText'])) {
$element->addText($node->nodeValue, $styles['font'], $styles['paragraph']);
}
}
/**
- * Parse property node
+ * Parse property node.
*
* @param array &$styles
* @param string $argument1 Style name
* @param string $argument2 Style value
*/
- protected static function parseProperty(&$styles, $argument1, $argument2)
+ protected static function parseProperty(&$styles, $argument1, $argument2): void
{
$styles['font'][$argument1] = $argument2;
}
/**
- * Parse span node
+ * Parse span node.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param array &$styles
*/
- protected static function parseSpan($node, &$styles)
+ protected static function parseSpan($node, &$styles): void
{
self::parseInlineStyle($node, $styles['font']);
}
/**
- * Parse table node
+ * Parse table node.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array &$styles
+ *
* @return Table $element
*
* @todo As soon as TableItem, RowItem and CellItem support relative width and height
@@ -382,11 +398,12 @@ protected static function parseTable($node, $element, &$styles)
}
/**
- * Parse a table row
+ * Parse a table row.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param \PhpOffice\PhpWord\Element\Table $element
* @param array &$styles
+ *
* @return Row $element
*/
protected static function parseRow($node, $element, &$styles)
@@ -400,11 +417,12 @@ protected static function parseRow($node, $element, &$styles)
}
/**
- * Parse table cell
+ * Parse table cell.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param \PhpOffice\PhpWord\Element\Table $element
* @param array &$styles
+ *
* @return \PhpOffice\PhpWord\Element\Cell|\PhpOffice\PhpWord\Element\TextRun $element
*/
protected static function parseCell($node, $element, &$styles)
@@ -417,7 +435,7 @@ protected static function parseCell($node, $element, &$styles)
}
// set cell width to control column widths
- $width = isset($cellStyles['width']) ? $cellStyles['width'] : null;
+ $width = $cellStyles['width'] ?? null;
unset($cellStyles['width']); // would not apply
$cell = $element->addCell($width, $cellStyles);
@@ -429,12 +447,11 @@ protected static function parseCell($node, $element, &$styles)
}
/**
- * Checks if $node contains an HTML element that cannot be added to TextRun
+ * Checks if $node contains an HTML element that cannot be added to TextRun.
*
- * @param \DOMNode $node
* @return bool Returns true if the node contains an HTML element that cannot be added to TextRun
*/
- protected static function shouldAddTextRun(\DOMNode $node)
+ protected static function shouldAddTextRun(DOMNode $node)
{
$containsBlockElement = self::$xpath->query('.//table|./p|./ul|./ol|./h1|./h2|./h3|./h4|./h5|./h6', $node)->length > 0;
if ($containsBlockElement) {
@@ -447,15 +464,12 @@ protected static function shouldAddTextRun(\DOMNode $node)
/**
* Recursively parses styles on parent nodes
* TODO if too slow, add caching of parent nodes, !! everything is static here so watch out for concurrency !!
- *
- * @param \DOMNode $node
- * @param array &$styles
*/
- protected static function recursiveParseStylesInHierarchy(\DOMNode $node, array $style)
+ protected static function recursiveParseStylesInHierarchy(DOMNode $node, array $style)
{
- $parentStyle = array();
+ $parentStyle = [];
if ($node->parentNode != null && XML_ELEMENT_NODE == $node->parentNode->nodeType) {
- $parentStyle = self::recursiveParseStylesInHierarchy($node->parentNode, array());
+ $parentStyle = self::recursiveParseStylesInHierarchy($node->parentNode, []);
}
if ($node->nodeName === '#text') {
$parentStyle = array_merge($parentStyle, $style);
@@ -468,13 +482,11 @@ protected static function recursiveParseStylesInHierarchy(\DOMNode $node, array
}
/**
- * Removes non-inherited styles from array
- *
- * @param array &$styles
+ * Removes non-inherited styles from array.
*/
protected static function filterOutNonInheritedStyles(array $styles)
{
- $nonInheritedStyles = array(
+ $nonInheritedStyles = [
'borderSize',
'borderTopSize',
'borderRightSize',
@@ -491,7 +503,7 @@ protected static function filterOutNonInheritedStyles(array $styles)
'underline',
'strikethrough',
'hidden',
- );
+ ];
$styles = array_diff_key($styles, array_flip($nonInheritedStyles));
@@ -499,9 +511,9 @@ protected static function filterOutNonInheritedStyles(array $styles)
}
/**
- * Parse list node
+ * Parse list node.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array &$styles
* @param array &$data
@@ -510,7 +522,7 @@ protected static function parseList($node, $element, &$styles, &$data)
{
$isOrderedList = $node->nodeName === 'ol';
if (isset($data['listdepth'])) {
- $data['listdepth']++;
+ ++$data['listdepth'];
} else {
$data['listdepth'] = 0;
$styles['list'] = 'listStyle_' . self::$listIndex++;
@@ -523,9 +535,11 @@ protected static function parseList($node, $element, &$styles, &$data)
switch ($attribute->name) {
case 'start':
$start = (int) $attribute->value;
+
break;
case 'type':
$type = $attribute->value;
+
break;
}
}
@@ -548,47 +562,48 @@ protected static function parseList($node, $element, &$styles, &$data)
/**
* @param bool $isOrderedList
+ *
* @return array
*/
protected static function getListStyle($isOrderedList)
{
if ($isOrderedList) {
- return array(
- 'type' => 'multilevel',
- 'levels' => array(
- array('format' => NumberFormat::DECIMAL, 'text' => '%1.', 'alignment' => 'left', 'tabPos' => 720, 'left' => 720, 'hanging' => 360),
- array('format' => NumberFormat::LOWER_LETTER, 'text' => '%2.', 'alignment' => 'left', 'tabPos' => 1440, 'left' => 1440, 'hanging' => 360),
- array('format' => NumberFormat::LOWER_ROMAN, 'text' => '%3.', 'alignment' => 'right', 'tabPos' => 2160, 'left' => 2160, 'hanging' => 180),
- array('format' => NumberFormat::DECIMAL, 'text' => '%4.', 'alignment' => 'left', 'tabPos' => 2880, 'left' => 2880, 'hanging' => 360),
- array('format' => NumberFormat::LOWER_LETTER, 'text' => '%5.', 'alignment' => 'left', 'tabPos' => 3600, 'left' => 3600, 'hanging' => 360),
- array('format' => NumberFormat::LOWER_ROMAN, 'text' => '%6.', 'alignment' => 'right', 'tabPos' => 4320, 'left' => 4320, 'hanging' => 180),
- array('format' => NumberFormat::DECIMAL, 'text' => '%7.', 'alignment' => 'left', 'tabPos' => 5040, 'left' => 5040, 'hanging' => 360),
- array('format' => NumberFormat::LOWER_LETTER, 'text' => '%8.', 'alignment' => 'left', 'tabPos' => 5760, 'left' => 5760, 'hanging' => 360),
- array('format' => NumberFormat::LOWER_ROMAN, 'text' => '%9.', 'alignment' => 'right', 'tabPos' => 6480, 'left' => 6480, 'hanging' => 180),
- ),
- );
+ return [
+ 'type' => 'multilevel',
+ 'levels' => [
+ ['format' => NumberFormat::DECIMAL, 'text' => '%1.', 'alignment' => 'left', 'tabPos' => 720, 'left' => 720, 'hanging' => 360],
+ ['format' => NumberFormat::LOWER_LETTER, 'text' => '%2.', 'alignment' => 'left', 'tabPos' => 1440, 'left' => 1440, 'hanging' => 360],
+ ['format' => NumberFormat::LOWER_ROMAN, 'text' => '%3.', 'alignment' => 'right', 'tabPos' => 2160, 'left' => 2160, 'hanging' => 180],
+ ['format' => NumberFormat::DECIMAL, 'text' => '%4.', 'alignment' => 'left', 'tabPos' => 2880, 'left' => 2880, 'hanging' => 360],
+ ['format' => NumberFormat::LOWER_LETTER, 'text' => '%5.', 'alignment' => 'left', 'tabPos' => 3600, 'left' => 3600, 'hanging' => 360],
+ ['format' => NumberFormat::LOWER_ROMAN, 'text' => '%6.', 'alignment' => 'right', 'tabPos' => 4320, 'left' => 4320, 'hanging' => 180],
+ ['format' => NumberFormat::DECIMAL, 'text' => '%7.', 'alignment' => 'left', 'tabPos' => 5040, 'left' => 5040, 'hanging' => 360],
+ ['format' => NumberFormat::LOWER_LETTER, 'text' => '%8.', 'alignment' => 'left', 'tabPos' => 5760, 'left' => 5760, 'hanging' => 360],
+ ['format' => NumberFormat::LOWER_ROMAN, 'text' => '%9.', 'alignment' => 'right', 'tabPos' => 6480, 'left' => 6480, 'hanging' => 180],
+ ],
+ ];
}
- return array(
- 'type' => 'hybridMultilevel',
- 'levels' => array(
- array('format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 720, 'left' => 720, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'),
- array('format' => NumberFormat::BULLET, 'text' => 'o', 'alignment' => 'left', 'tabPos' => 1440, 'left' => 1440, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'),
- array('format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 2160, 'left' => 2160, 'hanging' => 360, 'font' => 'Wingdings', 'hint' => 'default'),
- array('format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 2880, 'left' => 2880, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'),
- array('format' => NumberFormat::BULLET, 'text' => 'o', 'alignment' => 'left', 'tabPos' => 3600, 'left' => 3600, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'),
- array('format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 4320, 'left' => 4320, 'hanging' => 360, 'font' => 'Wingdings', 'hint' => 'default'),
- array('format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 5040, 'left' => 5040, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'),
- array('format' => NumberFormat::BULLET, 'text' => 'o', 'alignment' => 'left', 'tabPos' => 5760, 'left' => 5760, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'),
- array('format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 6480, 'left' => 6480, 'hanging' => 360, 'font' => 'Wingdings', 'hint' => 'default'),
- ),
- );
+ return [
+ 'type' => 'hybridMultilevel',
+ 'levels' => [
+ ['format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 720, 'left' => 720, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'],
+ ['format' => NumberFormat::BULLET, 'text' => 'o', 'alignment' => 'left', 'tabPos' => 1440, 'left' => 1440, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'],
+ ['format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 2160, 'left' => 2160, 'hanging' => 360, 'font' => 'Wingdings', 'hint' => 'default'],
+ ['format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 2880, 'left' => 2880, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'],
+ ['format' => NumberFormat::BULLET, 'text' => 'o', 'alignment' => 'left', 'tabPos' => 3600, 'left' => 3600, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'],
+ ['format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 4320, 'left' => 4320, 'hanging' => 360, 'font' => 'Wingdings', 'hint' => 'default'],
+ ['format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 5040, 'left' => 5040, 'hanging' => 360, 'font' => 'Symbol', 'hint' => 'default'],
+ ['format' => NumberFormat::BULLET, 'text' => 'o', 'alignment' => 'left', 'tabPos' => 5760, 'left' => 5760, 'hanging' => 360, 'font' => 'Courier New', 'hint' => 'default'],
+ ['format' => NumberFormat::BULLET, 'text' => '', 'alignment' => 'left', 'tabPos' => 6480, 'left' => 6480, 'hanging' => 360, 'font' => 'Wingdings', 'hint' => 'default'],
+ ],
+ ];
}
/**
- * Parse list item node
+ * Parse list item node.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array &$styles
* @param array $data
@@ -596,7 +611,7 @@ protected static function getListStyle($isOrderedList)
* @todo This function is almost the same like `parseChildNodes`. Merged?
* @todo As soon as ListItem inherits from AbstractContainer or TextRun delete parsing part of childNodes
*/
- protected static function parseListItem($node, $element, &$styles, $data)
+ protected static function parseListItem($node, $element, &$styles, $data): void
{
$cNodes = $node->childNodes;
if (!empty($cNodes)) {
@@ -608,10 +623,11 @@ protected static function parseListItem($node, $element, &$styles, $data)
}
/**
- * Parse style
+ * Parse style.
*
- * @param \DOMAttr $attribute
+ * @param DOMAttr $attribute
* @param array $styles
+ *
* @return array
*/
protected static function parseStyle($attribute, $styles)
@@ -619,7 +635,7 @@ protected static function parseStyle($attribute, $styles)
$properties = explode(';', trim($attribute->value, " \t\n\r\0\x0B;"));
foreach ($properties as $property) {
- list($cKey, $cValue) = array_pad(explode(':', $property, 2), 2, null);
+ [$cKey, $cValue] = array_pad(explode(':', $property, 2), 2, null);
$cValue = trim($cValue ?? '');
$cKey = strtolower(trim($cKey));
switch ($cKey) {
@@ -627,36 +643,46 @@ protected static function parseStyle($attribute, $styles)
switch ($cValue) {
case 'underline':
$styles['underline'] = 'single';
+
break;
case 'line-through':
$styles['strikethrough'] = true;
+
break;
}
+
break;
case 'text-align':
$styles['alignment'] = self::mapAlign($cValue);
+
break;
case 'display':
$styles['hidden'] = $cValue === 'none' || $cValue === 'hidden';
+
break;
case 'direction':
$styles['rtl'] = $cValue === 'rtl';
+
break;
case 'font-size':
$styles['size'] = Converter::cssToPoint($cValue);
+
break;
case 'font-family':
$cValue = array_map('trim', explode(',', $cValue));
$styles['name'] = ucwords($cValue[0]);
+
break;
case 'color':
$styles['color'] = trim($cValue, '#');
+
break;
case 'background-color':
$styles['bgColor'] = trim($cValue, '#');
+
break;
case 'line-height':
- $matches = array();
+ $matches = [];
if ($cValue === 'normal') {
$spacingLineRule = \PhpOffice\PhpWord\SimpleType\LineSpacingRule::AUTO;
$spacing = 0;
@@ -677,12 +703,15 @@ protected static function parseStyle($attribute, $styles)
}
$styles['spacingLineRule'] = $spacingLineRule;
$styles['line-spacing'] = $spacing;
+
break;
case 'letter-spacing':
$styles['letter-spacing'] = Converter::cssToTwip($cValue);
+
break;
case 'text-indent':
$styles['indentation']['firstLine'] = Converter::cssToTwip($cValue);
+
break;
case 'font-weight':
$tValue = false;
@@ -690,6 +719,7 @@ protected static function parseStyle($attribute, $styles)
$tValue = true; // also match bolder
}
$styles['bold'] = $tValue;
+
break;
case 'font-style':
$tValue = false;
@@ -697,28 +727,35 @@ protected static function parseStyle($attribute, $styles)
$tValue = true;
}
$styles['italic'] = $tValue;
+
break;
case 'margin':
$cValue = Converter::cssToTwip($cValue);
$styles['spaceBefore'] = $cValue;
$styles['spaceAfter'] = $cValue;
+
break;
case 'margin-top':
// BC change: up to ver. 0.17.0 incorrectly converted to points - Converter::cssToPoint($cValue)
$styles['spaceBefore'] = Converter::cssToTwip($cValue);
+
break;
case 'margin-bottom':
// BC change: up to ver. 0.17.0 incorrectly converted to points - Converter::cssToPoint($cValue)
$styles['spaceAfter'] = Converter::cssToTwip($cValue);
+
break;
case 'border-color':
self::mapBorderColor($styles, $cValue);
+
break;
case 'border-width':
$styles['borderSize'] = Converter::cssToPoint($cValue);
+
break;
case 'border-style':
$styles['borderStyle'] = self::mapBorderStyle($cValue);
+
break;
case 'width':
if (preg_match('/([0-9]+[a-z]+)/', $cValue, $matches)) {
@@ -731,6 +768,7 @@ protected static function parseStyle($attribute, $styles)
$styles['width'] = $matches[1];
$styles['unit'] = \PhpOffice\PhpWord\SimpleType\TblWidth::AUTO;
}
+
break;
case 'border':
case 'border-top':
@@ -760,17 +798,20 @@ protected static function parseStyle($attribute, $styles)
$styles["border{$which}Color"] = trim($matches[2], '#');
$styles["border{$which}Style"] = self::mapBorderStyle($matches[3]);
}
+
break;
case 'vertical-align':
// https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align
if (preg_match('#(?:top|bottom|middle|sub|baseline)#i', $cValue, $matches)) {
$styles['valign'] = self::mapAlignVertical($matches[0]);
}
+
break;
case 'page-break-after':
if ($cValue == 'always') {
$styles['isPageBreak'] = true;
}
+
break;
}
}
@@ -779,37 +820,40 @@ protected static function parseStyle($attribute, $styles)
}
/**
- * Parse image node
+ * Parse image node.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
*
* @return \PhpOffice\PhpWord\Element\Image
- **/
+ */
protected static function parseImage($node, $element)
{
- $style = array();
+ $style = [];
$src = null;
foreach ($node->attributes as $attribute) {
switch ($attribute->name) {
case 'src':
$src = $attribute->value;
+
break;
case 'width':
$width = $attribute->value;
$style['width'] = $width;
$style['unit'] = \PhpOffice\PhpWord\Style\Image::UNIT_PX;
+
break;
case 'height':
$height = $attribute->value;
$style['height'] = $height;
$style['unit'] = \PhpOffice\PhpWord\Style\Image::UNIT_PX;
+
break;
case 'style':
$styleattr = explode(';', $attribute->value);
foreach ($styleattr as $attr) {
if (strpos($attr, ':')) {
- list($k, $v) = explode(':', $attr);
+ [$k, $v] = explode(':', $attr);
switch ($k) {
case 'float':
if (trim($v) == 'right') {
@@ -826,10 +870,12 @@ protected static function parseImage($node, $element)
$style['wrap'] = \PhpOffice\PhpWord\Style\Image::WRAP_TIGHT;
$style['overlap'] = true;
}
+
break;
}
}
}
+
break;
}
}
@@ -837,7 +883,7 @@ protected static function parseImage($node, $element)
if (strpos($src, 'data:image') !== false) {
$tmpDir = Settings::getTempDir() . '/';
- $match = array();
+ $match = [];
preg_match('/data:image\/(\w+);base64,(.+)/', $src, $match);
$src = $imgFile = $tmpDir . uniqid() . '.' . $match[1];
@@ -852,16 +898,16 @@ protected static function parseImage($node, $element)
$src = urldecode($src);
if (!is_file($src)
- && !is_null(self::$options)
- && isset(self::$options['IMG_SRC_SEARCH'])
- && isset(self::$options['IMG_SRC_REPLACE'])) {
+ && null !== self::$options
+ && isset(self::$options['IMG_SRC_SEARCH'], self::$options['IMG_SRC_REPLACE'])
+ ) {
$src = str_replace(self::$options['IMG_SRC_SEARCH'], self::$options['IMG_SRC_REPLACE'], $src);
}
if (!is_file($src)) {
if ($imgBlob = @file_get_contents($src)) {
$tmpDir = Settings::getTempDir() . '/';
- $match = array();
+ $match = [];
preg_match('/.+\.(\w+)$/', $src, $match);
$src = $tmpDir . uniqid() . '.' . $match[1];
@@ -877,16 +923,17 @@ protected static function parseImage($node, $element)
if (is_file($src)) {
$newElement = $element->addImage($src, $style);
} else {
- throw new \Exception("Could not load image $originSrc");
+ throw new Exception("Could not load image $originSrc");
}
return $newElement;
}
/**
- * Transforms a CSS border style into a word border style
+ * Transforms a CSS border style into a word border style.
*
* @param string $cssBorderStyle
+ *
* @return null|string
*/
protected static function mapBorderStyle($cssBorderStyle)
@@ -902,25 +949,26 @@ protected static function mapBorderStyle($cssBorderStyle)
}
}
- protected static function mapBorderColor(&$styles, $cssBorderColor)
+ protected static function mapBorderColor(&$styles, $cssBorderColor): void
{
$numColors = substr_count($cssBorderColor, '#');
if ($numColors === 1) {
$styles['borderColor'] = trim($cssBorderColor, '#');
} elseif ($numColors > 1) {
$colors = explode(' ', $cssBorderColor);
- $borders = array('borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor');
- for ($i = 0; $i < min(4, $numColors, count($colors)); $i++) {
+ $borders = ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor'];
+ for ($i = 0; $i < min(4, $numColors, count($colors)); ++$i) {
$styles[$borders[$i]] = trim($colors[$i], '#');
}
}
}
/**
- * Transforms a HTML/CSS alignment into a \PhpOffice\PhpWord\SimpleType\Jc
+ * Transforms a HTML/CSS alignment into a \PhpOffice\PhpWord\SimpleType\Jc.
*
* @param string $cssAlignment
- * @return string|null
+ *
+ * @return null|string
*/
protected static function mapAlign($cssAlignment)
{
@@ -937,10 +985,11 @@ protected static function mapAlign($cssAlignment)
}
/**
- * Transforms a HTML/CSS vertical alignment
+ * Transforms a HTML/CSS vertical alignment.
*
* @param string $alignment
- * @return string|null
+ *
+ * @return null|string
*/
protected static function mapAlignVertical($alignment)
{
@@ -967,7 +1016,7 @@ protected static function mapAlignVertical($alignment)
}
/**
- * Map list style for ordered list
+ * Map list style for ordered list.
*
* @param string $cssListType
*/
@@ -989,19 +1038,19 @@ protected static function mapListType($cssListType)
}
/**
- * Parse line break
+ * Parse line break.
*
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
*/
- protected static function parseLineBreak($element)
+ protected static function parseLineBreak($element): void
{
$element->addTextBreak();
}
/**
- * Parse link node
+ * Parse link node.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array $styles
*/
@@ -1012,6 +1061,7 @@ protected static function parseLink($node, $element, &$styles)
switch ($attribute->name) {
case 'href':
$target = $attribute->value;
+
break;
}
}
@@ -1026,29 +1076,29 @@ protected static function parseLink($node, $element, &$styles)
/**
* Render horizontal rule
- * Note: Word rule is not the same as HTML's since it does not support width and thus neither alignment
+ * Note: Word rule is not the same as HTML's since it does not support width and thus neither alignment.
*
- * @param \DOMNode $node
+ * @param DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
*/
- protected static function parseHorizRule($node, $element)
+ protected static function parseHorizRule($node, $element): void
{
$styles = self::parseInlineStyle($node);
// is implemented as an empty paragraph - extending 100% inside the section
// Some properties may be controlled, e.g.
- $fontStyle = $styles + array('size' => 3);
+ $fontStyle = $styles + ['size' => 3];
- $paragraphStyle = $styles + array(
- 'lineHeight' => 0.25, // multiply default line height - e.g. 1, 1.5 etc
- 'spacing' => 0, // twip
- 'spaceBefore' => 120, // twip, 240/2 (default line height)
- 'spaceAfter' => 120, // twip
- 'borderBottomSize' => empty($styles['line-height']) ? 1 : $styles['line-height'],
+ $paragraphStyle = $styles + [
+ 'lineHeight' => 0.25, // multiply default line height - e.g. 1, 1.5 etc
+ 'spacing' => 0, // twip
+ 'spaceBefore' => 120, // twip, 240/2 (default line height)
+ 'spaceAfter' => 120, // twip
+ 'borderBottomSize' => empty($styles['line-height']) ? 1 : $styles['line-height'],
'borderBottomColor' => empty($styles['color']) ? '000000' : $styles['color'],
'borderBottomStyle' => 'single', // same as "solid"
- );
+ ];
$element->addText('', $fontStyle, $paragraphStyle);
diff --git a/src/PhpWord/Shared/Microsoft/PasswordEncoder.php b/src/PhpWord/Shared/Microsoft/PasswordEncoder.php
index fc0c7ecdf8..5ff42e49b9 100644
--- a/src/PhpWord/Shared/Microsoft/PasswordEncoder.php
+++ b/src/PhpWord/Shared/Microsoft/PasswordEncoder.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Shared\Microsoft;
/**
- * Password encoder for microsoft office applications
+ * Password encoder for microsoft office applications.
*/
class PasswordEncoder
{
@@ -35,26 +35,27 @@ class PasswordEncoder
const ALGORITHM_HMAC = 'HMAC';
/**
- * Mapping between algorithm name and algorithm ID
+ * Mapping between algorithm name and algorithm ID.
*
* @var array
+ *
* @see https://msdn.microsoft.com/en-us/library/documentformat.openxml.wordprocessing.writeprotection.cryptographicalgorithmsid(v=office.14).aspx
*/
- private static $algorithmMapping = array(
- self::ALGORITHM_MD2 => array(1, 'md2'),
- self::ALGORITHM_MD4 => array(2, 'md4'),
- self::ALGORITHM_MD5 => array(3, 'md5'),
- self::ALGORITHM_SHA_1 => array(4, 'sha1'),
- self::ALGORITHM_MAC => array(5, ''), // 'mac' -> not possible with hash()
- self::ALGORITHM_RIPEMD => array(6, 'ripemd'),
- self::ALGORITHM_RIPEMD_160 => array(7, 'ripemd160'),
- self::ALGORITHM_HMAC => array(9, ''), //'hmac' -> not possible with hash()
- self::ALGORITHM_SHA_256 => array(12, 'sha256'),
- self::ALGORITHM_SHA_384 => array(13, 'sha384'),
- self::ALGORITHM_SHA_512 => array(14, 'sha512'),
- );
-
- private static $initialCodeArray = array(
+ private static $algorithmMapping = [
+ self::ALGORITHM_MD2 => [1, 'md2'],
+ self::ALGORITHM_MD4 => [2, 'md4'],
+ self::ALGORITHM_MD5 => [3, 'md5'],
+ self::ALGORITHM_SHA_1 => [4, 'sha1'],
+ self::ALGORITHM_MAC => [5, ''], // 'mac' -> not possible with hash()
+ self::ALGORITHM_RIPEMD => [6, 'ripemd'],
+ self::ALGORITHM_RIPEMD_160 => [7, 'ripemd160'],
+ self::ALGORITHM_HMAC => [9, ''], //'hmac' -> not possible with hash()
+ self::ALGORITHM_SHA_256 => [12, 'sha256'],
+ self::ALGORITHM_SHA_384 => [13, 'sha384'],
+ self::ALGORITHM_SHA_512 => [14, 'sha512'],
+ ];
+
+ private static $initialCodeArray = [
0xE1F0,
0x1D0F,
0xCC9C,
@@ -70,36 +71,38 @@ class PasswordEncoder
0x280C,
0xA96A,
0x4EC3,
- );
-
- private static $encryptionMatrix = array(
- array(0xAEFC, 0x4DD9, 0x9BB2, 0x2745, 0x4E8A, 0x9D14, 0x2A09),
- array(0x7B61, 0xF6C2, 0xFDA5, 0xEB6B, 0xC6F7, 0x9DCF, 0x2BBF),
- array(0x4563, 0x8AC6, 0x05AD, 0x0B5A, 0x16B4, 0x2D68, 0x5AD0),
- array(0x0375, 0x06EA, 0x0DD4, 0x1BA8, 0x3750, 0x6EA0, 0xDD40),
- array(0xD849, 0xA0B3, 0x5147, 0xA28E, 0x553D, 0xAA7A, 0x44D5),
- array(0x6F45, 0xDE8A, 0xAD35, 0x4A4B, 0x9496, 0x390D, 0x721A),
- array(0xEB23, 0xC667, 0x9CEF, 0x29FF, 0x53FE, 0xA7FC, 0x5FD9),
- array(0x47D3, 0x8FA6, 0x0F6D, 0x1EDA, 0x3DB4, 0x7B68, 0xF6D0),
- array(0xB861, 0x60E3, 0xC1C6, 0x93AD, 0x377B, 0x6EF6, 0xDDEC),
- array(0x45A0, 0x8B40, 0x06A1, 0x0D42, 0x1A84, 0x3508, 0x6A10),
- array(0xAA51, 0x4483, 0x8906, 0x022D, 0x045A, 0x08B4, 0x1168),
- array(0x76B4, 0xED68, 0xCAF1, 0x85C3, 0x1BA7, 0x374E, 0x6E9C),
- array(0x3730, 0x6E60, 0xDCC0, 0xA9A1, 0x4363, 0x86C6, 0x1DAD),
- array(0x3331, 0x6662, 0xCCC4, 0x89A9, 0x0373, 0x06E6, 0x0DCC),
- array(0x1021, 0x2042, 0x4084, 0x8108, 0x1231, 0x2462, 0x48C4),
- );
+ ];
+
+ private static $encryptionMatrix = [
+ [0xAEFC, 0x4DD9, 0x9BB2, 0x2745, 0x4E8A, 0x9D14, 0x2A09],
+ [0x7B61, 0xF6C2, 0xFDA5, 0xEB6B, 0xC6F7, 0x9DCF, 0x2BBF],
+ [0x4563, 0x8AC6, 0x05AD, 0x0B5A, 0x16B4, 0x2D68, 0x5AD0],
+ [0x0375, 0x06EA, 0x0DD4, 0x1BA8, 0x3750, 0x6EA0, 0xDD40],
+ [0xD849, 0xA0B3, 0x5147, 0xA28E, 0x553D, 0xAA7A, 0x44D5],
+ [0x6F45, 0xDE8A, 0xAD35, 0x4A4B, 0x9496, 0x390D, 0x721A],
+ [0xEB23, 0xC667, 0x9CEF, 0x29FF, 0x53FE, 0xA7FC, 0x5FD9],
+ [0x47D3, 0x8FA6, 0x0F6D, 0x1EDA, 0x3DB4, 0x7B68, 0xF6D0],
+ [0xB861, 0x60E3, 0xC1C6, 0x93AD, 0x377B, 0x6EF6, 0xDDEC],
+ [0x45A0, 0x8B40, 0x06A1, 0x0D42, 0x1A84, 0x3508, 0x6A10],
+ [0xAA51, 0x4483, 0x8906, 0x022D, 0x045A, 0x08B4, 0x1168],
+ [0x76B4, 0xED68, 0xCAF1, 0x85C3, 0x1BA7, 0x374E, 0x6E9C],
+ [0x3730, 0x6E60, 0xDCC0, 0xA9A1, 0x4363, 0x86C6, 0x1DAD],
+ [0x3331, 0x6662, 0xCCC4, 0x89A9, 0x0373, 0x06E6, 0x0DCC],
+ [0x1021, 0x2042, 0x4084, 0x8108, 0x1231, 0x2462, 0x48C4],
+ ];
private static $passwordMaxLength = 15;
/**
- * Create a hashed password that MS Word will be able to work with
+ * Create a hashed password that MS Word will be able to work with.
+ *
* @see https://blogs.msdn.microsoft.com/vsod/2010/04/05/how-to-set-the-editing-restrictions-in-word-using-open-xml-sdk-2-0/
*
* @param string $password
* @param string $algorithmName
* @param string $salt
* @param int $spinCount
+ *
* @return string
*/
public static function hashPassword($password, $algorithmName = self::ALGORITHM_SHA_1, $salt = null, $spinCount = 10000)
@@ -112,9 +115,9 @@ public static function hashPassword($password, $algorithmName = self::ALGORITHM_
// Get the single-byte values by iterating through the Unicode characters of the truncated password.
// For each character, if the low byte is not equal to 0, take it. Otherwise, take the high byte.
$passUtf8 = mb_convert_encoding($password, 'UCS-2LE', 'UTF-8');
- $byteChars = array();
+ $byteChars = [];
- for ($i = 0; $i < mb_strlen($password); $i++) {
+ for ($i = 0; $i < mb_strlen($password); ++$i) {
$byteChars[$i] = ord(substr($passUtf8, $i * 2, 1));
if ($byteChars[$i] == 0) {
@@ -136,7 +139,7 @@ public static function hashPassword($password, $algorithmName = self::ALGORITHM_
$algorithm = self::getAlgorithm($algorithmName);
$generatedKey = hash($algorithm, $salt . $generatedKey, true);
- for ($i = 0; $i < $spinCount; $i++) {
+ for ($i = 0; $i < $spinCount; ++$i) {
$generatedKey = hash($algorithm, $generatedKey . pack('CCCC', $i, $i >> 8, $i >> 16, $i >> 24), true);
}
$generatedKey = base64_encode($generatedKey);
@@ -147,9 +150,10 @@ public static function hashPassword($password, $algorithmName = self::ALGORITHM_
}
/**
- * Get algorithm from self::$algorithmMapping
+ * Get algorithm from self::$algorithmMapping.
*
* @param string $algorithmName
+ *
* @return string
*/
private static function getAlgorithm($algorithmName)
@@ -163,9 +167,10 @@ private static function getAlgorithm($algorithmName)
}
/**
- * Returns the algorithm ID
+ * Returns the algorithm ID.
*
* @param string $algorithmName
+ *
* @return int
*/
public static function getAlgorithmId($algorithmName)
@@ -174,9 +179,10 @@ public static function getAlgorithmId($algorithmName)
}
/**
- * Build combined key from low-order word and high-order word
+ * Build combined key from low-order word and high-order word.
*
* @param array $byteChars byte array representation of password
+ *
* @return int
*/
private static function buildCombinedKey($byteChars)
@@ -190,10 +196,10 @@ private static function buildCombinedKey($byteChars)
// For every bit in the character, starting with the least significant and progressing to (but excluding)
// the most significant, if the bit is set, XOR the key’s high-order word with the corresponding word from
// the Encryption Matrix
- for ($i = 0; $i < $byteCharsLength; $i++) {
+ for ($i = 0; $i < $byteCharsLength; ++$i) {
$tmp = self::$passwordMaxLength - $byteCharsLength + $i;
$matrixRow = self::$encryptionMatrix[$tmp];
- for ($intBit = 0; $intBit < 7; $intBit++) {
+ for ($intBit = 0; $intBit < 7; ++$intBit) {
if (($byteChars[$i] & (0x0001 << $intBit)) != 0) {
$highOrderWord = ($highOrderWord ^ $matrixRow[$intBit]);
}
@@ -204,7 +210,7 @@ private static function buildCombinedKey($byteChars)
// Initialize with 0
$lowOrderWord = 0;
// For each character in the password, going backwards
- for ($i = $byteCharsLength - 1; $i >= 0; $i--) {
+ for ($i = $byteCharsLength - 1; $i >= 0; --$i) {
// low-order word = (((low-order word SHR 14) AND 0x0001) OR (low-order word SHL 1) AND 0x7FFF)) XOR character
$lowOrderWord = (((($lowOrderWord >> 14) & 0x0001) | (($lowOrderWord << 1) & 0x7FFF)) ^ $byteChars[$i]);
}
@@ -216,10 +222,12 @@ private static function buildCombinedKey($byteChars)
}
/**
- * Simulate behaviour of (signed) int32
+ * Simulate behaviour of (signed) int32.
*
* @codeCoverageIgnore
+ *
* @param int $value
+ *
* @return int
*/
private static function int32($value)
diff --git a/src/PhpWord/Shared/Text.php b/src/PhpWord/Shared/Text.php
index c4a1ad620f..667d67ab4a 100644
--- a/src/PhpWord/Shared/Text.php
+++ b/src/PhpWord/Shared/Text.php
@@ -11,28 +11,28 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Shared;
/**
- * Text
+ * Text.
*/
class Text
{
/**
- * Control characters array
+ * Control characters array.
*
* @var string[]
*/
- private static $controlCharacters = array();
+ private static $controlCharacters = [];
/**
- * Build control characters array
+ * Build control characters array.
*/
- private static function buildControlCharacters()
+ private static function buildControlCharacters(): void
{
for ($i = 0; $i <= 19; ++$i) {
if ($i != 9 && $i != 10 && $i != 13) {
@@ -44,7 +44,7 @@ private static function buildControlCharacters()
}
/**
- * Convert from PHP control character to OpenXML escaped control character
+ * Convert from PHP control character to OpenXML escaped control character.
*
* Excel 2007 team:
* ----------------
@@ -55,6 +55,7 @@ private static function buildControlCharacters()
* element or in the shared string element.
*
* @param string $value Value to escape
+ *
* @return string
*/
public static function controlCharacterPHP2OOXML($value = '')
@@ -67,9 +68,11 @@ public static function controlCharacterPHP2OOXML($value = '')
}
/**
- * Return a number formatted for being integrated in xml files
+ * Return a number formatted for being integrated in xml files.
+ *
* @param float $number
* @param int $decimals
+ *
* @return string
*/
public static function numberFormat($number, $decimals)
@@ -79,8 +82,11 @@ public static function numberFormat($number, $decimals)
/**
* @param int $dec
+ *
* @see http://stackoverflow.com/a/7153133/2235790
+ *
* @author velcrow
+ *
* @return string
*/
public static function chr($dec)
@@ -102,9 +108,10 @@ public static function chr($dec)
}
/**
- * Convert from OpenXML escaped control character to PHP control character
+ * Convert from OpenXML escaped control character to PHP control character.
*
* @param string $value Value to unescape
+ *
* @return string
*/
public static function controlCharacterOOXML2PHP($value = '')
@@ -117,9 +124,10 @@ public static function controlCharacterOOXML2PHP($value = '')
}
/**
- * Check if a string contains UTF-8 data
+ * Check if a string contains UTF-8 data.
*
* @param string $value
+ *
* @return bool
*/
public static function isUTF8($value = '')
@@ -128,14 +136,15 @@ public static function isUTF8($value = '')
}
/**
- * Return UTF8 encoded value
+ * Return UTF8 encoded value.
*
* @param string $value
+ *
* @return string
*/
public static function toUTF8($value = '')
{
- if (!is_null($value) && !self::isUTF8($value)) {
+ if (null !== $value && !self::isUTF8($value)) {
$value = utf8_encode($value);
}
@@ -143,12 +152,14 @@ public static function toUTF8($value = '')
}
/**
- * Returns unicode from UTF8 text
+ * Returns unicode from UTF8 text.
*
* The function is splitted to reduce cyclomatic complexity
*
* @param string $text UTF8 text
+ *
* @return string Unicode text
+ *
* @since 0.11.0
*/
public static function toUnicode($text)
@@ -157,21 +168,23 @@ public static function toUnicode($text)
}
/**
- * Returns unicode array from UTF8 text
+ * Returns unicode array from UTF8 text.
*
* @param string $text UTF8 text
+ *
* @return array
+ *
* @since 0.11.0
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
*/
public static function utf8ToUnicode($text)
{
- $unicode = array();
- $values = array();
+ $unicode = [];
+ $values = [];
$lookingFor = 1;
// Gets unicode for each character
- for ($i = 0; $i < strlen($text); $i++) {
+ for ($i = 0; $i < strlen($text); ++$i) {
$thisValue = ord($text[$i]);
if ($thisValue < 128) {
$unicode[] = $thisValue;
@@ -187,7 +200,7 @@ public static function utf8ToUnicode($text)
$number = (($values[0] % 32) * 64) + ($values[1] % 64);
}
$unicode[] = $number;
- $values = array();
+ $values = [];
$lookingFor = 1;
}
}
@@ -197,10 +210,12 @@ public static function utf8ToUnicode($text)
}
/**
- * Returns entites from unicode array
+ * Returns entites from unicode array.
*
* @param array $unicode
+ *
* @return string
+ *
* @since 0.11.0
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
*/
@@ -218,14 +233,15 @@ private static function unicodeToEntities($unicode)
}
/**
- * Return name without underscore for < 0.10.0 variable name compatibility
+ * Return name without underscore for < 0.10.0 variable name compatibility.
*
* @param string $value
+ *
* @return string
*/
public static function removeUnderscorePrefix($value)
{
- if (!is_null($value)) {
+ if (null !== $value) {
if (substr($value, 0, 1) == '_') {
$value = substr($value, 1);
}
diff --git a/src/PhpWord/Shared/XMLReader.php b/src/PhpWord/Shared/XMLReader.php
index 3905c52f19..73762db2ea 100644
--- a/src/PhpWord/Shared/XMLReader.php
+++ b/src/PhpWord/Shared/XMLReader.php
@@ -11,48 +11,56 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Shared;
+use DOMDocument;
+use DOMElement;
+use DOMNodeList;
+use DOMXpath;
+use Exception;
+use InvalidArgumentException;
+use ZipArchive;
+
/**
- * XML Reader wrapper
+ * XML Reader wrapper.
*
* @since 0.2.1
*/
class XMLReader
{
/**
- * DOMDocument object
+ * DOMDocument object.
*
- * @var \DOMDocument
+ * @var DOMDocument
*/
- private $dom = null;
+ private $dom;
/**
- * DOMXpath object
+ * DOMXpath object.
*
- * @var \DOMXpath
+ * @var DOMXpath
*/
- private $xpath = null;
+ private $xpath;
/**
- * Get DOMDocument from ZipArchive
+ * Get DOMDocument from ZipArchive.
*
* @param string $zipFile
* @param string $xmlFile
- * @throws \Exception
- * @return \DOMDocument|false
+ *
+ * @return DOMDocument|false
*/
public function getDomFromZip($zipFile, $xmlFile)
{
if (file_exists($zipFile) === false) {
- throw new \Exception('Cannot find archive file.');
+ throw new Exception('Cannot find archive file.');
}
- $zip = new \ZipArchive();
+ $zip = new ZipArchive();
$zip->open($zipFile);
$content = $zip->getFromName($xmlFile);
$zip->close();
@@ -65,17 +73,18 @@ public function getDomFromZip($zipFile, $xmlFile)
}
/**
- * Get DOMDocument from content string
+ * Get DOMDocument from content string.
*
* @param string $content
- * @return \DOMDocument
+ *
+ * @return DOMDocument
*/
public function getDomFromString($content)
{
if (\PHP_VERSION_ID < 80000) {
$originalLibXMLEntityValue = libxml_disable_entity_loader(true);
}
- $this->dom = new \DOMDocument();
+ $this->dom = new DOMDocument();
$this->dom->loadXML($content);
if (\PHP_VERSION_ID < 80000) {
libxml_disable_entity_loader($originalLibXMLEntityValue);
@@ -85,22 +94,23 @@ public function getDomFromString($content)
}
/**
- * Get elements
+ * Get elements.
*
* @param string $path
- * @param \DOMElement $contextNode
- * @return \DOMNodeList
+ * @param DOMElement $contextNode
+ *
+ * @return DOMNodeList
*/
- public function getElements($path, \DOMElement $contextNode = null)
+ public function getElements($path, ?DOMElement $contextNode = null)
{
if ($this->dom === null) {
- return array();
+ return [];
}
if ($this->xpath === null) {
- $this->xpath = new \DOMXpath($this->dom);
+ $this->xpath = new DOMXpath($this->dom);
}
- if (is_null($contextNode)) {
+ if (null === $contextNode) {
return $this->xpath->query($path);
}
@@ -108,33 +118,34 @@ public function getElements($path, \DOMElement $contextNode = null)
}
/**
- * Registers the namespace with the DOMXPath object
+ * Registers the namespace with the DOMXPath object.
*
* @param string $prefix The prefix
* @param string $namespaceURI The URI of the namespace
- * @throws \InvalidArgumentException If called before having loaded the DOM document
+ *
* @return bool true on success or false on failure
*/
public function registerNamespace($prefix, $namespaceURI)
{
if ($this->dom === null) {
- throw new \InvalidArgumentException('Dom needs to be loaded before registering a namespace');
+ throw new InvalidArgumentException('Dom needs to be loaded before registering a namespace');
}
if ($this->xpath === null) {
- $this->xpath = new \DOMXpath($this->dom);
+ $this->xpath = new DOMXpath($this->dom);
}
return $this->xpath->registerNamespace($prefix, $namespaceURI);
}
/**
- * Get element
+ * Get element.
*
* @param string $path
- * @param \DOMElement $contextNode
- * @return \DOMElement|null
+ * @param DOMElement $contextNode
+ *
+ * @return null|DOMElement
*/
- public function getElement($path, \DOMElement $contextNode = null)
+ public function getElement($path, ?DOMElement $contextNode = null)
{
$elements = $this->getElements($path, $contextNode);
if ($elements->length > 0) {
@@ -145,20 +156,21 @@ public function getElement($path, \DOMElement $contextNode = null)
}
/**
- * Get element attribute
+ * Get element attribute.
*
* @param string $attribute
- * @param \DOMElement $contextNode
+ * @param DOMElement $contextNode
* @param string $path
- * @return string|null
+ *
+ * @return null|string
*/
- public function getAttribute($attribute, \DOMElement $contextNode = null, $path = null)
+ public function getAttribute($attribute, ?DOMElement $contextNode = null, $path = null)
{
$return = null;
if ($path !== null) {
$elements = $this->getElements($path, $contextNode);
if ($elements->length > 0) {
- /** @var \DOMElement $node Type hint */
+ /** @var DOMElement $node Type hint */
$node = $elements->item(0);
$return = $node->getAttribute($attribute);
}
@@ -172,13 +184,14 @@ public function getAttribute($attribute, \DOMElement $contextNode = null, $path
}
/**
- * Get element value
+ * Get element value.
*
* @param string $path
- * @param \DOMElement $contextNode
- * @return string|null
+ * @param DOMElement $contextNode
+ *
+ * @return null|string
*/
- public function getValue($path, \DOMElement $contextNode = null)
+ public function getValue($path, ?DOMElement $contextNode = null)
{
$elements = $this->getElements($path, $contextNode);
if ($elements->length > 0) {
@@ -189,13 +202,14 @@ public function getValue($path, \DOMElement $contextNode = null)
}
/**
- * Count elements
+ * Count elements.
*
* @param string $path
- * @param \DOMElement $contextNode
+ * @param DOMElement $contextNode
+ *
* @return int
*/
- public function countElements($path, \DOMElement $contextNode = null)
+ public function countElements($path, ?DOMElement $contextNode = null)
{
$elements = $this->getElements($path, $contextNode);
@@ -203,13 +217,14 @@ public function countElements($path, \DOMElement $contextNode = null)
}
/**
- * Element exists
+ * Element exists.
*
* @param string $path
- * @param \DOMElement $contextNode
+ * @param DOMElement $contextNode
+ *
* @return bool
*/
- public function elementExists($path, \DOMElement $contextNode = null)
+ public function elementExists($path, ?DOMElement $contextNode = null)
{
return $this->getElements($path, $contextNode)->length > 0;
}
diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php
index 4d0afc5e13..9f51c0e514 100644
--- a/src/PhpWord/Shared/XMLWriter.php
+++ b/src/PhpWord/Shared/XMLWriter.php
@@ -11,14 +11,17 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Shared;
+use Exception;
+use ReturnTypeWillChange;
+
/**
- * XMLWriter
+ * XMLWriter.
*
* @method bool endElement()
* @method mixed flush(bool $empty = null)
@@ -40,14 +43,14 @@ class XMLWriter extends \XMLWriter
const STORAGE_DISK = 2;
/**
- * Temporary filename
+ * Temporary filename.
*
* @var string
*/
private $tempFileName = '';
/**
- * Create a new \PhpOffice\PhpWord\Shared\XMLWriter instance
+ * Create a new \PhpOffice\PhpWord\Shared\XMLWriter instance.
*
* @param int $pTemporaryStorage Temporary storage location
* @param string $pTemporaryStorageDir Temporary storage folder
@@ -79,7 +82,7 @@ public function __construct($pTemporaryStorage = self::STORAGE_MEMORY, $pTempora
}
/**
- * Destructor
+ * Destructor.
*/
public function __destruct()
{
@@ -88,12 +91,12 @@ 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.');
}
}
/**
- * Get written data
+ * Get written data.
*
* @return string
*/
@@ -109,21 +112,21 @@ public function getData()
}
/**
- * Write simple element and attribute(s) block
+ * Write simple element and attribute(s) block.
*
* There are two options:
* 1. If the `$attributes` is an array, then it's an associative array of attributes
* 2. If not, then it's a simple attribute-value pair
*
* @param string $element
- * @param string|array $attributes
+ * @param array|string $attributes
* @param string $value
*/
- public function writeElementBlock($element, $attributes, $value = null)
+ public function writeElementBlock($element, $attributes, $value = null): void
{
$this->startElement($element);
if (!is_array($attributes)) {
- $attributes = array($attributes => $value);
+ $attributes = [$attributes => $value];
}
foreach ($attributes as $attribute => $value) {
$this->writeAttribute($attribute, $value);
@@ -139,10 +142,10 @@ public function writeElementBlock($element, $attributes, $value = null)
* @param string $attribute
* @param mixed $value
*/
- public function writeElementIf($condition, $element, $attribute = null, $value = null)
+ public function writeElementIf($condition, $element, $attribute = null, $value = null): void
{
if ($condition == true) {
- if (is_null($attribute)) {
+ if (null === $attribute) {
$this->writeElement($element, $value);
} else {
$this->startElement($element);
@@ -159,7 +162,7 @@ public function writeElementIf($condition, $element, $attribute = null, $value =
* @param string $attribute
* @param mixed $value
*/
- public function writeAttributeIf($condition, $attribute, $value)
+ public function writeAttributeIf($condition, $attribute, $value): void
{
if ($condition == true) {
$this->writeAttribute($attribute, $value);
@@ -169,9 +172,10 @@ public function writeAttributeIf($condition, $attribute, $value)
/**
* @param string $name
* @param mixed $value
+ *
* @return bool
*/
- #[\ReturnTypeWillChange]
+ #[ReturnTypeWillChange]
public function writeAttribute($name, $value)
{
if (is_float($value)) {
diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php
index 6517ca8abf..74922b2c2b 100644
--- a/src/PhpWord/Shared/ZipArchive.php
+++ b/src/PhpWord/Shared/ZipArchive.php
@@ -11,17 +11,18 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Shared;
+use PclZip;
use PhpOffice\PhpWord\Exception\Exception;
use PhpOffice\PhpWord\Settings;
/**
- * ZipArchive wrapper
+ * ZipArchive wrapper.
*
* Wraps zip archive functionality of PHP ZipArchive and PCLZip. PHP ZipArchive
* properties and methods are bypassed and used as the model for the PCLZip
@@ -41,42 +42,42 @@ class ZipArchive
const OVERWRITE = 8; // Emulate \ZipArchive::OVERWRITE
/**
- * Number of files (emulate ZipArchive::$numFiles)
+ * Number of files (emulate ZipArchive::$numFiles).
*
* @var int
*/
public $numFiles = 0;
/**
- * Archive filename (emulate ZipArchive::$filename)
+ * Archive filename (emulate ZipArchive::$filename).
*
* @var string
*/
public $filename;
/**
- * Temporary storage directory
+ * Temporary storage directory.
*
* @var string
*/
private $tempDir;
/**
- * Internal zip archive object
+ * Internal zip archive object.
*
- * @var \ZipArchive|\PclZip
+ * @var PclZip|\ZipArchive
*/
private $zip;
/**
- * Use PCLZip (default behaviour)
+ * Use PCLZip (default behaviour).
*
* @var bool
*/
private $usePclzip = true;
/**
- * Create new instance
+ * Create new instance.
*/
public function __construct()
{
@@ -90,12 +91,13 @@ public function __construct()
}
/**
- * Catch function calls: pass to ZipArchive or PCLZip
+ * Catch function calls: pass to ZipArchive or PCLZip.
*
* `call_user_func_array` can only used for public function, hence the `public` in all `pcl...` methods
*
* @param mixed $function
* @param mixed $args
+ *
* @return mixed
*/
public function __call($function, $args)
@@ -112,17 +114,18 @@ public function __call($function, $args)
// Run function
$result = false;
if (method_exists($zipObject, $zipFunction)) {
- $result = @call_user_func_array(array($zipObject, $zipFunction), $args);
+ $result = @call_user_func_array([$zipObject, $zipFunction], $args);
}
return $result;
}
/**
- * Open a new zip archive
+ * Open a new zip archive.
*
* @param string $filename The file name of the ZIP archive to open
* @param int $flags The mode to use to open the archive
+ *
* @return bool
*/
public function open($filename, $flags = null)
@@ -146,7 +149,7 @@ public function open($filename, $flags = null)
// See https://github.com/scrutinizer-ci/php-analyzer/issues/190
$this->numFiles = $zip->numFiles;
} else {
- $zip = new \PclZip($this->filename);
+ $zip = new PclZip($this->filename);
$zipContent = $zip->listContent();
$this->numFiles = is_array($zipContent) ? count($zipContent) : 0;
}
@@ -156,9 +159,7 @@ public function open($filename, $flags = null)
}
/**
- * Close the active archive
- *
- * @throws \PhpOffice\PhpWord\Exception\Exception
+ * Close the active archive.
*
* @return bool
*
@@ -176,11 +177,13 @@ public function close()
}
/**
- * Extract the archive contents (emulate \ZipArchive)
+ * Extract the archive contents (emulate \ZipArchive).
*
* @param string $destination
- * @param string|array $entries
+ * @param array|string $entries
+ *
* @return bool
+ *
* @since 0.10.0
*/
public function extractTo($destination, $entries = null)
@@ -197,9 +200,10 @@ public function extractTo($destination, $entries = null)
}
/**
- * Extract file from archive by given file name (emulate \ZipArchive)
+ * Extract file from archive by given file name (emulate \ZipArchive).
*
* @param string $filename Filename for the file in zip archive
+ *
* @return string $contents File string contents
*/
public function getFromName($filename)
@@ -218,15 +222,16 @@ public function getFromName($filename)
}
/**
- * Add a new file to the zip archive (emulate \ZipArchive)
+ * Add a new file to the zip archive (emulate \ZipArchive).
*
* @param string $filename Directory/Name of the file to add to the zip archive
* @param string $localname Directory/Name of the file added to the zip
+ *
* @return bool
*/
public function pclzipAddFile($filename, $localname = null)
{
- /** @var \PclZip $zip Type hint */
+ /** @var PclZip $zip Type hint */
$zip = $this->zip;
// Bugfix GH-261 https://github.com/PHPOffice/PHPWord/pull/261
@@ -269,15 +274,16 @@ public function pclzipAddFile($filename, $localname = null)
}
/**
- * Add a new file to the zip archive from a string of raw data (emulate \ZipArchive)
+ * Add a new file to the zip archive from a string of raw data (emulate \ZipArchive).
*
* @param string $localname Directory/Name of the file to add to the zip archive
* @param string $contents String of data to add to the zip archive
+ *
* @return bool
*/
public function pclzipAddFromString($localname, $contents)
{
- /** @var \PclZip $zip Type hint */
+ /** @var PclZip $zip Type hint */
$zip = $this->zip;
$filenameParts = pathinfo($localname);
@@ -300,20 +306,22 @@ public function pclzipAddFromString($localname, $contents)
}
/**
- * Extract the archive contents (emulate \ZipArchive)
+ * Extract the archive contents (emulate \ZipArchive).
*
* @param string $destination
- * @param string|array $entries
+ * @param array|string $entries
+ *
* @return bool
+ *
* @since 0.10.0
*/
public function pclzipExtractTo($destination, $entries = null)
{
- /** @var \PclZip $zip Type hint */
+ /** @var PclZip $zip Type hint */
$zip = $this->zip;
// Extract all files
- if (is_null($entries)) {
+ if (null === $entries) {
$result = $zip->extract(PCLZIP_OPT_PATH, $destination);
return $result > 0;
@@ -321,7 +329,7 @@ public function pclzipExtractTo($destination, $entries = null)
// Extract by entries
if (!is_array($entries)) {
- $entries = array($entries);
+ $entries = [$entries];
}
foreach ($entries as $entry) {
$entryIndex = $this->locateName($entry);
@@ -335,14 +343,15 @@ public function pclzipExtractTo($destination, $entries = null)
}
/**
- * Extract file from archive by given file name (emulate \ZipArchive)
+ * Extract file from archive by given file name (emulate \ZipArchive).
*
* @param string $filename Filename for the file in zip archive
+ *
* @return string $contents File string contents
*/
public function pclzipGetFromName($filename)
{
- /** @var \PclZip $zip Type hint */
+ /** @var PclZip $zip Type hint */
$zip = $this->zip;
$listIndex = $this->pclzipLocateName($filename);
$contents = false;
@@ -362,15 +371,17 @@ public function pclzipGetFromName($filename)
}
/**
- * Returns the name of an entry using its index (emulate \ZipArchive)
+ * Returns the name of an entry using its index (emulate \ZipArchive).
*
* @param int $index
- * @return string|bool
+ *
+ * @return bool|string
+ *
* @since 0.10.0
*/
public function pclzipGetNameIndex($index)
{
- /** @var \PclZip $zip Type hint */
+ /** @var PclZip $zip Type hint */
$zip = $this->zip;
$list = $zip->listContent();
if (isset($list[$index])) {
@@ -381,14 +392,15 @@ public function pclzipGetNameIndex($index)
}
/**
- * Returns the index of the entry in the archive (emulate \ZipArchive)
+ * Returns the index of the entry in the archive (emulate \ZipArchive).
*
* @param string $filename Filename for the file in zip archive
+ *
* @return int
*/
public function pclzipLocateName($filename)
{
- /** @var \PclZip $zip Type hint */
+ /** @var PclZip $zip Type hint */
$zip = $this->zip;
$list = $zip->listContent();
$listCount = count($list);
@@ -397,6 +409,7 @@ public function pclzipLocateName($filename)
if (strtolower($list[$i]['filename']) == strtolower($filename) ||
strtolower($list[$i]['stored_filename']) == strtolower($filename)) {
$listIndex = $i;
+
break;
}
}
diff --git a/src/PhpWord/SimpleType/Border.php b/src/PhpWord/SimpleType/Border.php
index a73c7b4a67..6cb42f0467 100644
--- a/src/PhpWord/SimpleType/Border.php
+++ b/src/PhpWord/SimpleType/Border.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -23,7 +23,6 @@
* Border Styles.
*
* @since 0.18.0
- *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_Border.html
*/
final class Border extends AbstractEnum
diff --git a/src/PhpWord/SimpleType/DocProtect.php b/src/PhpWord/SimpleType/DocProtect.php
index e386913d53..2d13485493 100644
--- a/src/PhpWord/SimpleType/DocProtect.php
+++ b/src/PhpWord/SimpleType/DocProtect.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,36 +20,35 @@
use PhpOffice\PhpWord\Shared\AbstractEnum;
/**
- * Document Protection Types
+ * Document Protection Types.
*
* @since 0.14.0
- *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_DocProtect.html
*/
final class DocProtect extends AbstractEnum
{
/**
- * No Editing Restrictions
+ * No Editing Restrictions.
*/
const NONE = 'none';
/**
- * Allow No Editing
+ * Allow No Editing.
*/
const READ_ONLY = 'readOnly';
/**
- * Allow Editing of Comments
+ * Allow Editing of Comments.
*/
const COMMENTS = 'comments';
/**
- * Allow Editing With Revision Tracking
+ * Allow Editing With Revision Tracking.
*/
const TRACKED_CHANGES = 'trackedChanges';
/**
- * Allow Editing of Form Fields
+ * Allow Editing of Form Fields.
*/
const FORMS = 'forms';
}
diff --git a/src/PhpWord/SimpleType/Jc.php b/src/PhpWord/SimpleType/Jc.php
index e55f824d14..ab665822c4 100644
--- a/src/PhpWord/SimpleType/Jc.php
+++ b/src/PhpWord/SimpleType/Jc.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,7 +26,6 @@
* Since ISO/IEC-29500:2008 the type must not be used for table alignment.
*
* @since 0.13.0
- *
* @see \PhpOffice\PhpWord\SimpleType\JcTable For table alignment modes available since ISO/IEC-29500:2008.
* @see http://www.datypic.com/sc/ooxml/t-w_ST_Jc.html
*/
diff --git a/src/PhpWord/SimpleType/JcTable.php b/src/PhpWord/SimpleType/JcTable.php
index 924a4f2014..86a1b03462 100644
--- a/src/PhpWord/SimpleType/JcTable.php
+++ b/src/PhpWord/SimpleType/JcTable.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/SimpleType/LineSpacingRule.php b/src/PhpWord/SimpleType/LineSpacingRule.php
index 8fd8340c43..833b626953 100644
--- a/src/PhpWord/SimpleType/LineSpacingRule.php
+++ b/src/PhpWord/SimpleType/LineSpacingRule.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,26 +20,25 @@
use PhpOffice\PhpWord\Shared\AbstractEnum;
/**
- * Line Spacing Rule
+ * Line Spacing Rule.
*
* @since 0.14.0
- *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_LineSpacingRule.html
*/
final class LineSpacingRule extends AbstractEnum
{
/**
- * Automatically Determined Line Height
+ * Automatically Determined Line Height.
*/
const AUTO = 'auto';
/**
- * Exact Line Height
+ * Exact Line Height.
*/
const EXACT = 'exact';
/**
- * Minimum Line Height
+ * Minimum Line Height.
*/
const AT_LEAST = 'atLeast';
}
diff --git a/src/PhpWord/SimpleType/NumberFormat.php b/src/PhpWord/SimpleType/NumberFormat.php
index 83da66fa3f..36a678e8ce 100644
--- a/src/PhpWord/SimpleType/NumberFormat.php
+++ b/src/PhpWord/SimpleType/NumberFormat.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -23,7 +23,6 @@
* Numbering Format.
*
* @since 0.14.0
- *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_NumberFormat.html.
*/
final class NumberFormat extends AbstractEnum
diff --git a/src/PhpWord/SimpleType/TblWidth.php b/src/PhpWord/SimpleType/TblWidth.php
index 7fd753deb0..28ba0db2d1 100644
--- a/src/PhpWord/SimpleType/TblWidth.php
+++ b/src/PhpWord/SimpleType/TblWidth.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,10 +20,9 @@
use PhpOffice\PhpWord\Shared\AbstractEnum;
/**
- * Table Width Units
+ * Table Width Units.
*
* @since 0.15.0
- *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_TblWidth.html
*/
final class TblWidth extends AbstractEnum
diff --git a/src/PhpWord/SimpleType/TextAlignment.php b/src/PhpWord/SimpleType/TextAlignment.php
index 838b0c5e0e..1f2af0fd89 100644
--- a/src/PhpWord/SimpleType/TextAlignment.php
+++ b/src/PhpWord/SimpleType/TextAlignment.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,10 +20,9 @@
use PhpOffice\PhpWord\Shared\AbstractEnum;
/**
- * Magnification Preset Values
+ * Magnification Preset Values.
*
* @since 0.14.0
- *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_TextAlignment.html
*/
final class TextAlignment extends AbstractEnum
diff --git a/src/PhpWord/SimpleType/VerticalJc.php b/src/PhpWord/SimpleType/VerticalJc.php
index 2a37de417d..147cd20910 100644
--- a/src/PhpWord/SimpleType/VerticalJc.php
+++ b/src/PhpWord/SimpleType/VerticalJc.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/SimpleType/Zoom.php b/src/PhpWord/SimpleType/Zoom.php
index 02c38fdb6a..fc53ec8ff3 100644
--- a/src/PhpWord/SimpleType/Zoom.php
+++ b/src/PhpWord/SimpleType/Zoom.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,10 +20,9 @@
use PhpOffice\PhpWord\Shared\AbstractEnum;
/**
- * Magnification Preset Values
+ * Magnification Preset Values.
*
* @since 0.14.0
- *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_Zoom.html
*/
final class Zoom extends AbstractEnum
diff --git a/src/PhpWord/Style.php b/src/PhpWord/Style.php
index 62783b6301..23107ef535 100644
--- a/src/PhpWord/Style.php
+++ b/src/PhpWord/Style.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -24,22 +24,23 @@
use PhpOffice\PhpWord\Style\Table;
/**
- * Style collection
+ * Style collection.
*/
class Style
{
/**
- * Style register
+ * Style register.
*
* @var array
*/
- private static $styles = array();
+ private static $styles = [];
/**
- * Add paragraph style
+ * Add paragraph style.
*
* @param string $styleName
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $styles
+ *
* @return \PhpOffice\PhpWord\Style\Paragraph
*/
public static function addParagraphStyle($styleName, $styles)
@@ -48,11 +49,12 @@ public static function addParagraphStyle($styleName, $styles)
}
/**
- * Add font style
+ * Add font style.
*
* @param string $styleName
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $fontStyle
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $paragraphStyle
+ *
* @return \PhpOffice\PhpWord\Style\Font
*/
public static function addFontStyle($styleName, $fontStyle, $paragraphStyle = null)
@@ -61,10 +63,11 @@ public static function addFontStyle($styleName, $fontStyle, $paragraphStyle = nu
}
/**
- * Add link style
+ * Add link style.
*
* @param string $styleName
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $styles
+ *
* @return \PhpOffice\PhpWord\Style\Font
*/
public static function addLinkStyle($styleName, $styles)
@@ -73,11 +76,13 @@ public static function addLinkStyle($styleName, $styles)
}
/**
- * Add numbering style
+ * Add numbering style.
*
* @param string $styleName
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $styleValues
+ *
* @return \PhpOffice\PhpWord\Style\Numbering
+ *
* @since 0.10.0
*/
public static function addNumberingStyle($styleName, $styleValues)
@@ -86,11 +91,12 @@ public static function addNumberingStyle($styleName, $styleValues)
}
/**
- * Add title style
+ * Add title style.
*
- * @param int|null $depth Provide null to set title font
+ * @param null|int $depth Provide null to set title font
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $fontStyle
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $paragraphStyle
+ *
* @return \PhpOffice\PhpWord\Style\Font
*/
public static function addTitleStyle($depth, $fontStyle, $paragraphStyle = null)
@@ -105,11 +111,12 @@ public static function addTitleStyle($depth, $fontStyle, $paragraphStyle = null)
}
/**
- * Add table style
+ * Add table style.
*
* @param string $styleName
* @param array $styleTable
- * @param array|null $styleFirstRow
+ * @param null|array $styleFirstRow
+ *
* @return \PhpOffice\PhpWord\Style\Table
*/
public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null)
@@ -118,9 +125,10 @@ public static function addTableStyle($styleName, $styleTable, $styleFirstRow = n
}
/**
- * Count styles
+ * Count styles.
*
* @return int
+ *
* @since 0.10.0
*/
public static function countStyles()
@@ -133,15 +141,16 @@ public static function countStyles()
*
* @since 0.10.0
*/
- public static function resetStyles()
+ public static function resetStyles(): void
{
- self::$styles = array();
+ self::$styles = [];
}
/**
- * Set default paragraph style
+ * Set default paragraph style.
*
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $styles Paragraph style definition
+ *
* @return \PhpOffice\PhpWord\Style\Paragraph
*/
public static function setDefaultParagraphStyle($styles)
@@ -150,7 +159,7 @@ public static function setDefaultParagraphStyle($styles)
}
/**
- * Get all styles
+ * Get all styles.
*
* @return \PhpOffice\PhpWord\Style\AbstractStyle[]
*/
@@ -160,9 +169,10 @@ public static function getStyles()
}
/**
- * Get style by name
+ * Get style by name.
*
* @param string $styleName
+ *
* @return \PhpOffice\PhpWord\Style\AbstractStyle Paragraph|Font|Table|Numbering
*/
public static function getStyle($styleName)
@@ -175,13 +185,14 @@ public static function getStyle($styleName)
}
/**
- * Set style values and put it to static style collection
+ * Set style values and put it to static style collection.
*
* The $styleValues could be an array or object
*
* @param string $name
* @param \PhpOffice\PhpWord\Style\AbstractStyle $style
* @param array|\PhpOffice\PhpWord\Style\AbstractStyle $value
+ *
* @return \PhpOffice\PhpWord\Style\AbstractStyle
*/
private static function setStyleValues($name, $style, $value = null)
diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php
index aca6635faa..d3e1e81877 100644
--- a/src/PhpWord/Style/AbstractStyle.php
+++ b/src/PhpWord/Style/AbstractStyle.php
@@ -11,54 +11,56 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
+use InvalidArgumentException;
use PhpOffice\PhpWord\Shared\Text;
/**
- * Abstract style class
+ * Abstract style class.
*
* @since 0.10.0
*/
abstract class AbstractStyle
{
/**
- * Style name
+ * Style name.
*
* @var string
*/
protected $styleName;
/**
- * Index number in Style collection for named style
+ * Index number in Style collection for named style.
*
* This number starts from one and defined in Style::setStyleValues()
*
- * @var int|null
+ * @var null|int
*/
protected $index;
/**
- * Aliases
+ * Aliases.
*
* @var array
*/
- protected $aliases = array();
+ protected $aliases = [];
/**
- * Is this an automatic style? (Used primarily in OpenDocument driver)
+ * Is this an automatic style? (Used primarily in OpenDocument driver).
*
* @var bool
+ *
* @since 0.11.0
*/
private $isAuto = false;
/**
- * Get style name
+ * Get style name.
*
* @return string
*/
@@ -68,9 +70,10 @@ public function getStyleName()
}
/**
- * Set style name
+ * Set style name.
*
* @param string $value
+ *
* @return self
*/
public function setStyleName($value)
@@ -81,9 +84,9 @@ public function setStyleName($value)
}
/**
- * Get index number
+ * Get index number.
*
- * @return int|null
+ * @return null|int
*/
public function getIndex()
{
@@ -91,9 +94,10 @@ public function getIndex()
}
/**
- * Set index number
+ * Set index number.
+ *
+ * @param null|int $value
*
- * @param int|null $value
* @return self
*/
public function setIndex($value = null)
@@ -104,7 +108,7 @@ public function setIndex($value = null)
}
/**
- * Get is automatic style flag
+ * Get is automatic style flag.
*
* @return bool
*/
@@ -114,9 +118,10 @@ public function isAuto()
}
/**
- * Set is automatic style flag
+ * Set is automatic style flag.
*
* @param bool $value
+ *
* @return self
*/
public function setAuto($value = true)
@@ -127,11 +132,13 @@ public function setAuto($value = true)
}
/**
- * Return style value of child style object, e.g. `left` from `Indentation` child style of `Paragraph`
+ * Return style value of child style object, e.g. `left` from `Indentation` child style of `Paragraph`.
*
* @param \PhpOffice\PhpWord\Style\AbstractStyle $substyleObject
* @param string $substyleProperty
+ *
* @return mixed
+ *
* @since 0.12.0
*/
public function getChildStyleValue($substyleObject, $substyleProperty)
@@ -146,7 +153,7 @@ public function getChildStyleValue($substyleObject, $substyleProperty)
}
/**
- * Set style value template method
+ * Set style value template method.
*
* Some child classes have their own specific overrides.
* Backward compability check for versions < 0.10.0 which use underscore
@@ -155,6 +162,7 @@ public function getChildStyleValue($substyleObject, $substyleProperty)
*
* @param string $key
* @param string $value
+ *
* @return self
*/
public function setStyleValue($key, $value)
@@ -171,12 +179,13 @@ public function setStyleValue($key, $value)
}
/**
- * Set style by using associative array
+ * Set style by using associative array.
*
* @param array $values
+ *
* @return self
*/
- public function setStyleByArray($values = array())
+ public function setStyleByArray($values = [])
{
foreach ($values as $key => $value) {
$this->setStyleValue($key, $value);
@@ -186,10 +195,11 @@ public function setStyleByArray($values = array())
}
/**
- * Set default for null and empty value
+ * Set default for null and empty value.
*
* @param string $value (was: mixed)
* @param string $default (was: mixed)
+ *
* @return string (was: mixed)
*/
protected function setNonEmptyVal($value, $default)
@@ -202,10 +212,11 @@ protected function setNonEmptyVal($value, $default)
}
/**
- * Set bool value
+ * Set bool value.
*
* @param bool $value
* @param bool $default
+ *
* @return bool
*/
protected function setBoolVal($value, $default)
@@ -218,11 +229,12 @@ protected function setBoolVal($value, $default)
}
/**
- * Set numeric value
+ * Set numeric value.
*
* @param mixed $value
- * @param int|float|null $default
- * @return int|float|null
+ * @param null|float|int $default
+ *
+ * @return null|float|int
*/
protected function setNumericVal($value, $default = null)
{
@@ -234,11 +246,12 @@ protected function setNumericVal($value, $default = null)
}
/**
- * Set integer value: Convert string that contains only numeric into integer
+ * Set integer value: Convert string that contains only numeric into integer.
+ *
+ * @param null|int $value
+ * @param null|int $default
*
- * @param int|null $value
- * @param int|null $default
- * @return int|null
+ * @return null|int
*/
protected function setIntVal($value, $default = null)
{
@@ -255,11 +268,12 @@ protected function setIntVal($value, $default = null)
}
/**
- * Set float value: Convert string that contains only numeric into float
+ * Set float value: Convert string that contains only numeric into float.
*
* @param mixed $value
- * @param float|null $default
- * @return float|null
+ * @param null|float $default
+ *
+ * @return null|float
*/
protected function setFloatVal($value, $default = null)
{
@@ -274,19 +288,18 @@ protected function setFloatVal($value, $default = null)
}
/**
- * Set enum value
+ * Set enum value.
*
* @param mixed $value
* @param array $enum
* @param mixed $default
*
- * @throws \InvalidArgumentException
* @return mixed
*/
- protected function setEnumVal($value = null, $enum = array(), $default = null)
+ protected function setEnumVal($value = null, $enum = [], $default = null)
{
if ($value != null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) {
- throw new \InvalidArgumentException("Invalid style value: {$value} Options:" . implode(',', $enum));
+ throw new InvalidArgumentException("Invalid style value: {$value} Options:" . implode(',', $enum));
} elseif ($value === null || trim($value) == '') {
$value = $default;
}
@@ -295,16 +308,17 @@ protected function setEnumVal($value = null, $enum = array(), $default = null)
}
/**
- * Set object value
+ * Set object value.
*
* @param mixed $value
* @param string $styleName
* @param mixed &$style
+ *
* @return mixed
*/
protected function setObjectVal($value, $styleName, &$style)
{
- $styleClass = substr(get_class($this), 0, strrpos(get_class($this), '\\')) . '\\' . $styleName;
+ $styleClass = substr(static::class, 0, strrpos(static::class, '\\')) . '\\' . $styleName;
if (is_array($value)) {
/** @var \PhpOffice\PhpWord\Style\AbstractStyle $style Type hint */
if (!$style instanceof $styleClass) {
@@ -319,11 +333,12 @@ protected function setObjectVal($value, $styleName, &$style)
}
/**
- * Set $property value and set $pairProperty = false when $value = true
+ * Set $property value and set $pairProperty = false when $value = true.
*
* @param bool &$property
* @param bool &$pairProperty
* @param bool $value
+ *
* @return self
*/
protected function setPairedVal(&$property, &$pairProperty, $value)
@@ -337,17 +352,15 @@ protected function setPairedVal(&$property, &$pairProperty, $value)
}
/**
- * Set style using associative array
+ * Set style using associative array.
*
* @deprecated 0.11.0
*
- * @param array $style
- *
* @return self
*
* @codeCoverageIgnore
*/
- public function setArrayStyle(array $style = array())
+ public function setArrayStyle(array $style = [])
{
return $this->setStyleByArray($style);
}
diff --git a/src/PhpWord/Style/Border.php b/src/PhpWord/Style/Border.php
index d032d07faa..2ee69be56f 100644
--- a/src/PhpWord/Style/Border.php
+++ b/src/PhpWord/Style/Border.php
@@ -11,120 +11,121 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Border style
+ * Border style.
*/
class Border extends AbstractStyle
{
/**
- * Border Top Size
+ * Border Top Size.
*
- * @var int|float
+ * @var float|int
*/
protected $borderTopSize;
/**
- * Border Top Color
+ * Border Top Color.
*
* @var string
*/
protected $borderTopColor;
/**
- * Border Top Style
+ * Border Top Style.
*
* @var string
*/
protected $borderTopStyle;
/**
- * Border Left Size
+ * Border Left Size.
*
- * @var int|float
+ * @var float|int
*/
protected $borderLeftSize;
/**
- * Border Left Color
+ * Border Left Color.
*
* @var string
*/
protected $borderLeftColor;
/**
- * Border Left Style
+ * Border Left Style.
*
* @var string
*/
protected $borderLeftStyle;
/**
- * Border Right Size
+ * Border Right Size.
*
- * @var int|float
+ * @var float|int
*/
protected $borderRightSize;
/**
- * Border Right Color
+ * Border Right Color.
*
* @var string
*/
protected $borderRightColor;
/**
- * Border Right Style
+ * Border Right Style.
*
* @var string
*/
protected $borderRightStyle;
/**
- * Border Bottom Size
+ * Border Bottom Size.
*
- * @var int|float
+ * @var float|int
*/
protected $borderBottomSize;
/**
- * Border Bottom Color
+ * Border Bottom Color.
*
* @var string
*/
protected $borderBottomColor;
/**
- * Border Bottom Style
+ * Border Bottom Style.
*
* @var string
*/
protected $borderBottomStyle;
/**
- * Get border size
+ * Get border size.
*
* @return int[]
*/
public function getBorderSize()
{
- return array(
+ return [
$this->getBorderTopSize(),
$this->getBorderLeftSize(),
$this->getBorderRightSize(),
$this->getBorderBottomSize(),
- );
+ ];
}
/**
- * Set border size
+ * Set border size.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setBorderSize($value = null)
@@ -138,24 +139,25 @@ public function setBorderSize($value = null)
}
/**
- * Get border color
+ * Get border color.
*
* @return string[]
*/
public function getBorderColor()
{
- return array(
+ return [
$this->getBorderTopColor(),
$this->getBorderLeftColor(),
$this->getBorderRightColor(),
$this->getBorderBottomColor(),
- );
+ ];
}
/**
- * Set border color
+ * Set border color.
*
* @param string $value
+ *
* @return self
*/
public function setBorderColor($value = null)
@@ -169,24 +171,25 @@ public function setBorderColor($value = null)
}
/**
- * Get border style
+ * Get border style.
*
* @return string[]
*/
public function getBorderStyle()
{
- return array(
+ return [
$this->getBorderTopStyle(),
$this->getBorderLeftStyle(),
$this->getBorderRightStyle(),
$this->getBorderBottomStyle(),
- );
+ ];
}
/**
- * Set border style
+ * Set border style.
*
* @param string $value
+ *
* @return self
*/
public function setBorderStyle($value = null)
@@ -200,9 +203,9 @@ public function setBorderStyle($value = null)
}
/**
- * Get border top size
+ * Get border top size.
*
- * @return int|float
+ * @return float|int
*/
public function getBorderTopSize()
{
@@ -210,9 +213,10 @@ public function getBorderTopSize()
}
/**
- * Set border top size
+ * Set border top size.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setBorderTopSize($value = null)
@@ -223,7 +227,7 @@ public function setBorderTopSize($value = null)
}
/**
- * Get border top color
+ * Get border top color.
*
* @return string
*/
@@ -233,9 +237,10 @@ public function getBorderTopColor()
}
/**
- * Set border top color
+ * Set border top color.
*
* @param string $value
+ *
* @return self
*/
public function setBorderTopColor($value = null)
@@ -246,7 +251,7 @@ public function setBorderTopColor($value = null)
}
/**
- * Get border top style
+ * Get border top style.
*
* @return string
*/
@@ -256,9 +261,10 @@ public function getBorderTopStyle()
}
/**
- * Set border top Style
+ * Set border top Style.
*
* @param string $value
+ *
* @return self
*/
public function setBorderTopStyle($value = null)
@@ -269,9 +275,9 @@ public function setBorderTopStyle($value = null)
}
/**
- * Get border left size
+ * Get border left size.
*
- * @return int|float
+ * @return float|int
*/
public function getBorderLeftSize()
{
@@ -279,9 +285,10 @@ public function getBorderLeftSize()
}
/**
- * Set border left size
+ * Set border left size.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setBorderLeftSize($value = null)
@@ -292,7 +299,7 @@ public function setBorderLeftSize($value = null)
}
/**
- * Get border left color
+ * Get border left color.
*
* @return string
*/
@@ -302,9 +309,10 @@ public function getBorderLeftColor()
}
/**
- * Set border left color
+ * Set border left color.
*
* @param string $value
+ *
* @return self
*/
public function setBorderLeftColor($value = null)
@@ -315,7 +323,7 @@ public function setBorderLeftColor($value = null)
}
/**
- * Get border left style
+ * Get border left style.
*
* @return string
*/
@@ -325,9 +333,10 @@ public function getBorderLeftStyle()
}
/**
- * Set border left style
+ * Set border left style.
*
* @param string $value
+ *
* @return self
*/
public function setBorderLeftStyle($value = null)
@@ -338,9 +347,9 @@ public function setBorderLeftStyle($value = null)
}
/**
- * Get border right size
+ * Get border right size.
*
- * @return int|float
+ * @return float|int
*/
public function getBorderRightSize()
{
@@ -348,9 +357,10 @@ public function getBorderRightSize()
}
/**
- * Set border right size
+ * Set border right size.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setBorderRightSize($value = null)
@@ -361,7 +371,7 @@ public function setBorderRightSize($value = null)
}
/**
- * Get border right color
+ * Get border right color.
*
* @return string
*/
@@ -371,9 +381,10 @@ public function getBorderRightColor()
}
/**
- * Set border right color
+ * Set border right color.
*
* @param string $value
+ *
* @return self
*/
public function setBorderRightColor($value = null)
@@ -384,7 +395,7 @@ public function setBorderRightColor($value = null)
}
/**
- * Get border right style
+ * Get border right style.
*
* @return string
*/
@@ -394,9 +405,10 @@ public function getBorderRightStyle()
}
/**
- * Set border right style
+ * Set border right style.
*
* @param string $value
+ *
* @return self
*/
public function setBorderRightStyle($value = null)
@@ -407,9 +419,9 @@ public function setBorderRightStyle($value = null)
}
/**
- * Get border bottom size
+ * Get border bottom size.
*
- * @return int|float
+ * @return float|int
*/
public function getBorderBottomSize()
{
@@ -417,9 +429,10 @@ public function getBorderBottomSize()
}
/**
- * Set border bottom size
+ * Set border bottom size.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setBorderBottomSize($value = null)
@@ -430,7 +443,7 @@ public function setBorderBottomSize($value = null)
}
/**
- * Get border bottom color
+ * Get border bottom color.
*
* @return string
*/
@@ -440,9 +453,10 @@ public function getBorderBottomColor()
}
/**
- * Set border bottom color
+ * Set border bottom color.
*
* @param string $value
+ *
* @return self
*/
public function setBorderBottomColor($value = null)
@@ -453,7 +467,7 @@ public function setBorderBottomColor($value = null)
}
/**
- * Get border bottom style
+ * Get border bottom style.
*
* @return string
*/
@@ -463,9 +477,10 @@ public function getBorderBottomStyle()
}
/**
- * Set border bottom style
+ * Set border bottom style.
*
* @param string $value
+ *
* @return self
*/
public function setBorderBottomStyle($value = null)
@@ -476,7 +491,7 @@ public function setBorderBottomStyle($value = null)
}
/**
- * Check if any of the border is not null
+ * Check if any of the border is not null.
*
* @return bool
*/
diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php
index 1276b5b59a..420f8dc50c 100644
--- a/src/PhpWord/Style/Cell.php
+++ b/src/PhpWord/Style/Cell.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,14 +21,15 @@
use PhpOffice\PhpWord\SimpleType\VerticalJc;
/**
- * Table cell style
+ * Table cell style.
*/
class Cell extends Border
{
/**
- * Vertical alignment constants
+ * Vertical alignment constants.
*
* @const string
+ *
* @deprecated Use \PhpOffice\PhpWord\SimpleType\VerticalJc::TOP instead
*/
const VALIGN_TOP = 'top';
@@ -47,32 +48,32 @@ class Cell extends Border
//Text direction constants
/**
- * Left to Right, Top to Bottom
+ * Left to Right, Top to Bottom.
*/
const TEXT_DIR_LRTB = 'lrTb';
/**
- * Top to Bottom, Right to Left
+ * Top to Bottom, Right to Left.
*/
const TEXT_DIR_TBRL = 'tbRl';
/**
- * Bottom to Top, Left to Right
+ * Bottom to Top, Left to Right.
*/
const TEXT_DIR_BTLR = 'btLr';
/**
- * Left to Right, Top to Bottom Rotated
+ * Left to Right, Top to Bottom Rotated.
*/
const TEXT_DIR_LRTBV = 'lrTbV';
/**
- * Top to Bottom, Right to Left Rotated
+ * Top to Bottom, Right to Left Rotated.
*/
const TEXT_DIR_TBRLV = 'tbRlV';
/**
- * Top to Bottom, Left to Right Rotated
+ * Top to Bottom, Left to Right Rotated.
*/
const TEXT_DIR_TBLRV = 'tbLrV';
/**
- * Vertical merge (rowspan) constants
+ * Vertical merge (rowspan) constants.
*
* @const string
*/
@@ -80,35 +81,35 @@ class Cell extends Border
const VMERGE_CONTINUE = 'continue';
/**
- * Default border color
+ * Default border color.
*
* @const string
*/
const DEFAULT_BORDER_COLOR = '000000';
/**
- * Vertical align (top, center, both, bottom)
+ * Vertical align (top, center, both, bottom).
*
* @var string
*/
private $vAlign;
/**
- * Text Direction
+ * Text Direction.
*
* @var string
*/
private $textDirection;
/**
- * colspan
+ * colspan.
*
* @var int
*/
private $gridSpan;
/**
- * rowspan (restart, continue)
+ * rowspan (restart, continue).
*
* - restart: Start/restart merged region
* - continue: Continue merged region
@@ -118,21 +119,21 @@ class Cell extends Border
private $vMerge;
/**
- * Shading
+ * Shading.
*
* @var \PhpOffice\PhpWord\Style\Shading
*/
private $shading;
/**
- * Width
+ * Width.
*
* @var int
*/
private $width;
/**
- * Width unit
+ * Width unit.
*
* @var string
*/
@@ -149,9 +150,10 @@ public function getVAlign()
}
/**
- * Set vertical align
+ * Set vertical align.
*
* @param string $value
+ *
* @return self
*/
public function setVAlign($value = null)
@@ -173,21 +175,22 @@ public function getTextDirection()
}
/**
- * Set text direction
+ * Set text direction.
*
* @param string $value
+ *
* @return self
*/
public function setTextDirection($value = null)
{
- $enum = array(self::TEXT_DIR_BTLR, self::TEXT_DIR_TBRL);
+ $enum = [self::TEXT_DIR_BTLR, self::TEXT_DIR_TBRL];
$this->textDirection = $this->setEnumVal($value, $enum, $this->textDirection);
return $this;
}
/**
- * Get background
+ * Get background.
*
* @return string
*/
@@ -201,14 +204,15 @@ public function getBgColor()
}
/**
- * Set background
+ * Set background.
*
* @param string $value
+ *
* @return self
*/
public function setBgColor($value = null)
{
- return $this->setShading(array('fill' => $value));
+ return $this->setShading(['fill' => $value]);
}
/**
@@ -222,9 +226,10 @@ public function getGridSpan()
}
/**
- * Set grid span (colspan)
+ * Set grid span (colspan).
*
* @param int $value
+ *
* @return self
*/
public function setGridSpan($value = null)
@@ -245,21 +250,22 @@ public function getVMerge()
}
/**
- * Set vertical merge (rowspan)
+ * Set vertical merge (rowspan).
*
* @param string $value
+ *
* @return self
*/
public function setVMerge($value = null)
{
- $enum = array(self::VMERGE_RESTART, self::VMERGE_CONTINUE);
+ $enum = [self::VMERGE_RESTART, self::VMERGE_CONTINUE];
$this->vMerge = $this->setEnumVal($value, $enum, $this->vMerge);
return $this;
}
/**
- * Get shading
+ * Get shading.
*
* @return \PhpOffice\PhpWord\Style\Shading
*/
@@ -269,9 +275,10 @@ public function getShading()
}
/**
- * Set shading
+ * Set shading.
*
* @param mixed $value
+ *
* @return self
*/
public function setShading($value = null)
@@ -282,7 +289,7 @@ public function setShading($value = null)
}
/**
- * Get cell width
+ * Get cell width.
*
* @return int
*/
@@ -292,9 +299,10 @@ public function getWidth()
}
/**
- * Set cell width
+ * Set cell width.
*
* @param int $value
+ *
* @return self
*/
public function setWidth($value)
@@ -305,7 +313,7 @@ public function setWidth($value)
}
/**
- * Get width unit
+ * Get width unit.
*
* @return string
*/
@@ -315,19 +323,19 @@ public function getUnit()
}
/**
- * Set width unit
+ * Set width unit.
*
* @param string $value
*/
public function setUnit($value)
{
- $this->unit = $this->setEnumVal($value, array(TblWidth::AUTO, TblWidth::PERCENT, TblWidth::TWIP), TblWidth::TWIP);
+ $this->unit = $this->setEnumVal($value, [TblWidth::AUTO, TblWidth::PERCENT, TblWidth::TWIP], TblWidth::TWIP);
return $this;
}
/**
- * Get default border color
+ * Get default border color.
*
* @deprecated 0.10.0
*
diff --git a/src/PhpWord/Style/Chart.php b/src/PhpWord/Style/Chart.php
index c02c0af4d8..9dbc8db0a6 100644
--- a/src/PhpWord/Style/Chart.php
+++ b/src/PhpWord/Style/Chart.php
@@ -11,56 +11,56 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Chart style
+ * Chart style.
*
* @since 0.12.0
*/
class Chart extends AbstractStyle
{
/**
- * Width (in EMU)
+ * Width (in EMU).
*
* @var int
*/
private $width = 1000000;
/**
- * Height (in EMU)
+ * Height (in EMU).
*
* @var int
*/
private $height = 1000000;
/**
- * Is 3D; applies to pie, bar, line, area
+ * Is 3D; applies to pie, bar, line, area.
*
* @var bool
*/
private $is3d = false;
/**
- * A list of colors to use in the chart
+ * A list of colors to use in the chart.
*
* @var array
*/
- private $colors = array();
+ private $colors = [];
/**
- * Chart title
+ * Chart title.
*
* @var string
*/
- private $title = null;
+ private $title;
/**
- * Chart legend visibility
+ * Chart legend visibility.
*
* @var bool
*/
@@ -68,32 +68,32 @@ class Chart extends AbstractStyle
/**
* Chart legend Position.
- * Possible values are 'r', 't', 'b', 'l', 'tr'
+ * Possible values are 'r', 't', 'b', 'l', 'tr'.
*
* @var string
*/
private $legendPosition = 'r';
/**
- * A list of display options for data labels
+ * A list of display options for data labels.
*
* @var array
*/
- private $dataLabelOptions = array(
- 'showVal' => true, // value
- 'showCatName' => true, // category name
- 'showLegendKey' => false, //show the cart legend
- 'showSerName' => false, // series name
- 'showPercent' => false,
- 'showLeaderLines' => false,
- 'showBubbleSize' => false,
- );
+ private $dataLabelOptions = [
+ 'showVal' => true, // value
+ 'showCatName' => true, // category name
+ 'showLegendKey' => false, //show the cart legend
+ 'showSerName' => false, // series name
+ 'showPercent' => false,
+ 'showLeaderLines' => false,
+ 'showBubbleSize' => false,
+ ];
/**
* A string that tells the writer where to write chart labels or to skip
* "nextTo" - sets labels next to the axis (bar graphs on the left) (default)
* "low" - labels on the left side of the graph
- * "high" - labels on the right side of the graph
+ * "high" - labels on the right side of the graph.
*
* @var string
*/
@@ -103,7 +103,7 @@ class Chart extends AbstractStyle
* A string that tells the writer where to write chart labels or to skip
* "nextTo" - sets labels next to the axis (bar graphs on the bottom) (default)
* "low" - labels are below the graph
- * "high" - labels above the graph
+ * "high" - labels above the graph.
*
* @var string
*/
@@ -121,45 +121,45 @@ class Chart extends AbstractStyle
/**
* The position for major tick marks
- * Possible values are 'in', 'out', 'cross', 'none'
+ * Possible values are 'in', 'out', 'cross', 'none'.
*
* @var string
*/
private $majorTickMarkPos = 'none';
/**
- * Show labels for axis
+ * Show labels for axis.
*
* @var bool
*/
private $showAxisLabels = false;
/**
- * Show Gridlines for Y-Axis
+ * Show Gridlines for Y-Axis.
*
* @var bool
*/
private $gridY = false;
/**
- * Show Gridlines for X-Axis
+ * Show Gridlines for X-Axis.
*
* @var bool
*/
private $gridX = false;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param array $style
*/
- public function __construct($style = array())
+ public function __construct($style = [])
{
$this->setStyleByArray($style);
}
/**
- * Get width
+ * Get width.
*
* @return int
*/
@@ -169,9 +169,10 @@ public function getWidth()
}
/**
- * Set width
+ * Set width.
*
* @param int $value
+ *
* @return self
*/
public function setWidth($value = null)
@@ -182,7 +183,7 @@ public function setWidth($value = null)
}
/**
- * Get height
+ * Get height.
*
* @return int
*/
@@ -192,9 +193,10 @@ public function getHeight()
}
/**
- * Set height
+ * Set height.
*
* @param int $value
+ *
* @return self
*/
public function setHeight($value = null)
@@ -205,7 +207,7 @@ public function setHeight($value = null)
}
/**
- * Is 3D
+ * Is 3D.
*
* @return bool
*/
@@ -215,9 +217,10 @@ public function is3d()
}
/**
- * Set 3D
+ * Set 3D.
*
* @param bool $value
+ *
* @return self
*/
public function set3d($value = true)
@@ -241,9 +244,10 @@ public function getColors()
* Set the colors to use in a chart.
*
* @param array $value a list of colors to use in the chart
+ *
* @return self
*/
- public function setColors($value = array())
+ public function setColors($value = [])
{
$this->colors = $value;
@@ -251,7 +255,7 @@ public function setColors($value = array())
}
/**
- * Get the chart title
+ * Get the chart title.
*
* @return string
*/
@@ -261,9 +265,10 @@ public function getTitle()
}
/**
- * Set the chart title
+ * Set the chart title.
*
* @param string $value
+ *
* @return self
*/
public function setTitle($value = null)
@@ -274,7 +279,7 @@ public function setTitle($value = null)
}
/**
- * Get chart legend visibility
+ * Get chart legend visibility.
*
* @return bool
*/
@@ -284,9 +289,10 @@ public function isShowLegend()
}
/**
- * Set chart legend visibility
+ * Set chart legend visibility.
*
* @param bool $value
+ *
* @return self
*/
public function setShowLegend($value = false)
@@ -297,7 +303,7 @@ public function setShowLegend($value = false)
}
/**
- * Get chart legend position
+ * Get chart legend position.
*
* @return string
*/
@@ -312,16 +318,17 @@ public function getLegendPosition()
* "b" - bottom of chart
* "t" - top of chart
* "l" - left of chart
- * "tr" - top right of chart
+ * "tr" - top right of chart.
*
* default: right
*
* @param string $legendPosition
+ *
* @return self
*/
public function setLegendPosition($legendPosition = 'r')
{
- $enum = array('r', 'b', 't', 'l', 'tr');
+ $enum = ['r', 'b', 't', 'l', 'tr'];
$this->legendPosition = $this->setEnumVal($legendPosition, $enum, $this->legendPosition);
return $this;
@@ -338,9 +345,10 @@ public function showAxisLabels()
}
/**
- * Set show Gridlines for Y-Axis
+ * Set show Gridlines for Y-Axis.
*
* @param bool $value
+ *
* @return self
*/
public function setShowAxisLabels($value = true)
@@ -351,7 +359,7 @@ public function setShowAxisLabels($value = true)
}
/**
- * get the list of options for data labels
+ * get the list of options for data labels.
*
* @return array
*/
@@ -366,7 +374,7 @@ public function getDataLabelOptions()
*
* @param array $values [description]
*/
- public function setDataLabelOptions($values = array())
+ public function setDataLabelOptions($values = []): void
{
foreach (array_keys($this->dataLabelOptions) as $option) {
if (isset($values[$option])) {
@@ -389,9 +397,10 @@ public function showGridY()
}
/**
- * Set show Gridlines for Y-Axis
+ * Set show Gridlines for Y-Axis.
*
* @param bool $value
+ *
* @return self
*/
public function setShowGridY($value = true)
@@ -402,7 +411,7 @@ public function setShowGridY($value = true)
}
/**
- * Get the categoryLabelPosition setting
+ * Get the categoryLabelPosition setting.
*
* @return string
*/
@@ -416,21 +425,22 @@ public function getCategoryLabelPosition()
* "none" - skips writing labels
* "nextTo" - sets labels next to the (bar graphs on the left)
* "low" - labels on the left side of the graph
- * "high" - labels on the right side of the graph
+ * "high" - labels on the right side of the graph.
*
* @param mixed $labelPosition
+ *
* @return self
*/
public function setCategoryLabelPosition($labelPosition)
{
- $enum = array('nextTo', 'low', 'high');
+ $enum = ['nextTo', 'low', 'high'];
$this->categoryLabelPosition = $this->setEnumVal($labelPosition, $enum, $this->categoryLabelPosition);
return $this;
}
/**
- * Get the valueAxisLabelPosition setting
+ * Get the valueAxisLabelPosition setting.
*
* @return string
*/
@@ -444,21 +454,22 @@ public function getValueLabelPosition()
* "none" - skips writing labels
* "nextTo" - sets labels next to the value
* "low" - sets labels are below the graph
- * "high" - sets labels above the graph
+ * "high" - sets labels above the graph.
*
* @param string
* @param mixed $labelPosition
*/
public function setValueLabelPosition($labelPosition)
{
- $enum = array('nextTo', 'low', 'high');
+ $enum = ['nextTo', 'low', 'high'];
$this->valueLabelPosition = $this->setEnumVal($labelPosition, $enum, $this->valueLabelPosition);
return $this;
}
/**
- * Get the categoryAxisTitle
+ * Get the categoryAxisTitle.
+ *
* @return string
*/
public function getCategoryAxisTitle()
@@ -467,7 +478,8 @@ public function getCategoryAxisTitle()
}
/**
- * Set the title that appears on the category side of the chart
+ * Set the title that appears on the category side of the chart.
+ *
* @param string $axisTitle
*/
public function setCategoryAxisTitle($axisTitle)
@@ -478,7 +490,8 @@ public function setCategoryAxisTitle($axisTitle)
}
/**
- * Get the valueAxisTitle
+ * Get the valueAxisTitle.
+ *
* @return string
*/
public function getValueAxisTitle()
@@ -487,7 +500,8 @@ public function getValueAxisTitle()
}
/**
- * Set the title that appears on the value side of the chart
+ * Set the title that appears on the value side of the chart.
+ *
* @param string $axisTitle
*/
public function setValueAxisTitle($axisTitle)
@@ -503,17 +517,18 @@ public function getMajorTickPosition()
}
/**
- * Set the position for major tick marks
+ * Set the position for major tick marks.
+ *
* @param string $position
*/
- public function setMajorTickPosition($position)
+ public function setMajorTickPosition($position): void
{
- $enum = array('in', 'out', 'cross', 'none');
+ $enum = ['in', 'out', 'cross', 'none'];
$this->majorTickMarkPos = $this->setEnumVal($position, $enum, $this->majorTickMarkPos);
}
/**
- * Show Gridlines for X-Axis
+ * Show Gridlines for X-Axis.
*
* @return bool
*/
@@ -523,9 +538,10 @@ public function showGridX()
}
/**
- * Set show Gridlines for X-Axis
+ * Set show Gridlines for X-Axis.
*
* @param bool $value
+ *
* @return self
*/
public function setShowGridX($value = true)
diff --git a/src/PhpWord/Style/Extrusion.php b/src/PhpWord/Style/Extrusion.php
index 4c860bcd63..dd00231223 100644
--- a/src/PhpWord/Style/Extrusion.php
+++ b/src/PhpWord/Style/Extrusion.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * 3D extrusion style
+ * 3D extrusion style.
*
* @see http://www.schemacentral.com/sc/ooxml/t-o_CT_Extrusion.html
* @since 0.12.0
@@ -26,7 +26,7 @@
class Extrusion extends AbstractStyle
{
/**
- * Type constants
+ * Type constants.
*
* @const string
*/
@@ -34,31 +34,31 @@ class Extrusion extends AbstractStyle
const EXTRUSION_PERSPECTIVE = 'perspective';
/**
- * Type: parallel|perspective
+ * Type: parallel|perspective.
*
* @var string
*/
private $type;
/**
- * Color
+ * Color.
*
* @var string
*/
private $color;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param array $style
*/
- public function __construct($style = array())
+ public function __construct($style = [])
{
$this->setStyleByArray($style);
}
/**
- * Get type
+ * Get type.
*
* @return string
*/
@@ -68,21 +68,22 @@ public function getType()
}
/**
- * Set pattern
+ * Set pattern.
*
* @param string $value
+ *
* @return self
*/
public function setType($value = null)
{
- $enum = array(self::EXTRUSION_PARALLEL, self::EXTRUSION_PERSPECTIVE);
+ $enum = [self::EXTRUSION_PARALLEL, self::EXTRUSION_PERSPECTIVE];
$this->type = $this->setEnumVal($value, $enum, null);
return $this;
}
/**
- * Get color
+ * Get color.
*
* @return string
*/
@@ -92,9 +93,10 @@ public function getColor()
}
/**
- * Set color
+ * Set color.
*
* @param string $value
+ *
* @return self
*/
public function setColor($value = null)
diff --git a/src/PhpWord/Style/Fill.php b/src/PhpWord/Style/Fill.php
index 360bcf3f0c..af0149d0fe 100644
--- a/src/PhpWord/Style/Fill.php
+++ b/src/PhpWord/Style/Fill.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Fill style
+ * Fill style.
*
* There are still lot of interesting things for this style that can be added, including gradient. See @see .
*
@@ -28,24 +28,24 @@
class Fill extends AbstractStyle
{
/**
- * Color
+ * Color.
*
* @var string
*/
private $color;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param array $style
*/
- public function __construct($style = array())
+ public function __construct($style = [])
{
$this->setStyleByArray($style);
}
/**
- * Get color
+ * Get color.
*
* @return string
*/
@@ -55,9 +55,10 @@ public function getColor()
}
/**
- * Set color
+ * Set color.
*
* @param string $value
+ *
* @return self
*/
public function setColor($value = null)
diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php
index 09e6f1a2f3..ea072c6a2d 100644
--- a/src/PhpWord/Style/Font.php
+++ b/src/PhpWord/Style/Font.php
@@ -11,19 +11,19 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Font style
+ * Font style.
*/
class Font extends AbstractStyle
{
/**
- * Underline types
+ * Underline types.
*
* @const string
*/
@@ -55,7 +55,7 @@ class Font extends AbstractStyle
const UNDERLINE_WORDS = 'words';
/**
- * Foreground colors
+ * Foreground colors.
*
* @const string
*/
@@ -76,169 +76,174 @@ class Font extends AbstractStyle
const FGCOLOR_BLACK = 'black';
/**
- * Aliases
+ * Aliases.
*
* @var array
*/
- protected $aliases = array('line-height' => 'lineHeight', 'letter-spacing' => 'spacing');
+ protected $aliases = ['line-height' => 'lineHeight', 'letter-spacing' => 'spacing'];
/**
- * Font style type
+ * Font style type.
*
* @var string
*/
private $type;
/**
- * Font name
+ * Font name.
*
* @var string
*/
private $name;
/**
- * Font Content Type
+ * Font Content Type.
*
* @var string
*/
private $hint;
/**
- * Font size
+ * Font size.
*
- * @var int|float
+ * @var float|int
*/
private $size;
/**
- * Font color
+ * Font color.
*
* @var string
*/
private $color;
/**
- * Bold
+ * Bold.
*
* @var bool
*/
private $bold;
/**
- * Italic
+ * Italic.
*
* @var bool
*/
private $italic;
/**
- * Undeline
+ * Undeline.
*
* @var string
*/
private $underline = self::UNDERLINE_NONE;
/**
- * Superscript
+ * Superscript.
*
* @var bool
*/
private $superScript = false;
/**
- * Subscript
+ * Subscript.
*
* @var bool
*/
private $subScript = false;
/**
- * Strikethrough
+ * Strikethrough.
*
* @var bool
*/
private $strikethrough;
/**
- * Double strikethrough
+ * Double strikethrough.
*
* @var bool
*/
private $doubleStrikethrough;
/**
- * Small caps
+ * Small caps.
*
* @var bool
+ *
* @see http://www.schemacentral.com/sc/ooxml/e-w_smallCaps-1.html
*/
private $smallCaps;
/**
- * All caps
+ * All caps.
*
* @var bool
+ *
* @see http://www.schemacentral.com/sc/ooxml/e-w_caps-1.html
*/
private $allCaps;
/**
- * Foreground/highlight
+ * Foreground/highlight.
*
* @var string
*/
private $fgColor;
/**
- * Expanded/compressed text: 0-600 (percent)
+ * Expanded/compressed text: 0-600 (percent).
*
* @var int
+ *
* @since 0.12.0
* @see http://www.schemacentral.com/sc/ooxml/e-w_w-1.html
*/
private $scale;
/**
- * Character spacing adjustment: twip
+ * Character spacing adjustment: twip.
+ *
+ * @var float|int
*
- * @var int|float
* @since 0.12.0
* @see http://www.schemacentral.com/sc/ooxml/e-w_spacing-2.html
*/
private $spacing;
/**
- * Font kerning: halfpoint
+ * Font kerning: halfpoint.
+ *
+ * @var float|int
*
- * @var int|float
* @since 0.12.0
* @see http://www.schemacentral.com/sc/ooxml/e-w_kern-1.html
*/
private $kerning;
/**
- * Paragraph style
+ * Paragraph style.
*
* @var \PhpOffice\PhpWord\Style\Paragraph
*/
private $paragraph;
/**
- * Shading
+ * Shading.
*
* @var \PhpOffice\PhpWord\Style\Shading
*/
private $shading;
/**
- * Right to left languages
+ * Right to left languages.
*
* @var bool
*/
private $rtl;
/**
- * noProof (disables AutoCorrect)
+ * noProof (disables AutoCorrect).
*
* @var bool
* http://www.datypic.com/sc/ooxml/e-w_noProof-1.html
@@ -246,33 +251,35 @@ class Font extends AbstractStyle
private $noProof;
/**
- * Languages
+ * Languages.
*
* @var \PhpOffice\PhpWord\Style\Language
*/
private $lang;
/**
- * Hidden text
+ * Hidden text.
*
* @var bool
+ *
* @see http://www.datypic.com/sc/ooxml/e-w_vanish-1.html
*/
private $hidden;
/**
- * Vertically Raised or Lowered Text
+ * Vertically Raised or Lowered Text.
*
* @var int Signed Half-Point Measurement
+ *
* @see http://www.datypic.com/sc/ooxml/e-w_position-1.html
*/
private $position;
/**
- * Create new font style
+ * Create new font style.
*
* @param string $type Type of font
- * @param array|string|\PhpOffice\PhpWord\Style\AbstractStyle $paragraph Paragraph styles definition
+ * @param array|\PhpOffice\PhpWord\Style\AbstractStyle|string $paragraph Paragraph styles definition
*/
public function __construct($type = 'text', $paragraph = null)
{
@@ -281,51 +288,52 @@ public function __construct($type = 'text', $paragraph = null)
}
/**
- * Get style values
+ * Get style values.
*
* @return array
+ *
* @since 0.12.0
*/
public function getStyleValues()
{
- $styles = array(
- 'name' => $this->getStyleName(),
- 'basic' => array(
- 'name' => $this->getName(),
- 'size' => $this->getSize(),
- 'color' => $this->getColor(),
- 'hint' => $this->getHint(),
- ),
- 'style' => array(
- 'bold' => $this->isBold(),
- 'italic' => $this->isItalic(),
+ $styles = [
+ 'name' => $this->getStyleName(),
+ 'basic' => [
+ 'name' => $this->getName(),
+ 'size' => $this->getSize(),
+ 'color' => $this->getColor(),
+ 'hint' => $this->getHint(),
+ ],
+ 'style' => [
+ 'bold' => $this->isBold(),
+ 'italic' => $this->isItalic(),
'underline' => $this->getUnderline(),
- 'strike' => $this->isStrikethrough(),
- 'dStrike' => $this->isDoubleStrikethrough(),
- 'super' => $this->isSuperScript(),
- 'sub' => $this->isSubScript(),
+ 'strike' => $this->isStrikethrough(),
+ 'dStrike' => $this->isDoubleStrikethrough(),
+ 'super' => $this->isSuperScript(),
+ 'sub' => $this->isSubScript(),
'smallCaps' => $this->isSmallCaps(),
- 'allCaps' => $this->isAllCaps(),
- 'fgColor' => $this->getFgColor(),
- 'hidden' => $this->isHidden(),
- ),
- 'spacing' => array(
- 'scale' => $this->getScale(),
- 'spacing' => $this->getSpacing(),
- 'kerning' => $this->getKerning(),
- 'position' => $this->getPosition(),
- ),
- 'paragraph' => $this->getParagraph(),
- 'rtl' => $this->isRTL(),
- 'shading' => $this->getShading(),
- 'lang' => $this->getLang(),
- );
+ 'allCaps' => $this->isAllCaps(),
+ 'fgColor' => $this->getFgColor(),
+ 'hidden' => $this->isHidden(),
+ ],
+ 'spacing' => [
+ 'scale' => $this->getScale(),
+ 'spacing' => $this->getSpacing(),
+ 'kerning' => $this->getKerning(),
+ 'position' => $this->getPosition(),
+ ],
+ 'paragraph' => $this->getParagraph(),
+ 'rtl' => $this->isRTL(),
+ 'shading' => $this->getShading(),
+ 'lang' => $this->getLang(),
+ ];
return $styles;
}
/**
- * Get style type
+ * Get style type.
*
* @return string
*/
@@ -335,7 +343,7 @@ public function getStyleType()
}
/**
- * Get font name
+ * Get font name.
*
* @return string
*/
@@ -345,9 +353,10 @@ public function getName()
}
/**
- * Set font name
+ * Set font name.
*
* @param string $value
+ *
* @return self
*/
public function setName($value = null)
@@ -358,7 +367,7 @@ public function setName($value = null)
}
/**
- * Get Font Content Type
+ * Get Font Content Type.
*
* @return string
*/
@@ -368,9 +377,10 @@ public function getHint()
}
/**
- * Set Font Content Type
+ * Set Font Content Type.
*
* @param string $value
+ *
* @return self
*/
public function setHint($value = null)
@@ -381,9 +391,9 @@ public function setHint($value = null)
}
/**
- * Get font size
+ * Get font size.
*
- * @return int|float
+ * @return float|int
*/
public function getSize()
{
@@ -391,9 +401,10 @@ public function getSize()
}
/**
- * Set font size
+ * Set font size.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setSize($value = null)
@@ -404,7 +415,7 @@ public function setSize($value = null)
}
/**
- * Get font color
+ * Get font color.
*
* @return string
*/
@@ -414,9 +425,10 @@ public function getColor()
}
/**
- * Set font color
+ * Set font color.
*
* @param string $value
+ *
* @return self
*/
public function setColor($value = null)
@@ -427,7 +439,7 @@ public function setColor($value = null)
}
/**
- * Get bold
+ * Get bold.
*
* @return bool
*/
@@ -437,9 +449,10 @@ public function isBold()
}
/**
- * Set bold
+ * Set bold.
*
* @param bool $value
+ *
* @return self
*/
public function setBold($value = true)
@@ -450,7 +463,7 @@ public function setBold($value = true)
}
/**
- * Get italic
+ * Get italic.
*
* @return bool
*/
@@ -460,9 +473,10 @@ public function isItalic()
}
/**
- * Set italic
+ * Set italic.
*
* @param bool $value
+ *
* @return self
*/
public function setItalic($value = true)
@@ -473,7 +487,7 @@ public function setItalic($value = true)
}
/**
- * Get underline
+ * Get underline.
*
* @return string
*/
@@ -483,9 +497,10 @@ public function getUnderline()
}
/**
- * Set underline
+ * Set underline.
*
* @param string $value
+ *
* @return self
*/
public function setUnderline($value = self::UNDERLINE_NONE)
@@ -496,7 +511,7 @@ public function setUnderline($value = self::UNDERLINE_NONE)
}
/**
- * Get superscript
+ * Get superscript.
*
* @return bool
*/
@@ -506,9 +521,10 @@ public function isSuperScript()
}
/**
- * Set superscript
+ * Set superscript.
*
* @param bool $value
+ *
* @return self
*/
public function setSuperScript($value = true)
@@ -517,7 +533,7 @@ public function setSuperScript($value = true)
}
/**
- * Get subscript
+ * Get subscript.
*
* @return bool
*/
@@ -527,9 +543,10 @@ public function isSubScript()
}
/**
- * Set subscript
+ * Set subscript.
*
* @param bool $value
+ *
* @return self
*/
public function setSubScript($value = true)
@@ -538,7 +555,7 @@ public function setSubScript($value = true)
}
/**
- * Get strikethrough
+ * Get strikethrough.
*
* @return bool
*/
@@ -548,9 +565,10 @@ public function isStrikethrough()
}
/**
- * Set strikethrough
+ * Set strikethrough.
*
* @param bool $value
+ *
* @return self
*/
public function setStrikethrough($value = true)
@@ -559,7 +577,7 @@ public function setStrikethrough($value = true)
}
/**
- * Get double strikethrough
+ * Get double strikethrough.
*
* @return bool
*/
@@ -569,9 +587,10 @@ public function isDoubleStrikethrough()
}
/**
- * Set double strikethrough
+ * Set double strikethrough.
*
* @param bool $value
+ *
* @return self
*/
public function setDoubleStrikethrough($value = true)
@@ -580,7 +599,7 @@ public function setDoubleStrikethrough($value = true)
}
/**
- * Get small caps
+ * Get small caps.
*
* @return bool
*/
@@ -590,9 +609,10 @@ public function isSmallCaps()
}
/**
- * Set small caps
+ * Set small caps.
*
* @param bool $value
+ *
* @return self
*/
public function setSmallCaps($value = true)
@@ -601,7 +621,7 @@ public function setSmallCaps($value = true)
}
/**
- * Get all caps
+ * Get all caps.
*
* @return bool
*/
@@ -611,9 +631,10 @@ public function isAllCaps()
}
/**
- * Set all caps
+ * Set all caps.
*
* @param bool $value
+ *
* @return self
*/
public function setAllCaps($value = true)
@@ -622,7 +643,7 @@ public function setAllCaps($value = true)
}
/**
- * Get foreground/highlight color
+ * Get foreground/highlight color.
*
* @return string
*/
@@ -632,9 +653,10 @@ public function getFgColor()
}
/**
- * Set foreground/highlight color
+ * Set foreground/highlight color.
*
* @param string $value
+ *
* @return self
*/
public function setFgColor($value = null)
@@ -645,7 +667,7 @@ public function setFgColor($value = null)
}
/**
- * Get background
+ * Get background.
*
* @return string
*/
@@ -655,18 +677,19 @@ public function getBgColor()
}
/**
- * Set background
+ * Set background.
*
* @param string $value
+ *
* @return \PhpOffice\PhpWord\Style\Table
*/
public function setBgColor($value = null)
{
- $this->setShading(array('fill' => $value));
+ $this->setShading(['fill' => $value]);
}
/**
- * Get scale
+ * Get scale.
*
* @return int
*/
@@ -676,9 +699,10 @@ public function getScale()
}
/**
- * Set scale
+ * Set scale.
*
* @param int $value
+ *
* @return self
*/
public function setScale($value = null)
@@ -689,9 +713,9 @@ public function setScale($value = null)
}
/**
- * Get font spacing
+ * Get font spacing.
*
- * @return int|float
+ * @return float|int
*/
public function getSpacing()
{
@@ -699,9 +723,10 @@ public function getSpacing()
}
/**
- * Set font spacing
+ * Set font spacing.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setSpacing($value = null)
@@ -712,9 +737,9 @@ public function setSpacing($value = null)
}
/**
- * Get font kerning
+ * Get font kerning.
*
- * @return int|float
+ * @return float|int
*/
public function getKerning()
{
@@ -722,9 +747,10 @@ public function getKerning()
}
/**
- * Set font kerning
+ * Set font kerning.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setKerning($value = null)
@@ -735,7 +761,7 @@ public function setKerning($value = null)
}
/**
- * Get noProof (disables autocorrect)
+ * Get noProof (disables autocorrect).
*
* @return bool
*/
@@ -745,9 +771,10 @@ public function isNoProof()
}
/**
- * Set noProof (disables autocorrect)
+ * Set noProof (disables autocorrect).
*
* @param bool $value
+ *
* @return $this
*/
public function setNoProof($value = false)
@@ -758,9 +785,9 @@ public function setNoProof($value = false)
}
/**
- * Get line height
+ * Get line height.
*
- * @return int|float
+ * @return float|int
*/
public function getLineHeight()
{
@@ -768,20 +795,21 @@ public function getLineHeight()
}
/**
- * Set lineheight
+ * Set lineheight.
+ *
+ * @param float|int|string $value
*
- * @param int|float|string $value
* @return self
*/
public function setLineHeight($value)
{
- $this->setParagraph(array('lineHeight' => $value));
+ $this->setParagraph(['lineHeight' => $value]);
return $this;
}
/**
- * Get paragraph style
+ * Get paragraph style.
*
* @return \PhpOffice\PhpWord\Style\Paragraph
*/
@@ -791,9 +819,10 @@ public function getParagraph()
}
/**
- * Set Paragraph
+ * Set Paragraph.
*
* @param mixed $value
+ *
* @return self
*/
public function setParagraph($value = null)
@@ -804,7 +833,7 @@ public function setParagraph($value = null)
}
/**
- * Get rtl
+ * Get rtl.
*
* @return bool
*/
@@ -814,9 +843,10 @@ public function isRTL()
}
/**
- * Set rtl
+ * Set rtl.
*
* @param bool $value
+ *
* @return self
*/
public function setRTL($value = true)
@@ -827,7 +857,7 @@ public function setRTL($value = true)
}
/**
- * Get shading
+ * Get shading.
*
* @return \PhpOffice\PhpWord\Style\Shading
*/
@@ -837,9 +867,10 @@ public function getShading()
}
/**
- * Set shading
+ * Set shading.
*
* @param mixed $value
+ *
* @return self
*/
public function setShading($value = null)
@@ -850,7 +881,7 @@ public function setShading($value = null)
}
/**
- * Get language
+ * Get language.
*
* @return \PhpOffice\PhpWord\Style\Language
*/
@@ -860,9 +891,10 @@ public function getLang()
}
/**
- * Set language
+ * Set language.
*
* @param mixed $value
+ *
* @return self
*/
public function setLang($value = null)
@@ -876,7 +908,7 @@ public function setLang($value = null)
}
/**
- * Get bold
+ * Get bold.
*
* @deprecated 0.10.0
*
@@ -888,7 +920,7 @@ public function getBold()
}
/**
- * Get italic
+ * Get italic.
*
* @deprecated 0.10.0
*
@@ -900,7 +932,7 @@ public function getItalic()
}
/**
- * Get superscript
+ * Get superscript.
*
* @deprecated 0.10.0
*
@@ -912,7 +944,7 @@ public function getSuperScript()
}
/**
- * Get subscript
+ * Get subscript.
*
* @deprecated 0.10.0
*
@@ -924,7 +956,7 @@ public function getSubScript()
}
/**
- * Get strikethrough
+ * Get strikethrough.
*
* @deprecated 0.10.0
*
@@ -936,7 +968,7 @@ public function getStrikethrough()
}
/**
- * Get paragraph style
+ * Get paragraph style.
*
* @deprecated 0.11.0
*
@@ -948,7 +980,7 @@ public function getParagraphStyle()
}
/**
- * Get hidden text
+ * Get hidden text.
*
* @return bool
*/
@@ -958,9 +990,10 @@ public function isHidden()
}
/**
- * Set hidden text
+ * Set hidden text.
*
* @param bool $value
+ *
* @return self
*/
public function setHidden($value = true)
@@ -971,7 +1004,7 @@ public function setHidden($value = true)
}
/**
- * Get position
+ * Get position.
*
* @return int
*/
@@ -981,9 +1014,10 @@ public function getPosition()
}
/**
- * Set position
+ * Set position.
*
* @param int $value
+ *
* @return self
*/
public function setPosition($value = null)
diff --git a/src/PhpWord/Style/Frame.php b/src/PhpWord/Style/Frame.php
index e87b7a803a..489c56b26f 100644
--- a/src/PhpWord/Style/Frame.php
+++ b/src/PhpWord/Style/Frame.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,17 +20,18 @@
use PhpOffice\PhpWord\SimpleType\Jc;
/**
- * Frame defines the size and position of an object
+ * Frame defines the size and position of an object.
*
* Width, height, left/hpos, top/vpos, hrel, vrel, wrap, zindex
*
* @since 0.12.0
+ *
* @todo Make existing style (image, textbox, etc) use this style
*/
class Frame extends AbstractStyle
{
/**
- * Length unit
+ * Length unit.
*
* @const string
*/
@@ -46,7 +47,7 @@ class Frame extends AbstractStyle
const POS_RELATIVE = 'relative';
/**
- * Horizontal/vertical value
+ * Horizontal/vertical value.
*
* @const string
*/
@@ -59,7 +60,7 @@ class Frame extends AbstractStyle
const POS_OUTSIDE = 'outside';
/**
- * Position relative to
+ * Position relative to.
*
* @const string
*/
@@ -77,7 +78,7 @@ class Frame extends AbstractStyle
const POS_RELTO_OMARGIN = 'outer-margin-area';
/**
- * Wrap type
+ * Wrap type.
*
* @const string
*/
@@ -95,124 +96,125 @@ class Frame extends AbstractStyle
private $alignment = '';
/**
- * Unit
+ * Unit.
*
* @var string
*/
private $unit = 'pt';
/**
- * Width
+ * Width.
*
- * @var int|float
+ * @var float|int
*/
private $width;
/**
- * Height
+ * Height.
*
- * @var int|float
+ * @var float|int
*/
private $height;
/**
- * Leftmost (horizontal) position
+ * Leftmost (horizontal) position.
*
- * @var int|float
+ * @var float|int
*/
private $left = 0;
/**
- * Topmost (vertical) position
+ * Topmost (vertical) position.
*
- * @var int|float
+ * @var float|int
*/
private $top = 0;
/**
- * Position type: absolute|relative
+ * Position type: absolute|relative.
*
* @var string
*/
private $pos;
/**
- * Horizontal position
+ * Horizontal position.
*
* @var string
*/
private $hPos;
/**
- * Horizontal position relative to
+ * Horizontal position relative to.
*
* @var string
*/
private $hPosRelTo;
/**
- * Vertical position
+ * Vertical position.
*
* @var string
*/
private $vPos;
/**
- * Vertical position relative to
+ * Vertical position relative to.
*
* @var string
*/
private $vPosRelTo;
/**
- * Wrap type
+ * Wrap type.
*
* @var string
*/
private $wrap;
/**
- * Top wrap distance
+ * Top wrap distance.
*
* @var float
*/
private $wrapDistanceTop;
/**
- * Bottom wrap distance
+ * Bottom wrap distance.
*
* @var float
*/
private $wrapDistanceBottom;
/**
- * Left wrap distance
+ * Left wrap distance.
*
* @var float
*/
private $wrapDistanceLeft;
/**
- * Right wrap distance
+ * Right wrap distance.
*
* @var float
*/
private $wrapDistanceRight;
/**
- * Vertically raised or lowered text
+ * Vertically raised or lowered text.
*
* @var int
+ *
* @see http://www.datypic.com/sc/ooxml/e-w_position-1.html
*/
private $position;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param array $style
*/
- public function __construct($style = array())
+ public function __construct($style = [])
{
$this->setStyleByArray($style);
}
@@ -270,7 +272,7 @@ public function setAlign($value = null)
}
/**
- * Get unit
+ * Get unit.
*
* @return string
*/
@@ -280,9 +282,10 @@ public function getUnit()
}
/**
- * Set unit
+ * Set unit.
*
* @param string $value
+ *
* @return self
*/
public function setUnit($value)
@@ -293,9 +296,9 @@ public function setUnit($value)
}
/**
- * Get width
+ * Get width.
*
- * @return int|float
+ * @return float|int
*/
public function getWidth()
{
@@ -303,9 +306,10 @@ public function getWidth()
}
/**
- * Set width
+ * Set width.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setWidth($value = null)
@@ -316,9 +320,9 @@ public function setWidth($value = null)
}
/**
- * Get height
+ * Get height.
*
- * @return int|float
+ * @return float|int
*/
public function getHeight()
{
@@ -326,9 +330,10 @@ public function getHeight()
}
/**
- * Set height
+ * Set height.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setHeight($value = null)
@@ -339,9 +344,9 @@ public function setHeight($value = null)
}
/**
- * Get left
+ * Get left.
*
- * @return int|float
+ * @return float|int
*/
public function getLeft()
{
@@ -349,9 +354,10 @@ public function getLeft()
}
/**
- * Set left
+ * Set left.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setLeft($value = 0)
@@ -362,9 +368,9 @@ public function setLeft($value = 0)
}
/**
- * Get topmost position
+ * Get topmost position.
*
- * @return int|float
+ * @return float|int
*/
public function getTop()
{
@@ -372,9 +378,10 @@ public function getTop()
}
/**
- * Set topmost position
+ * Set topmost position.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setTop($value = 0)
@@ -385,7 +392,7 @@ public function setTop($value = 0)
}
/**
- * Get position type
+ * Get position type.
*
* @return string
*/
@@ -395,24 +402,25 @@ public function getPos()
}
/**
- * Set position type
+ * Set position type.
*
* @param string $value
+ *
* @return self
*/
public function setPos($value)
{
- $enum = array(
+ $enum = [
self::POS_ABSOLUTE,
self::POS_RELATIVE,
- );
+ ];
$this->pos = $this->setEnumVal($value, $enum, $this->pos);
return $this;
}
/**
- * Get horizontal position
+ * Get horizontal position.
*
* @return string
*/
@@ -422,30 +430,31 @@ public function getHPos()
}
/**
- * Set horizontal position
+ * Set horizontal position.
*
* @since 0.12.0 "absolute" option is available.
*
* @param string $value
+ *
* @return self
*/
public function setHPos($value)
{
- $enum = array(
+ $enum = [
self::POS_ABSOLUTE,
self::POS_LEFT,
self::POS_CENTER,
self::POS_RIGHT,
self::POS_INSIDE,
self::POS_OUTSIDE,
- );
+ ];
$this->hPos = $this->setEnumVal($value, $enum, $this->hPos);
return $this;
}
/**
- * Get vertical position
+ * Get vertical position.
*
* @return string
*/
@@ -455,30 +464,31 @@ public function getVPos()
}
/**
- * Set vertical position
+ * Set vertical position.
*
* @since 0.12.0 "absolute" option is available.
*
* @param string $value
+ *
* @return self
*/
public function setVPos($value)
{
- $enum = array(
+ $enum = [
self::POS_ABSOLUTE,
self::POS_TOP,
self::POS_CENTER,
self::POS_BOTTOM,
self::POS_INSIDE,
self::POS_OUTSIDE,
- );
+ ];
$this->vPos = $this->setEnumVal($value, $enum, $this->vPos);
return $this;
}
/**
- * Get horizontal position relative to
+ * Get horizontal position relative to.
*
* @return string
*/
@@ -488,14 +498,15 @@ public function getHPosRelTo()
}
/**
- * Set horizontal position relative to
+ * Set horizontal position relative to.
*
* @param string $value
+ *
* @return self
*/
public function setHPosRelTo($value)
{
- $enum = array(
+ $enum = [
self::POS_RELTO_MARGIN,
self::POS_RELTO_PAGE,
self::POS_RELTO_COLUMN,
@@ -504,14 +515,14 @@ public function setHPosRelTo($value)
self::POS_RELTO_RMARGIN,
self::POS_RELTO_IMARGIN,
self::POS_RELTO_OMARGIN,
- );
+ ];
$this->hPosRelTo = $this->setEnumVal($value, $enum, $this->hPosRelTo);
return $this;
}
/**
- * Get vertical position relative to
+ * Get vertical position relative to.
*
* @return string
*/
@@ -521,14 +532,15 @@ public function getVPosRelTo()
}
/**
- * Set vertical position relative to
+ * Set vertical position relative to.
*
* @param string $value
+ *
* @return self
*/
public function setVPosRelTo($value)
{
- $enum = array(
+ $enum = [
self::POS_RELTO_MARGIN,
self::POS_RELTO_PAGE,
self::POS_RELTO_TEXT,
@@ -537,14 +549,14 @@ public function setVPosRelTo($value)
self::POS_RELTO_BMARGIN,
self::POS_RELTO_IMARGIN,
self::POS_RELTO_OMARGIN,
- );
+ ];
$this->vPosRelTo = $this->setEnumVal($value, $enum, $this->vPosRelTo);
return $this;
}
/**
- * Get wrap type
+ * Get wrap type.
*
* @return string
*/
@@ -554,14 +566,15 @@ public function getWrap()
}
/**
- * Set wrap type
+ * Set wrap type.
*
* @param string $value
+ *
* @return self
*/
public function setWrap($value)
{
- $enum = array(
+ $enum = [
self::WRAP_INLINE,
self::WRAP_SQUARE,
self::WRAP_TIGHT,
@@ -569,14 +582,14 @@ public function setWrap($value)
self::WRAP_TOPBOTTOM,
self::WRAP_BEHIND,
self::WRAP_INFRONT,
- );
+ ];
$this->wrap = $this->setEnumVal($value, $enum, $this->wrap);
return $this;
}
/**
- * Get top distance from text wrap
+ * Get top distance from text wrap.
*
* @return float
*/
@@ -586,9 +599,10 @@ public function getWrapDistanceTop()
}
/**
- * Set top distance from text wrap
+ * Set top distance from text wrap.
*
* @param int $value
+ *
* @return self
*/
public function setWrapDistanceTop($value = null)
@@ -599,7 +613,7 @@ public function setWrapDistanceTop($value = null)
}
/**
- * Get bottom distance from text wrap
+ * Get bottom distance from text wrap.
*
* @return float
*/
@@ -609,9 +623,10 @@ public function getWrapDistanceBottom()
}
/**
- * Set bottom distance from text wrap
+ * Set bottom distance from text wrap.
*
* @param float $value
+ *
* @return self
*/
public function setWrapDistanceBottom($value = null)
@@ -622,7 +637,7 @@ public function setWrapDistanceBottom($value = null)
}
/**
- * Get left distance from text wrap
+ * Get left distance from text wrap.
*
* @return float
*/
@@ -632,9 +647,10 @@ public function getWrapDistanceLeft()
}
/**
- * Set left distance from text wrap
+ * Set left distance from text wrap.
*
* @param float $value
+ *
* @return self
*/
public function setWrapDistanceLeft($value = null)
@@ -645,7 +661,7 @@ public function setWrapDistanceLeft($value = null)
}
/**
- * Get right distance from text wrap
+ * Get right distance from text wrap.
*
* @return float
*/
@@ -655,9 +671,10 @@ public function getWrapDistanceRight()
}
/**
- * Set right distance from text wrap
+ * Set right distance from text wrap.
*
* @param float $value
+ *
* @return self
*/
public function setWrapDistanceRight($value = null)
@@ -668,7 +685,7 @@ public function setWrapDistanceRight($value = null)
}
/**
- * Get position
+ * Get position.
*
* @return int
*/
@@ -678,9 +695,10 @@ public function getPosition()
}
/**
- * Set position
+ * Set position.
*
* @param int $value
+ *
* @return self
*/
public function setPosition($value = null)
diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php
index 70aafe12cd..dbb8572f99 100644
--- a/src/PhpWord/Style/Image.php
+++ b/src/PhpWord/Style/Image.php
@@ -11,19 +11,19 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Image and memory image style
+ * Image and memory image style.
*/
class Image extends Frame
{
/**
- * Backward compatibility constants
+ * Backward compatibility constants.
*
* @const string
*/
@@ -56,7 +56,7 @@ class Image extends Frame
const POSITION_RELATIVE = self::POS_RELATIVE;
/**
- * Create new instance
+ * Create new instance.
*/
public function __construct()
{
@@ -73,9 +73,9 @@ public function __construct()
}
/**
- * Get margin top
+ * Get margin top.
*
- * @return int|float
+ * @return float|int
*/
public function getMarginTop()
{
@@ -83,10 +83,12 @@ public function getMarginTop()
}
/**
- * Set margin top
+ * Set margin top.
*
* @ignoreScrutinizerPatch
- * @param int|float $value
+ *
+ * @param float|int $value
+ *
* @return self
*/
public function setMarginTop($value = 0)
@@ -97,9 +99,9 @@ public function setMarginTop($value = 0)
}
/**
- * Get margin left
+ * Get margin left.
*
- * @return int|float
+ * @return float|int
*/
public function getMarginLeft()
{
@@ -107,10 +109,12 @@ public function getMarginLeft()
}
/**
- * Set margin left
+ * Set margin left.
*
* @ignoreScrutinizerPatch
- * @param int|float $value
+ *
+ * @param float|int $value
+ *
* @return self
*/
public function setMarginLeft($value = 0)
@@ -121,7 +125,7 @@ public function setMarginLeft($value = 0)
}
/**
- * Get wrapping style
+ * Get wrapping style.
*
* @return string
*/
@@ -131,12 +135,10 @@ public function getWrappingStyle()
}
/**
- * Set wrapping style
+ * Set wrapping style.
*
* @param string $wrappingStyle
*
- * @throws \InvalidArgumentException
- *
* @return self
*/
public function setWrappingStyle($wrappingStyle)
@@ -147,7 +149,7 @@ public function setWrappingStyle($wrappingStyle)
}
/**
- * Get positioning type
+ * Get positioning type.
*
* @return string
*/
@@ -157,12 +159,10 @@ public function getPositioning()
}
/**
- * Set positioning type
+ * Set positioning type.
*
* @param string $positioning
*
- * @throws \InvalidArgumentException
- *
* @return self
*/
public function setPositioning($positioning)
@@ -173,7 +173,7 @@ public function setPositioning($positioning)
}
/**
- * Get horizontal alignment
+ * Get horizontal alignment.
*
* @return string
*/
@@ -183,12 +183,10 @@ public function getPosHorizontal()
}
/**
- * Set horizontal alignment
+ * Set horizontal alignment.
*
* @param string $alignment
*
- * @throws \InvalidArgumentException
- *
* @return self
*/
public function setPosHorizontal($alignment)
@@ -199,7 +197,7 @@ public function setPosHorizontal($alignment)
}
/**
- * Get vertical alignment
+ * Get vertical alignment.
*
* @return string
*/
@@ -209,12 +207,10 @@ public function getPosVertical()
}
/**
- * Set vertical alignment
+ * Set vertical alignment.
*
* @param string $alignment
*
- * @throws \InvalidArgumentException
- *
* @return self
*/
public function setPosVertical($alignment)
@@ -225,7 +221,7 @@ public function setPosVertical($alignment)
}
/**
- * Get horizontal relation
+ * Get horizontal relation.
*
* @return string
*/
@@ -235,12 +231,10 @@ public function getPosHorizontalRel()
}
/**
- * Set horizontal relation
+ * Set horizontal relation.
*
* @param string $relto
*
- * @throws \InvalidArgumentException
- *
* @return self
*/
public function setPosHorizontalRel($relto)
@@ -251,7 +245,7 @@ public function setPosHorizontalRel($relto)
}
/**
- * Get vertical relation
+ * Get vertical relation.
*
* @return string
*/
@@ -261,12 +255,10 @@ public function getPosVerticalRel()
}
/**
- * Set vertical relation
+ * Set vertical relation.
*
* @param string $relto
*
- * @throws \InvalidArgumentException
- *
* @return self
*/
public function setPosVerticalRel($relto)
diff --git a/src/PhpWord/Style/Indentation.php b/src/PhpWord/Style/Indentation.php
index e422395c80..87277b4b81 100644
--- a/src/PhpWord/Style/Indentation.php
+++ b/src/PhpWord/Style/Indentation.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Paragraph indentation style
+ * Paragraph indentation style.
*
* @see http://www.schemacentral.com/sc/ooxml/t-w_CT_Ind.html
* @since 0.10.0
@@ -26,47 +26,47 @@
class Indentation extends AbstractStyle
{
/**
- * Left indentation (twip)
+ * Left indentation (twip).
*
- * @var int|float
+ * @var float|int
*/
private $left = 0;
/**
- * Right indentation (twip)
+ * Right indentation (twip).
*
- * @var int|float
+ * @var float|int
*/
private $right = 0;
/**
- * Additional first line indentation (twip)
+ * Additional first line indentation (twip).
*
- * @var int|float
+ * @var float|int
*/
private $firstLine;
/**
- * Indentation removed from first line (twip)
+ * Indentation removed from first line (twip).
*
- * @var int|float
+ * @var float|int
*/
private $hanging;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param array $style
*/
- public function __construct($style = array())
+ public function __construct($style = [])
{
$this->setStyleByArray($style);
}
/**
- * Get left
+ * Get left.
*
- * @return int|float
+ * @return float|int
*/
public function getLeft()
{
@@ -74,9 +74,10 @@ public function getLeft()
}
/**
- * Set left
+ * Set left.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setLeft($value = null)
@@ -87,9 +88,9 @@ public function setLeft($value = null)
}
/**
- * Get right
+ * Get right.
*
- * @return int|float
+ * @return float|int
*/
public function getRight()
{
@@ -97,9 +98,10 @@ public function getRight()
}
/**
- * Set right
+ * Set right.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setRight($value = null)
@@ -110,9 +112,9 @@ public function setRight($value = null)
}
/**
- * Get first line
+ * Get first line.
*
- * @return int|float
+ * @return float|int
*/
public function getFirstLine()
{
@@ -120,9 +122,10 @@ public function getFirstLine()
}
/**
- * Set first line
+ * Set first line.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setFirstLine($value = null)
@@ -133,9 +136,9 @@ public function setFirstLine($value = null)
}
/**
- * Get hanging
+ * Get hanging.
*
- * @return int|float
+ * @return float|int
*/
public function getHanging()
{
@@ -143,9 +146,10 @@ public function getHanging()
}
/**
- * Set hanging
+ * Set hanging.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setHanging($value = null)
diff --git a/src/PhpWord/Style/Language.php b/src/PhpWord/Style/Language.php
index 7f3dbec767..fd63eb143e 100644
--- a/src/PhpWord/Style/Language.php
+++ b/src/PhpWord/Style/Language.php
@@ -11,15 +11,17 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
+use InvalidArgumentException;
+
/**
* Language
- * A couple of predefined values are defined here, see the websites below for more values
+ * A couple of predefined values are defined here, see the websites below for more values.
*
* @see http://www.datypic.com/sc/ooxml/t-w_CT_Language.html
* @see https://technet.microsoft.com/en-us/library/cc287874(v=office.12).aspx
@@ -75,40 +77,41 @@ final class Language extends AbstractStyle
const RU_RU_ID = 1049;
/**
- * Language ID, used for RTF document generation
+ * Language ID, used for RTF document generation.
*
* @var int
+ *
* @see https://technet.microsoft.com/en-us/library/cc179219.aspx
*/
private $langId;
/**
- * Latin Language
+ * Latin Language.
*
* @var string
*/
private $latin;
/**
- * East Asian Language
+ * East Asian Language.
*
* @var string
*/
private $eastAsia;
/**
- * Complex Script Language
+ * Complex Script Language.
*
* @var string
*/
private $bidirectional;
/**
- * Constructor
+ * Constructor.
*
- * @param string|null $latin
- * @param string|null $eastAsia
- * @param string|null $bidirectional
+ * @param null|string $latin
+ * @param null|string $eastAsia
+ * @param null|string $bidirectional
*/
public function __construct($latin = null, $eastAsia = null, $bidirectional = null)
{
@@ -124,10 +127,11 @@ public function __construct($latin = null, $eastAsia = null, $bidirectional = nu
}
/**
- * Set the Latin Language
+ * Set the Latin Language.
*
* @param string $latin
* The value for the latin language
+ *
* @return self
*/
public function setLatin($latin)
@@ -138,9 +142,9 @@ public function setLatin($latin)
}
/**
- * Get the Latin Language
+ * Get the Latin Language.
*
- * @return string|null
+ * @return null|string
*/
public function getLatin()
{
@@ -148,11 +152,13 @@ public function getLatin()
}
/**
- * Set the Language ID
+ * Set the Language ID.
*
* @param int $langId
* The value for the language ID
+ *
* @return self
+ *
* @see https://technet.microsoft.com/en-us/library/cc287874(v=office.12).aspx
*/
public function setLangId($langId)
@@ -163,7 +169,7 @@ public function setLangId($langId)
}
/**
- * Get the Language ID
+ * Get the Language ID.
*
* @return int
*/
@@ -173,10 +179,11 @@ public function getLangId()
}
/**
- * Set the East Asian Language
+ * Set the East Asian Language.
*
* @param string $eastAsia
* The value for the east asian language
+ *
* @return self
*/
public function setEastAsia($eastAsia)
@@ -187,9 +194,9 @@ public function setEastAsia($eastAsia)
}
/**
- * Get the East Asian Language
+ * Get the East Asian Language.
*
- * @return string|null
+ * @return null|string
*/
public function getEastAsia()
{
@@ -197,10 +204,11 @@ public function getEastAsia()
}
/**
- * Set the Complex Script Language
+ * Set the Complex Script Language.
*
* @param string $bidirectional
* The value for the complex script language
+ *
* @return self
*/
public function setBidirectional($bidirectional)
@@ -211,9 +219,9 @@ public function setBidirectional($bidirectional)
}
/**
- * Get the Complex Script Language
+ * Get the Complex Script Language.
*
- * @return string|null
+ * @return null|string
*/
public function getBidirectional()
{
@@ -221,9 +229,10 @@ public function getBidirectional()
}
/**
- * Validates that the language passed is in the format xx-xx
+ * Validates that the language passed is in the format xx-xx.
*
* @param string $locale
+ *
* @return string
*/
private function validateLocale($locale)
@@ -237,7 +246,7 @@ private function validateLocale($locale)
}
if ($locale !== null && $locale !== 'zxx' && strstr($locale, '-') === false) {
- throw new \InvalidArgumentException($locale . ' is not a valid language code');
+ throw new InvalidArgumentException($locale . ' is not a valid language code');
}
return $locale;
diff --git a/src/PhpWord/Style/Line.php b/src/PhpWord/Style/Line.php
index a9952eec0b..2aeefa5ae5 100644
--- a/src/PhpWord/Style/Line.php
+++ b/src/PhpWord/Style/Line.php
@@ -11,26 +11,26 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Line style
+ * Line style.
*/
class Line extends Image
{
/**
- * Connector types
+ * Connector types.
*
* @const string
*/
const CONNECTOR_TYPE_STRAIGHT = 'straight';
/**
- * Arrow styles
+ * Arrow styles.
*
* @const string
*/
@@ -41,7 +41,7 @@ class Line extends Image
const ARROW_STYLE_OVAL = 'oval';
/**
- * Dash styles
+ * Dash styles.
*
* @const string
*/
@@ -54,56 +54,56 @@ class Line extends Image
const DASH_STYLE_LONG_DASH_DOT_DOT = 'longdashdotdot';
/**
- * flip Line
+ * flip Line.
*
* @var bool
*/
private $flip = false;
/**
- * connectorType
+ * connectorType.
*
* @var string
*/
private $connectorType = self::CONNECTOR_TYPE_STRAIGHT;
/**
- * Line Weight
+ * Line Weight.
*
* @var int
*/
private $weight;
/**
- * Line color
+ * Line color.
*
* @var string
*/
private $color;
/**
- * Dash style
+ * Dash style.
*
* @var string
*/
private $dash;
/**
- * Begin arrow
+ * Begin arrow.
*
* @var string
*/
private $beginArrow;
/**
- * End arrow
+ * End arrow.
*
* @var string
*/
private $endArrow;
/**
- * Get flip
+ * Get flip.
*
* @return bool
*/
@@ -113,9 +113,10 @@ public function isFlip()
}
/**
- * Set flip
+ * Set flip.
*
* @param bool $value
+ *
* @return self
*/
public function setFlip($value = false)
@@ -126,7 +127,7 @@ public function setFlip($value = false)
}
/**
- * Get connectorType
+ * Get connectorType.
*
* @return string
*/
@@ -136,23 +137,24 @@ public function getConnectorType()
}
/**
- * Set connectorType
+ * Set connectorType.
*
* @param string $value
+ *
* @return self
*/
public function setConnectorType($value = null)
{
- $enum = array(
+ $enum = [
self::CONNECTOR_TYPE_STRAIGHT,
- );
+ ];
$this->connectorType = $this->setEnumVal($value, $enum, $this->connectorType);
return $this;
}
/**
- * Get weight
+ * Get weight.
*
* @return int
*/
@@ -162,9 +164,10 @@ public function getWeight()
}
/**
- * Set weight
+ * Set weight.
*
* @param int $value Weight in points
+ *
* @return self
*/
public function setWeight($value = null)
@@ -175,7 +178,7 @@ public function setWeight($value = null)
}
/**
- * Get color
+ * Get color.
*
* @return string
*/
@@ -185,9 +188,10 @@ public function getColor()
}
/**
- * Set color
+ * Set color.
*
* @param string $value
+ *
* @return self
*/
public function setColor($value = null)
@@ -198,7 +202,7 @@ public function setColor($value = null)
}
/**
- * Get beginArrow
+ * Get beginArrow.
*
* @return string
*/
@@ -208,24 +212,25 @@ public function getBeginArrow()
}
/**
- * Set beginArrow
+ * Set beginArrow.
*
* @param string $value
+ *
* @return self
*/
public function setBeginArrow($value = null)
{
- $enum = array(
+ $enum = [
self::ARROW_STYLE_BLOCK, self::ARROW_STYLE_CLASSIC, self::ARROW_STYLE_DIAMOND,
self::ARROW_STYLE_OPEN, self::ARROW_STYLE_OVAL,
- );
+ ];
$this->beginArrow = $this->setEnumVal($value, $enum, $this->beginArrow);
return $this;
}
/**
- * Get endArrow
+ * Get endArrow.
*
* @return string
*/
@@ -235,24 +240,25 @@ public function getEndArrow()
}
/**
- * Set endArrow
+ * Set endArrow.
*
* @param string $value
+ *
* @return self
*/
public function setEndArrow($value = null)
{
- $enum = array(
+ $enum = [
self::ARROW_STYLE_BLOCK, self::ARROW_STYLE_CLASSIC, self::ARROW_STYLE_DIAMOND,
self::ARROW_STYLE_OPEN, self::ARROW_STYLE_OVAL,
- );
+ ];
$this->endArrow = $this->setEnumVal($value, $enum, $this->endArrow);
return $this;
}
/**
- * Get Dash
+ * Get Dash.
*
* @return string
*/
@@ -262,18 +268,19 @@ public function getDash()
}
/**
- * Set Dash
+ * Set Dash.
*
* @param string $value
+ *
* @return self
*/
public function setDash($value = null)
{
- $enum = array(
+ $enum = [
self::DASH_STYLE_DASH, self::DASH_STYLE_DASH_DOT, self::DASH_STYLE_LONG_DASH,
self::DASH_STYLE_LONG_DASH_DOT, self::DASH_STYLE_LONG_DASH_DOT_DOT, self::DASH_STYLE_ROUND_DOT,
self::DASH_STYLE_SQUARE_DOT,
- );
+ ];
$this->dash = $this->setEnumVal($value, $enum, $this->dash);
return $this;
diff --git a/src/PhpWord/Style/LineNumbering.php b/src/PhpWord/Style/LineNumbering.php
index 451252d87a..61a98dc8e1 100644
--- a/src/PhpWord/Style/LineNumbering.php
+++ b/src/PhpWord/Style/LineNumbering.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Line numbering style
+ * Line numbering style.
*
* @see http://www.schemacentral.com/sc/ooxml/t-w_CT_LineNumber.html
* @since 0.10.0
@@ -31,46 +31,47 @@ class LineNumbering extends AbstractStyle
const LINE_NUMBERING_NEW_SECTION = 'newSection';
/**
- * Line numbering starting value
+ * Line numbering starting value.
*
* @var int
*/
private $start = 1;
/**
- * Line number increments
+ * Line number increments.
*
* @var int
*/
private $increment = 1;
/**
- * Distance between text and line numbering in twip
+ * Distance between text and line numbering in twip.
*
- * @var int|float
+ * @var float|int
*/
private $distance;
/**
- * Line numbering restart setting continuous|newPage|newSection
+ * Line numbering restart setting continuous|newPage|newSection.
*
* @var string
+ *
* @see http://www.schemacentral.com/sc/ooxml/a-w_restart-1.html
*/
private $restart;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param array $style
*/
- public function __construct($style = array())
+ public function __construct($style = [])
{
$this->setStyleByArray($style);
}
/**
- * Get start
+ * Get start.
*
* @return int
*/
@@ -80,9 +81,10 @@ public function getStart()
}
/**
- * Set start
+ * Set start.
*
* @param int $value
+ *
* @return self
*/
public function setStart($value = null)
@@ -93,7 +95,7 @@ public function setStart($value = null)
}
/**
- * Get increment
+ * Get increment.
*
* @return int
*/
@@ -103,9 +105,10 @@ public function getIncrement()
}
/**
- * Set increment
+ * Set increment.
*
* @param int $value
+ *
* @return self
*/
public function setIncrement($value = null)
@@ -116,9 +119,9 @@ public function setIncrement($value = null)
}
/**
- * Get distance
+ * Get distance.
*
- * @return int|float
+ * @return float|int
*/
public function getDistance()
{
@@ -126,9 +129,10 @@ public function getDistance()
}
/**
- * Set distance
+ * Set distance.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setDistance($value = null)
@@ -139,7 +143,7 @@ public function setDistance($value = null)
}
/**
- * Get restart
+ * Get restart.
*
* @return string
*/
@@ -149,14 +153,15 @@ public function getRestart()
}
/**
- * Set distance
+ * Set distance.
*
* @param string $value
+ *
* @return self
*/
public function setRestart($value = null)
{
- $enum = array(self::LINE_NUMBERING_CONTINUOUS, self::LINE_NUMBERING_NEW_PAGE, self::LINE_NUMBERING_NEW_SECTION);
+ $enum = [self::LINE_NUMBERING_CONTINUOUS, self::LINE_NUMBERING_NEW_PAGE, self::LINE_NUMBERING_NEW_SECTION];
$this->restart = $this->setEnumVal($value, $enum, $this->restart);
return $this;
diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php
index 4293940fd2..28d3fb1b66 100644
--- a/src/PhpWord/Style/ListItem.php
+++ b/src/PhpWord/Style/ListItem.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,7 +20,7 @@
use PhpOffice\PhpWord\Style;
/**
- * List item style
+ * List item style.
*
* Before version 0.10.0, numbering style is defined statically with $listType.
* After version 0.10.0, numbering style is defined by using Numbering and
@@ -36,30 +36,32 @@ class ListItem extends AbstractStyle
const TYPE_ALPHANUM = 9;
/**
- * Legacy list type
+ * Legacy list type.
*
* @var int
*/
private $listType;
/**
- * Numbering style name
+ * Numbering style name.
*
* @var string
+ *
* @since 0.10.0
*/
private $numStyle;
/**
- * Numbering definition instance ID
+ * Numbering definition instance ID.
*
* @var int
+ *
* @since 0.10.0
*/
private $numId;
/**
- * Create new instance
+ * Create new instance.
*
* @param string $numStyle
*/
@@ -73,7 +75,7 @@ public function __construct($numStyle = null)
}
/**
- * Get List Type
+ * Get List Type.
*
* @return int
*/
@@ -83,18 +85,19 @@ public function getListType()
}
/**
- * Set legacy list type for version < 0.10.0
+ * Set legacy list type for version < 0.10.0.
*
* @param int $value
+ *
* @return self
*/
public function setListType($value = self::TYPE_BULLET_FILLED)
{
- $enum = array(
+ $enum = [
self::TYPE_SQUARE_FILLED, self::TYPE_BULLET_FILLED,
self::TYPE_BULLET_EMPTY, self::TYPE_NUMBER,
self::TYPE_NUMBER_NESTED, self::TYPE_ALPHANUM,
- );
+ ];
$this->listType = $this->setEnumVal($value, $enum, $this->listType);
$this->getListTypeStyle();
@@ -102,7 +105,7 @@ public function setListType($value = self::TYPE_BULLET_FILLED)
}
/**
- * Get numbering style name
+ * Get numbering style name.
*
* @return string
*/
@@ -112,9 +115,10 @@ public function getNumStyle()
}
/**
- * Set numbering style name
+ * Set numbering style name.
*
* @param string $value
+ *
* @return self
*/
public function setNumStyle($value)
@@ -130,7 +134,7 @@ public function setNumStyle($value)
}
/**
- * Get numbering Id
+ * Get numbering Id.
*
* @return int
*/
@@ -140,19 +144,21 @@ public function getNumId()
}
/**
- * Set numbering Id. Same numId means same list
+ * Set numbering Id. Same numId means same list.
+ *
* @param mixed $numInt
*/
- public function setNumId($numInt)
+ public function setNumId($numInt): void
{
$this->numId = $numInt;
$this->getListTypeStyle();
}
/**
- * Get legacy numbering definition
+ * Get legacy numbering definition.
*
* @return array
+ *
* @since 0.10.0
*/
private function getListTypeStyle()
@@ -171,13 +177,13 @@ private function getListTypeStyle()
}
// Property mapping for numbering level information
- $properties = array('start', 'format', 'text', 'alignment', 'tabPos', 'left', 'hanging', 'font', 'hint');
+ $properties = ['start', 'format', 'text', 'alignment', 'tabPos', 'left', 'hanging', 'font', 'hint'];
// Legacy level information
- $listTypeStyles = array(
- self::TYPE_SQUARE_FILLED => array(
- 'type' => 'hybridMultilevel',
- 'levels' => array(
+ $listTypeStyles = [
+ self::TYPE_SQUARE_FILLED => [
+ 'type' => 'hybridMultilevel',
+ 'levels' => [
0 => '1, bullet, , left, 720, 720, 360, Wingdings, default',
1 => '1, bullet, o, left, 1440, 1440, 360, Courier New, default',
2 => '1, bullet, , left, 2160, 2160, 360, Wingdings, default',
@@ -187,11 +193,11 @@ private function getListTypeStyle()
6 => '1, bullet, , left, 5040, 5040, 360, Symbol, default',
7 => '1, bullet, o, left, 5760, 5760, 360, Courier New, default',
8 => '1, bullet, , left, 6480, 6480, 360, Wingdings, default',
- ),
- ),
- self::TYPE_BULLET_FILLED => array(
- 'type' => 'hybridMultilevel',
- 'levels' => array(
+ ],
+ ],
+ self::TYPE_BULLET_FILLED => [
+ 'type' => 'hybridMultilevel',
+ 'levels' => [
0 => '1, bullet, , left, 720, 720, 360, Symbol, default',
1 => '1, bullet, o, left, 1440, 1440, 360, Courier New, default',
2 => '1, bullet, , left, 2160, 2160, 360, Wingdings, default',
@@ -201,11 +207,11 @@ private function getListTypeStyle()
6 => '1, bullet, , left, 5040, 5040, 360, Symbol, default',
7 => '1, bullet, o, left, 5760, 5760, 360, Courier New, default',
8 => '1, bullet, , left, 6480, 6480, 360, Wingdings, default',
- ),
- ),
- self::TYPE_BULLET_EMPTY => array(
- 'type' => 'hybridMultilevel',
- 'levels' => array(
+ ],
+ ],
+ self::TYPE_BULLET_EMPTY => [
+ 'type' => 'hybridMultilevel',
+ 'levels' => [
0 => '1, bullet, o, left, 720, 720, 360, Courier New, default',
1 => '1, bullet, o, left, 1440, 1440, 360, Courier New, default',
2 => '1, bullet, , left, 2160, 2160, 360, Wingdings, default',
@@ -215,11 +221,11 @@ private function getListTypeStyle()
6 => '1, bullet, , left, 5040, 5040, 360, Symbol, default',
7 => '1, bullet, o, left, 5760, 5760, 360, Courier New, default',
8 => '1, bullet, , left, 6480, 6480, 360, Wingdings, default',
- ),
- ),
- self::TYPE_NUMBER => array(
- 'type' => 'hybridMultilevel',
- 'levels' => array(
+ ],
+ ],
+ self::TYPE_NUMBER => [
+ 'type' => 'hybridMultilevel',
+ 'levels' => [
0 => '1, decimal, %1., left, 720, 720, 360, , default',
1 => '1, bullet, o, left, 1440, 1440, 360, Courier New, default',
2 => '1, bullet, , left, 2160, 2160, 360, Wingdings, default',
@@ -229,11 +235,11 @@ private function getListTypeStyle()
6 => '1, bullet, , left, 5040, 5040, 360, Symbol, default',
7 => '1, bullet, o, left, 5760, 5760, 360, Courier New, default',
8 => '1, bullet, , left, 6480, 6480, 360, Wingdings, default',
- ),
- ),
- self::TYPE_NUMBER_NESTED => array(
- 'type' => 'multilevel',
- 'levels' => array(
+ ],
+ ],
+ self::TYPE_NUMBER_NESTED => [
+ 'type' => 'multilevel',
+ 'levels' => [
0 => '1, decimal, %1., left, 360, 360, 360, , ',
1 => '1, decimal, %1.%2., left, 792, 792, 432, , ',
2 => '1, decimal, %1.%2.%3., left, 1224, 1224, 504, , ',
@@ -243,11 +249,11 @@ private function getListTypeStyle()
6 => '1, decimal, %1.%2.%3.%4.%5.%6.%7., left, 3600, 3240, 1080, , ',
7 => '1, decimal, %1.%2.%3.%4.%5.%6.%7.%8., left, 3960, 3744, 1224, , ',
8 => '1, decimal, %1.%2.%3.%4.%5.%6.%7.%8.%9., left, 4680, 4320, 1440, , ',
- ),
- ),
- self::TYPE_ALPHANUM => array(
- 'type' => 'multilevel',
- 'levels' => array(
+ ],
+ ],
+ self::TYPE_ALPHANUM => [
+ 'type' => 'multilevel',
+ 'levels' => [
0 => '1, decimal, %1., left, 720, 720, 360, , ',
1 => '1, lowerLetter, %2., left, 1440, 1440, 360, , ',
2 => '1, lowerRoman, %3., right, 2160, 2160, 180, , ',
@@ -257,18 +263,18 @@ private function getListTypeStyle()
6 => '1, decimal, %7., left, 5040, 5040, 360, , ',
7 => '1, lowerLetter, %8., left, 5760, 5760, 360, , ',
8 => '1, lowerRoman, %9., right, 6480, 6480, 180, , ',
- ),
- ),
- );
+ ],
+ ],
+ ];
// Populate style and register to global Style register
$style = $listTypeStyles[$this->listType];
$numProperties = count($properties);
foreach ($style['levels'] as $key => $value) {
- $level = array();
+ $level = [];
$levelProperties = explode(', ', $value);
$level['level'] = $key;
- for ($i = 0; $i < $numProperties; $i++) {
+ for ($i = 0; $i < $numProperties; ++$i) {
$property = $properties[$i];
$level[$property] = $levelProperties[$i];
}
diff --git a/src/PhpWord/Style/Numbering.php b/src/PhpWord/Style/Numbering.php
index f7855cfa20..0efb088dd4 100644
--- a/src/PhpWord/Style/Numbering.php
+++ b/src/PhpWord/Style/Numbering.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Numbering style
+ * Numbering style.
*
* @see http://www.schemacentral.com/sc/ooxml/e-w_numbering.html
* @see http://www.schemacentral.com/sc/ooxml/e-w_abstractNum-1.html
@@ -28,30 +28,32 @@
class Numbering extends AbstractStyle
{
/**
- * Numbering definition instance ID
+ * Numbering definition instance ID.
*
* @var int
+ *
* @see http://www.schemacentral.com/sc/ooxml/e-w_num-1.html
*/
private $numId;
/**
- * Multilevel type singleLevel|multilevel|hybridMultilevel
+ * Multilevel type singleLevel|multilevel|hybridMultilevel.
*
* @var string
+ *
* @see http://www.schemacentral.com/sc/ooxml/a-w_val-67.html
*/
private $type;
/**
- * Numbering levels
+ * Numbering levels.
*
* @var NumberingLevel[]
*/
- private $levels = array();
+ private $levels = [];
/**
- * Get Id
+ * Get Id.
*
* @return int
*/
@@ -61,9 +63,10 @@ public function getNumId()
}
/**
- * Set Id
+ * Set Id.
*
* @param int $value
+ *
* @return self
*/
public function setNumId($value)
@@ -74,7 +77,7 @@ public function setNumId($value)
}
/**
- * Get multilevel type
+ * Get multilevel type.
*
* @return string
*/
@@ -84,21 +87,22 @@ public function getType()
}
/**
- * Set multilevel type
+ * Set multilevel type.
*
* @param string $value
+ *
* @return self
*/
public function setType($value)
{
- $enum = array('singleLevel', 'multilevel', 'hybridMultilevel');
+ $enum = ['singleLevel', 'multilevel', 'hybridMultilevel'];
$this->type = $this->setEnumVal($value, $enum, $this->type);
return $this;
}
/**
- * Get levels
+ * Get levels.
*
* @return NumberingLevel[]
*/
@@ -108,9 +112,10 @@ public function getLevels()
}
/**
- * Set multilevel type
+ * Set multilevel type.
*
* @param array $values
+ *
* @return self
*/
public function setLevels($values)
diff --git a/src/PhpWord/Style/NumberingLevel.php b/src/PhpWord/Style/NumberingLevel.php
index e9b32f0135..5efc830016 100644
--- a/src/PhpWord/Style/NumberingLevel.php
+++ b/src/PhpWord/Style/NumberingLevel.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,7 +21,7 @@
use PhpOffice\PhpWord\SimpleType\NumberFormat;
/**
- * Numbering level definition
+ * Numbering level definition.
*
* @see http://www.schemacentral.com/sc/ooxml/e-w_lvl-1.html
* @since 0.10.0
@@ -29,105 +29,112 @@
class NumberingLevel extends AbstractStyle
{
/**
- * Level number, 0 to 8 (total 9 levels)
+ * Level number, 0 to 8 (total 9 levels).
*
* @var int
*/
private $level = 0;
/**
- * Starting value w:start
+ * Starting value w:start.
*
* @var int
+ *
* @see http://www.schemacentral.com/sc/ooxml/e-w_start-1.html
*/
private $start = 1;
/**
- * Numbering format w:numFmt, one of PhpOffice\PhpWord\SimpleType\NumberFormat
+ * Numbering format w:numFmt, one of PhpOffice\PhpWord\SimpleType\NumberFormat.
*
* @var string
+ *
* @see http://www.schemacentral.com/sc/ooxml/t-w_ST_NumberFormat.html
*/
private $format;
/**
- * Restart numbering level symbol w:lvlRestart
+ * Restart numbering level symbol w:lvlRestart.
*
* @var int
+ *
* @see http://www.schemacentral.com/sc/ooxml/e-w_lvlRestart-1.html
*/
private $restart;
/**
- * Related paragraph style
+ * Related paragraph style.
*
* @var string
+ *
* @see http://www.schemacentral.com/sc/ooxml/e-w_pStyle-2.html
*/
private $pStyle;
/**
- * Content between numbering symbol and paragraph text w:suff
+ * Content between numbering symbol and paragraph text w:suff.
*
* @var string tab|space|nothing
+ *
* @see http://www.schemacentral.com/sc/ooxml/e-w_suff-1.html
*/
private $suffix = 'tab';
/**
- * Numbering level text e.g. %1 for nonbullet or bullet character
+ * Numbering level text e.g. %1 for nonbullet or bullet character.
*
* @var string
+ *
* @see http://www.schemacentral.com/sc/ooxml/e-w_lvlText-1.html
*/
private $text;
/**
- * Justification, w:lvlJc
+ * Justification, w:lvlJc.
*
* @var string, one of PhpOffice\PhpWord\SimpleType\Jc
*/
private $alignment = '';
/**
- * Left
+ * Left.
*
* @var int
*/
private $left;
/**
- * Hanging
+ * Hanging.
*
* @var int
*/
private $hanging;
/**
- * Tab position
+ * Tab position.
*
* @var int
*/
private $tabPos;
/**
- * Font family
+ * Font family.
*
* @var string
*/
private $font;
/**
- * Hint default|eastAsia|cs
+ * Hint default|eastAsia|cs.
*
* @var string
+ *
* @see http://www.schemacentral.com/sc/ooxml/a-w_hint-1.html
*/
private $hint;
/**
- * Get level
+ * Get level.
*
* @return int
*/
@@ -137,9 +144,10 @@ public function getLevel()
}
/**
- * Set level
+ * Set level.
*
* @param int $value
+ *
* @return self
*/
public function setLevel($value)
@@ -150,7 +158,7 @@ public function setLevel($value)
}
/**
- * Get start
+ * Get start.
*
* @return int
*/
@@ -160,9 +168,10 @@ public function getStart()
}
/**
- * Set start
+ * Set start.
*
* @param int $value
+ *
* @return self
*/
public function setStart($value)
@@ -173,7 +182,7 @@ public function setStart($value)
}
/**
- * Get format
+ * Get format.
*
* @return string
*/
@@ -183,9 +192,10 @@ public function getFormat()
}
/**
- * Set format
+ * Set format.
*
* @param string $value
+ *
* @return self
*/
public function setFormat($value)
@@ -196,7 +206,7 @@ public function setFormat($value)
}
/**
- * Get restart
+ * Get restart.
*
* @return int
*/
@@ -206,9 +216,10 @@ public function getRestart()
}
/**
- * Set restart
+ * Set restart.
*
* @param int $value
+ *
* @return self
*/
public function setRestart($value)
@@ -219,7 +230,7 @@ public function setRestart($value)
}
/**
- * Get related paragraph style
+ * Get related paragraph style.
*
* @return string
*/
@@ -229,9 +240,10 @@ public function getPStyle()
}
/**
- * Set related paragraph style
+ * Set related paragraph style.
*
* @param string $value
+ *
* @return self
*/
public function setPStyle($value)
@@ -242,7 +254,7 @@ public function setPStyle($value)
}
/**
- * Get suffix
+ * Get suffix.
*
* @return string
*/
@@ -252,21 +264,22 @@ public function getSuffix()
}
/**
- * Set suffix
+ * Set suffix.
*
* @param string $value
+ *
* @return self
*/
public function setSuffix($value)
{
- $enum = array('tab', 'space', 'nothing');
+ $enum = ['tab', 'space', 'nothing'];
$this->suffix = $this->setEnumVal($value, $enum, $this->suffix);
return $this;
}
/**
- * Get text
+ * Get text.
*
* @return string
*/
@@ -276,9 +289,10 @@ public function getText()
}
/**
- * Set text
+ * Set text.
*
* @param string $value
+ *
* @return self
*/
public function setText($value)
@@ -341,7 +355,7 @@ public function setAlign($value)
}
/**
- * Get left
+ * Get left.
*
* @return int
*/
@@ -351,9 +365,10 @@ public function getLeft()
}
/**
- * Set left
+ * Set left.
*
* @param int $value
+ *
* @return self
*/
public function setLeft($value)
@@ -364,7 +379,7 @@ public function setLeft($value)
}
/**
- * Get hanging
+ * Get hanging.
*
* @return int
*/
@@ -374,9 +389,10 @@ public function getHanging()
}
/**
- * Set hanging
+ * Set hanging.
*
* @param int $value
+ *
* @return self
*/
public function setHanging($value)
@@ -387,7 +403,7 @@ public function setHanging($value)
}
/**
- * Get tab
+ * Get tab.
*
* @return int
*/
@@ -397,9 +413,10 @@ public function getTabPos()
}
/**
- * Set tab
+ * Set tab.
*
* @param int $value
+ *
* @return self
*/
public function setTabPos($value)
@@ -410,7 +427,7 @@ public function setTabPos($value)
}
/**
- * Get font
+ * Get font.
*
* @return string
*/
@@ -420,9 +437,10 @@ public function getFont()
}
/**
- * Set font
+ * Set font.
*
* @param string $value
+ *
* @return self
*/
public function setFont($value)
@@ -433,7 +451,7 @@ public function setFont($value)
}
/**
- * Get hint
+ * Get hint.
*
* @return string
*/
@@ -443,14 +461,15 @@ public function getHint()
}
/**
- * Set hint
+ * Set hint.
*
* @param string $value
+ *
* @return self
*/
public function setHint($value = null)
{
- $enum = array('default', 'eastAsia', 'cs');
+ $enum = ['default', 'eastAsia', 'cs'];
$this->hint = $this->setEnumVal($value, $enum, $this->hint);
return $this;
diff --git a/src/PhpWord/Style/Outline.php b/src/PhpWord/Style/Outline.php
index a04ad974c0..6d83f0378d 100644
--- a/src/PhpWord/Style/Outline.php
+++ b/src/PhpWord/Style/Outline.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Outline defines the line/border of the object
+ * Outline defines the line/border of the object.
*
* @see http://www.schemacentral.com/sc/ooxml/t-v_CT_Stroke.html
* @see http://www.w3.org/TR/1998/NOTE-VML-19980513#_Toc416858395
@@ -27,9 +27,10 @@
class Outline extends AbstractStyle
{
/**
- * Line style constants
+ * Line style constants.
*
* @see http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeLineStyle.html
+ *
* @const string
*/
const LINE_SINGLE = 'single';
@@ -39,9 +40,10 @@ class Outline extends AbstractStyle
const LINE_THICK_BETWEEN_THIN = 'thickBetweenThin';
/**
- * Line style constants
+ * Line style constants.
*
* @see http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeEndCap.html
+ *
* @const string
*/
const ENDCAP_FLAT = 'flat';
@@ -49,9 +51,10 @@ class Outline extends AbstractStyle
const ENDCAP_ROUND = 'round';
/**
- * Arrowhead type constants
+ * Arrowhead type constants.
*
* @see http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeArrowType.html
+ *
* @const string
*/
const ARROW_NONE = 'none';
@@ -62,74 +65,75 @@ class Outline extends AbstractStyle
const ARROW_OPEN = 'open';
/**
- * Unit; No set method for now
+ * Unit; No set method for now.
*
* @var string
*/
private $unit = 'pt';
/**
- * Outline weight
+ * Outline weight.
*
- * @var int|float
+ * @var float|int
*/
private $weight;
/**
- * Outline color
+ * Outline color.
*
* @var string
*/
private $color;
/**
- * Dash type
+ * Dash type.
*
* @var string
*/
private $dash;
/**
- * Line style
+ * Line style.
*
* @var string
*/
private $line;
/**
- * End cap
+ * End cap.
*
* @var string
+ *
* @see http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeEndCap.html
*/
private $endCap;
/**
- * Start arrow type
+ * Start arrow type.
*
* @var string
*/
private $startArrow;
/**
- * End arrow type
+ * End arrow type.
*
* @var string
*/
private $endArrow;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param array $style
*/
- public function __construct($style = array())
+ public function __construct($style = [])
{
$this->setStyleByArray($style);
}
/**
- * Get unit
+ * Get unit.
*
* @return string
*/
@@ -139,9 +143,9 @@ public function getUnit()
}
/**
- * Get weight
+ * Get weight.
*
- * @return int|float
+ * @return float|int
*/
public function getWeight()
{
@@ -149,9 +153,10 @@ public function getWeight()
}
/**
- * Set weight
+ * Set weight.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setWeight($value = null)
@@ -162,7 +167,7 @@ public function setWeight($value = null)
}
/**
- * Get color
+ * Get color.
*
* @return string
*/
@@ -172,9 +177,10 @@ public function getColor()
}
/**
- * Set color
+ * Set color.
*
* @param string $value
+ *
* @return self
*/
public function setColor($value = null)
@@ -185,7 +191,7 @@ public function setColor($value = null)
}
/**
- * Get dash type
+ * Get dash type.
*
* @return string
*/
@@ -195,9 +201,10 @@ public function getDash()
}
/**
- * Set dash type
+ * Set dash type.
*
* @param string $value
+ *
* @return self
*/
public function setDash($value = null)
@@ -208,7 +215,7 @@ public function setDash($value = null)
}
/**
- * Get line style
+ * Get line style.
*
* @return string
*/
@@ -218,22 +225,23 @@ public function getLine()
}
/**
- * Set line style
+ * Set line style.
*
* @param string $value
+ *
* @return self
*/
public function setLine($value = null)
{
- $enum = array(self::LINE_SINGLE, self::LINE_THIN_THIN, self::LINE_THIN_THICK,
- self::LINE_THICK_THIN, self::LINE_THICK_BETWEEN_THIN, );
+ $enum = [self::LINE_SINGLE, self::LINE_THIN_THIN, self::LINE_THIN_THICK,
+ self::LINE_THICK_THIN, self::LINE_THICK_BETWEEN_THIN, ];
$this->line = $this->setEnumVal($value, $enum, null);
return $this;
}
/**
- * Get endCap style
+ * Get endCap style.
*
* @return string
*/
@@ -243,21 +251,22 @@ public function getEndCap()
}
/**
- * Set endCap style
+ * Set endCap style.
*
* @param string $value
+ *
* @return self
*/
public function setEndCap($value = null)
{
- $enum = array(self::ENDCAP_FLAT, self::ENDCAP_SQUARE, self::ENDCAP_ROUND);
+ $enum = [self::ENDCAP_FLAT, self::ENDCAP_SQUARE, self::ENDCAP_ROUND];
$this->endCap = $this->setEnumVal($value, $enum, null);
return $this;
}
/**
- * Get startArrow
+ * Get startArrow.
*
* @return string
*/
@@ -267,22 +276,23 @@ public function getStartArrow()
}
/**
- * Set pattern
+ * Set pattern.
*
* @param string $value
+ *
* @return self
*/
public function setStartArrow($value = null)
{
- $enum = array(self::ARROW_NONE, self::ARROW_BLOCK, self::ARROW_CLASSIC,
- self::ARROW_OVAL, self::ARROW_DIAMOND, self::ARROW_OPEN, );
+ $enum = [self::ARROW_NONE, self::ARROW_BLOCK, self::ARROW_CLASSIC,
+ self::ARROW_OVAL, self::ARROW_DIAMOND, self::ARROW_OPEN, ];
$this->startArrow = $this->setEnumVal($value, $enum, null);
return $this;
}
/**
- * Get endArrow
+ * Get endArrow.
*
* @return string
*/
@@ -292,15 +302,16 @@ public function getEndArrow()
}
/**
- * Set pattern
+ * Set pattern.
*
* @param string $value
+ *
* @return self
*/
public function setEndArrow($value = null)
{
- $enum = array(self::ARROW_NONE, self::ARROW_BLOCK, self::ARROW_CLASSIC,
- self::ARROW_OVAL, self::ARROW_DIAMOND, self::ARROW_OPEN, );
+ $enum = [self::ARROW_NONE, self::ARROW_BLOCK, self::ARROW_CLASSIC,
+ self::ARROW_OVAL, self::ARROW_DIAMOND, self::ARROW_OPEN, ];
$this->endArrow = $this->setEnumVal($value, $enum, null);
return $this;
diff --git a/src/PhpWord/Style/Paper.php b/src/PhpWord/Style/Paper.php
index 3c93ed8f2f..3a340bda9d 100644
--- a/src/PhpWord/Style/Paper.php
+++ b/src/PhpWord/Style/Paper.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,7 +20,7 @@
use PhpOffice\PhpWord\Shared\Converter;
/**
- * Paper size from ISO/IEC 29500-1:2012 pg. 1656-1657
+ * Paper size from ISO/IEC 29500-1:2012 pg. 1656-1657.
*
* 1 = Letter paper (8.5 in. by 11 in.)
* 2 = Letter small paper (8.5 in. by 11 in.)
@@ -94,43 +94,43 @@
class Paper extends AbstractStyle
{
/**
- * Paper sizes
+ * Paper sizes.
*
* @var array
*/
- private $sizes = array(
- 'A3' => array(297, 420, 'mm'),
- 'A4' => array(210, 297, 'mm'),
- 'A5' => array(148, 210, 'mm'),
- 'B5' => array(176, 250, 'mm'),
- 'Folio' => array(8.5, 13, 'in'),
- 'Legal' => array(8.5, 14, 'in'),
- 'Letter' => array(8.5, 11, 'in'),
- );
+ private $sizes = [
+ 'A3' => [297, 420, 'mm'],
+ 'A4' => [210, 297, 'mm'],
+ 'A5' => [148, 210, 'mm'],
+ 'B5' => [176, 250, 'mm'],
+ 'Folio' => [8.5, 13, 'in'],
+ 'Legal' => [8.5, 14, 'in'],
+ 'Letter' => [8.5, 11, 'in'],
+ ];
/**
- * Paper size
+ * Paper size.
*
* @var string
*/
private $size = 'A4';
/**
- * Width
+ * Width.
*
* @var float (twip)
*/
private $width;
/**
- * Height
+ * Height.
*
* @var float (twip)
*/
private $height;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param string $size
*/
@@ -140,7 +140,7 @@ public function __construct($size = 'A4')
}
/**
- * Get size
+ * Get size.
*
* @return string
*/
@@ -150,16 +150,17 @@ public function getSize()
}
/**
- * Set size
+ * Set size.
*
* @param string $size
+ *
* @return self
*/
public function setSize($size)
{
$this->size = $this->setEnumVal($size, array_keys($this->sizes), $this->size);
- list($width, $height, $unit) = $this->sizes[$this->size];
+ [$width, $height, $unit] = $this->sizes[$this->size];
if ($unit == 'mm') {
$this->width = Converter::cmToTwip($width / 10);
@@ -173,7 +174,7 @@ public function setSize($size)
}
/**
- * Get width
+ * Get width.
*
* @return float
*/
@@ -183,7 +184,7 @@ public function getWidth()
}
/**
- * Get height
+ * Get height.
*
* @return float
*/
diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php
index 522dea9baf..cce8d3ce9c 100644
--- a/src/PhpWord/Style/Paragraph.php
+++ b/src/PhpWord/Style/Paragraph.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -23,7 +23,7 @@
use PhpOffice\PhpWord\SimpleType\TextAlignment;
/**
- * Paragraph style
+ * Paragraph style.
*
* OOXML:
* - General: alignment, outline level
@@ -57,21 +57,21 @@ class Paragraph extends Border
const LINE_HEIGHT = 240;
/**
- * Aliases
+ * Aliases.
*
* @var array
*/
- protected $aliases = array('line-height' => 'lineHeight', 'line-spacing' => 'spacing');
+ protected $aliases = ['line-height' => 'lineHeight', 'line-spacing' => 'spacing'];
/**
- * Parent style
+ * Parent style.
*
* @var string
*/
private $basedOn = 'Normal';
/**
- * Style for next paragraph
+ * Style for next paragraph.
*
* @var string
*/
@@ -83,115 +83,116 @@ class Paragraph extends Border
private $alignment = '';
/**
- * Indentation
+ * Indentation.
*
- * @var \PhpOffice\PhpWord\Style\Indentation|null
+ * @var null|\PhpOffice\PhpWord\Style\Indentation
*/
private $indentation;
/**
- * Spacing
+ * Spacing.
*
* @var \PhpOffice\PhpWord\Style\Spacing
*/
private $spacing;
/**
- * Text line height
+ * Text line height.
*
* @var int
*/
private $lineHeight;
/**
- * Allow first/last line to display on a separate page
+ * Allow first/last line to display on a separate page.
*
* @var bool
*/
private $widowControl = true;
/**
- * Keep paragraph with next paragraph
+ * Keep paragraph with next paragraph.
*
* @var bool
*/
private $keepNext = false;
/**
- * Keep all lines on one page
+ * Keep all lines on one page.
*
* @var bool
*/
private $keepLines = false;
/**
- * Start paragraph on next page
+ * Start paragraph on next page.
*
* @var bool
*/
private $pageBreakBefore = false;
/**
- * Numbering style name
+ * Numbering style name.
*
* @var string
*/
private $numStyle;
/**
- * Numbering level
+ * Numbering level.
*
* @var int
*/
private $numLevel = 0;
/**
- * Set of Custom Tab Stops
+ * Set of Custom Tab Stops.
*
* @var \PhpOffice\PhpWord\Style\Tab[]
*/
- private $tabs = array();
+ private $tabs = [];
/**
- * Shading
+ * Shading.
*
* @var \PhpOffice\PhpWord\Style\Shading
*/
private $shading;
/**
- * Ignore Spacing Above and Below When Using Identical Styles
+ * Ignore Spacing Above and Below When Using Identical Styles.
*
* @var bool
*/
private $contextualSpacing = false;
/**
- * Right to Left Paragraph Layout
+ * Right to Left Paragraph Layout.
*
* @var bool
*/
private $bidi = false;
/**
- * Vertical Character Alignment on Line
+ * Vertical Character Alignment on Line.
*
* @var string
*/
private $textAlignment;
/**
- * Suppress hyphenation for paragraph
+ * Suppress hyphenation for paragraph.
*
* @var bool
*/
private $suppressAutoHyphens = false;
/**
- * Set Style value
+ * Set Style value.
*
* @param string $key
* @param mixed $value
+ *
* @return self
*/
public function setStyleValue($key, $value)
@@ -205,41 +206,42 @@ public function setStyleValue($key, $value)
}
/**
- * Get style values
+ * Get style values.
*
* An experiment to retrieve all style values in one function. This will
* reduce function call and increase cohesion between functions. Should be
* implemented in all styles.
*
* @ignoreScrutinizerPatch
+ *
* @return array
*/
public function getStyleValues()
{
- $styles = array(
- 'name' => $this->getStyleName(),
- 'basedOn' => $this->getBasedOn(),
- 'next' => $this->getNext(),
- 'alignment' => $this->getAlignment(),
- 'indentation' => $this->getIndentation(),
- 'spacing' => $this->getSpace(),
- 'pagination' => array(
- 'widowControl' => $this->hasWidowControl(),
- 'keepNext' => $this->isKeepNext(),
- 'keepLines' => $this->isKeepLines(),
- 'pageBreak' => $this->hasPageBreakBefore(),
- ),
- 'numbering' => array(
- 'style' => $this->getNumStyle(),
- 'level' => $this->getNumLevel(),
- ),
- 'tabs' => $this->getTabs(),
- 'shading' => $this->getShading(),
- 'contextualSpacing' => $this->hasContextualSpacing(),
- 'bidi' => $this->isBidi(),
- 'textAlignment' => $this->getTextAlignment(),
+ $styles = [
+ 'name' => $this->getStyleName(),
+ 'basedOn' => $this->getBasedOn(),
+ 'next' => $this->getNext(),
+ 'alignment' => $this->getAlignment(),
+ 'indentation' => $this->getIndentation(),
+ 'spacing' => $this->getSpace(),
+ 'pagination' => [
+ 'widowControl' => $this->hasWidowControl(),
+ 'keepNext' => $this->isKeepNext(),
+ 'keepLines' => $this->isKeepLines(),
+ 'pageBreak' => $this->hasPageBreakBefore(),
+ ],
+ 'numbering' => [
+ 'style' => $this->getNumStyle(),
+ 'level' => $this->getNumLevel(),
+ ],
+ 'tabs' => $this->getTabs(),
+ 'shading' => $this->getShading(),
+ 'contextualSpacing' => $this->hasContextualSpacing(),
+ 'bidi' => $this->isBidi(),
+ 'textAlignment' => $this->getTextAlignment(),
'suppressAutoHyphens' => $this->hasSuppressAutoHyphens(),
- );
+ ];
return $styles;
}
@@ -297,7 +299,7 @@ public function setAlign($value = null)
}
/**
- * Get parent style ID
+ * Get parent style ID.
*
* @return string
*/
@@ -307,9 +309,10 @@ public function getBasedOn()
}
/**
- * Set parent style ID
+ * Set parent style ID.
*
* @param string $value
+ *
* @return self
*/
public function setBasedOn($value = 'Normal')
@@ -320,7 +323,7 @@ public function setBasedOn($value = 'Normal')
}
/**
- * Get style for next paragraph
+ * Get style for next paragraph.
*
* @return string
*/
@@ -330,9 +333,10 @@ public function getNext()
}
/**
- * Set style for next paragraph
+ * Set style for next paragraph.
*
* @param string $value
+ *
* @return self
*/
public function setNext($value = null)
@@ -343,7 +347,7 @@ public function setNext($value = null)
}
/**
- * Get shading
+ * Get shading.
*
* @return \PhpOffice\PhpWord\Style\Indentation
*/
@@ -353,9 +357,10 @@ public function getIndentation()
}
/**
- * Set shading
+ * Set shading.
*
* @param mixed $value
+ *
* @return self
*/
public function setIndentation($value = null)
@@ -366,7 +371,7 @@ public function setIndentation($value = null)
}
/**
- * Get indentation
+ * Get indentation.
*
* @return int
*/
@@ -376,18 +381,19 @@ public function getIndent()
}
/**
- * Set indentation
+ * Set indentation.
*
* @param int $value
+ *
* @return self
*/
public function setIndent($value = null)
{
- return $this->setIndentation(array('left' => $value));
+ return $this->setIndentation(['left' => $value]);
}
/**
- * Get hanging
+ * Get hanging.
*
* @return int
*/
@@ -397,20 +403,22 @@ public function getHanging()
}
/**
- * Set hanging
+ * Set hanging.
*
* @param int $value
+ *
* @return self
*/
public function setHanging($value = null)
{
- return $this->setIndentation(array('hanging' => $value));
+ return $this->setIndentation(['hanging' => $value]);
}
/**
- * Get spacing
+ * Get spacing.
*
* @return \PhpOffice\PhpWord\Style\Spacing
+ *
* @todo Rename to getSpacing in 1.0
*/
public function getSpace()
@@ -419,10 +427,12 @@ public function getSpace()
}
/**
- * Set spacing
+ * Set spacing.
*
* @param mixed $value
+ *
* @return self
+ *
* @todo Rename to setSpacing in 1.0
*/
public function setSpace($value = null)
@@ -433,7 +443,7 @@ public function setSpace($value = null)
}
/**
- * Get space before paragraph
+ * Get space before paragraph.
*
* @return int
*/
@@ -443,18 +453,19 @@ public function getSpaceBefore()
}
/**
- * Set space before paragraph
+ * Set space before paragraph.
*
* @param int $value
+ *
* @return self
*/
public function setSpaceBefore($value = null)
{
- return $this->setSpace(array('before' => $value));
+ return $this->setSpace(['before' => $value]);
}
/**
- * Get space after paragraph
+ * Get space after paragraph.
*
* @return int
*/
@@ -464,20 +475,21 @@ public function getSpaceAfter()
}
/**
- * Set space after paragraph
+ * Set space after paragraph.
*
* @param int $value
+ *
* @return self
*/
public function setSpaceAfter($value = null)
{
- return $this->setSpace(array('after' => $value));
+ return $this->setSpace(['after' => $value]);
}
/**
- * Get spacing between lines
+ * Get spacing between lines.
*
- * @return int|float
+ * @return float|int
*/
public function getSpacing()
{
@@ -485,18 +497,19 @@ public function getSpacing()
}
/**
- * Set spacing between lines
+ * Set spacing between lines.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setSpacing($value = null)
{
- return $this->setSpace(array('line' => $value));
+ return $this->setSpace(['line' => $value]);
}
/**
- * Get spacing line rule
+ * Get spacing line rule.
*
* @return string
*/
@@ -506,20 +519,21 @@ public function getSpacingLineRule()
}
/**
- * Set the spacing line rule
+ * Set the spacing line rule.
*
* @param string $value Possible values are defined in LineSpacingRule
+ *
* @return \PhpOffice\PhpWord\Style\Paragraph
*/
public function setSpacingLineRule($value)
{
- return $this->setSpace(array('lineRule' => $value));
+ return $this->setSpace(['lineRule' => $value]);
}
/**
- * Get line height
+ * Get line height.
*
- * @return int|float
+ * @return float|int
*/
public function getLineHeight()
{
@@ -527,11 +541,10 @@ public function getLineHeight()
}
/**
- * Set the line height
+ * Set the line height.
*
- * @param int|float|string $lineHeight
+ * @param float|int|string $lineHeight
*
- * @throws \PhpOffice\PhpWord\Exception\InvalidStyleException
* @return self
*/
public function setLineHeight($lineHeight)
@@ -552,7 +565,7 @@ public function setLineHeight($lineHeight)
}
/**
- * Get allow first/last line to display on a separate page setting
+ * Get allow first/last line to display on a separate page setting.
*
* @return bool
*/
@@ -562,9 +575,10 @@ public function hasWidowControl()
}
/**
- * Set keep paragraph with next paragraph setting
+ * Set keep paragraph with next paragraph setting.
*
* @param bool $value
+ *
* @return self
*/
public function setWidowControl($value = true)
@@ -575,7 +589,7 @@ public function setWidowControl($value = true)
}
/**
- * Get keep paragraph with next paragraph setting
+ * Get keep paragraph with next paragraph setting.
*
* @return bool
*/
@@ -585,9 +599,10 @@ public function isKeepNext()
}
/**
- * Set keep paragraph with next paragraph setting
+ * Set keep paragraph with next paragraph setting.
*
* @param bool $value
+ *
* @return self
*/
public function setKeepNext($value = true)
@@ -598,7 +613,7 @@ public function setKeepNext($value = true)
}
/**
- * Get keep all lines on one page setting
+ * Get keep all lines on one page setting.
*
* @return bool
*/
@@ -608,9 +623,10 @@ public function isKeepLines()
}
/**
- * Set keep all lines on one page setting
+ * Set keep all lines on one page setting.
*
* @param bool $value
+ *
* @return self
*/
public function setKeepLines($value = true)
@@ -621,7 +637,7 @@ public function setKeepLines($value = true)
}
/**
- * Get start paragraph on next page setting
+ * Get start paragraph on next page setting.
*
* @return bool
*/
@@ -631,9 +647,10 @@ public function hasPageBreakBefore()
}
/**
- * Set start paragraph on next page setting
+ * Set start paragraph on next page setting.
*
* @param bool $value
+ *
* @return self
*/
public function setPageBreakBefore($value = true)
@@ -644,7 +661,7 @@ public function setPageBreakBefore($value = true)
}
/**
- * Get numbering style name
+ * Get numbering style name.
*
* @return string
*/
@@ -654,9 +671,10 @@ public function getNumStyle()
}
/**
- * Set numbering style name
+ * Set numbering style name.
*
* @param string $value
+ *
* @return self
*/
public function setNumStyle($value)
@@ -667,7 +685,7 @@ public function setNumStyle($value)
}
/**
- * Get numbering level
+ * Get numbering level.
*
* @return int
*/
@@ -677,9 +695,10 @@ public function getNumLevel()
}
/**
- * Set numbering level
+ * Set numbering level.
*
* @param int $value
+ *
* @return self
*/
public function setNumLevel($value = 0)
@@ -690,7 +709,7 @@ public function setNumLevel($value = 0)
}
/**
- * Get tabs
+ * Get tabs.
*
* @return \PhpOffice\PhpWord\Style\Tab[]
*/
@@ -700,9 +719,10 @@ public function getTabs()
}
/**
- * Set tabs
+ * Set tabs.
*
* @param array $value
+ *
* @return self
*/
public function setTabs($value = null)
@@ -715,7 +735,7 @@ public function setTabs($value = null)
}
/**
- * Get allow first/last line to display on a separate page setting
+ * Get allow first/last line to display on a separate page setting.
*
* @deprecated 0.10.0
*
@@ -727,7 +747,7 @@ public function getWidowControl()
}
/**
- * Get keep paragraph with next paragraph setting
+ * Get keep paragraph with next paragraph setting.
*
* @deprecated 0.10.0
*
@@ -739,7 +759,7 @@ public function getKeepNext()
}
/**
- * Get keep all lines on one page setting
+ * Get keep all lines on one page setting.
*
* @deprecated 0.10.0
*
@@ -751,7 +771,7 @@ public function getKeepLines()
}
/**
- * Get start paragraph on next page setting
+ * Get start paragraph on next page setting.
*
* @deprecated 0.10.0
*
@@ -763,7 +783,7 @@ public function getPageBreakBefore()
}
/**
- * Get shading
+ * Get shading.
*
* @return \PhpOffice\PhpWord\Style\Shading
*/
@@ -773,9 +793,10 @@ public function getShading()
}
/**
- * Set shading
+ * Set shading.
*
* @param mixed $value
+ *
* @return self
*/
public function setShading($value = null)
@@ -786,7 +807,7 @@ public function setShading($value = null)
}
/**
- * Get contextualSpacing
+ * Get contextualSpacing.
*
* @return bool
*/
@@ -796,9 +817,10 @@ public function hasContextualSpacing()
}
/**
- * Set contextualSpacing
+ * Set contextualSpacing.
*
* @param bool $contextualSpacing
+ *
* @return self
*/
public function setContextualSpacing($contextualSpacing)
@@ -809,7 +831,7 @@ public function setContextualSpacing($contextualSpacing)
}
/**
- * Get bidirectional
+ * Get bidirectional.
*
* @return bool
*/
@@ -819,10 +841,11 @@ public function isBidi()
}
/**
- * Set bidi
+ * Set bidi.
*
* @param bool $bidi
* Set to true to write from right to left
+ *
* @return self
*/
public function setBidi($bidi)
@@ -833,7 +856,7 @@ public function setBidi($bidi)
}
/**
- * Get textAlignment
+ * Get textAlignment.
*
* @return string
*/
@@ -843,9 +866,10 @@ public function getTextAlignment()
}
/**
- * Set textAlignment
+ * Set textAlignment.
*
* @param string $textAlignment
+ *
* @return self
*/
public function setTextAlignment($textAlignment)
@@ -867,7 +891,7 @@ public function hasSuppressAutoHyphens()
/**
* @param bool $suppressAutoHyphens
*/
- public function setSuppressAutoHyphens($suppressAutoHyphens)
+ public function setSuppressAutoHyphens($suppressAutoHyphens): void
{
$this->suppressAutoHyphens = (bool) $suppressAutoHyphens;
}
diff --git a/src/PhpWord/Style/Row.php b/src/PhpWord/Style/Row.php
index ad801af6e2..e7be3992e1 100644
--- a/src/PhpWord/Style/Row.php
+++ b/src/PhpWord/Style/Row.php
@@ -11,49 +11,49 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Table row style
+ * Table row style.
*
* @since 0.8.0
*/
class Row extends AbstractStyle
{
/**
- * Repeat table row on every new page
+ * Repeat table row on every new page.
*
* @var bool
*/
private $tblHeader = false;
/**
- * Table row cannot break across pages
+ * Table row cannot break across pages.
*
* @var bool
*/
private $cantSplit = false;
/**
- * Table row exact height
+ * Table row exact height.
*
* @var bool
*/
private $exactHeight = false;
/**
- * Create a new row style
+ * Create a new row style.
*/
public function __construct()
{
}
/**
- * Is tblHeader
+ * Is tblHeader.
*
* @return bool
*/
@@ -63,9 +63,10 @@ public function isTblHeader()
}
/**
- * Is tblHeader
+ * Is tblHeader.
*
* @param bool $value
+ *
* @return self
*/
public function setTblHeader($value = true)
@@ -76,7 +77,7 @@ public function setTblHeader($value = true)
}
/**
- * Is cantSplit
+ * Is cantSplit.
*
* @return bool
*/
@@ -86,9 +87,10 @@ public function isCantSplit()
}
/**
- * Is cantSplit
+ * Is cantSplit.
*
* @param bool $value
+ *
* @return self
*/
public function setCantSplit($value = true)
@@ -99,7 +101,7 @@ public function setCantSplit($value = true)
}
/**
- * Is exactHeight
+ * Is exactHeight.
*
* @return bool
*/
@@ -109,9 +111,10 @@ public function isExactHeight()
}
/**
- * Set exactHeight
+ * Set exactHeight.
*
* @param bool $value
+ *
* @return self
*/
public function setExactHeight($value = true)
@@ -122,7 +125,7 @@ public function setExactHeight($value = true)
}
/**
- * Get tblHeader
+ * Get tblHeader.
*
* @deprecated 0.10.0
*
@@ -134,7 +137,7 @@ public function getTblHeader()
}
/**
- * Get cantSplit
+ * Get cantSplit.
*
* @deprecated 0.10.0
*
@@ -146,7 +149,7 @@ public function getCantSplit()
}
/**
- * Get exactHeight
+ * Get exactHeight.
*
* @deprecated 0.10.0
*
diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php
index 697add7456..29e06bf3cf 100644
--- a/src/PhpWord/Style/Section.php
+++ b/src/PhpWord/Style/Section.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,12 +21,12 @@
use PhpOffice\PhpWord\SimpleType\VerticalJc;
/**
- * Section settings
+ * Section settings.
*/
class Section extends Border
{
/**
- * Page orientation
+ * Page orientation.
*
* @const string
*/
@@ -34,7 +34,7 @@ class Section extends Border
const ORIENTATION_LANDSCAPE = 'landscape';
/**
- * Page default constants
+ * Page default constants.
*
* @const int|float
*/
@@ -48,107 +48,109 @@ class Section extends Border
const DEFAULT_COLUMN_SPACING = 720; // In twips.
/**
- * Page Orientation
+ * Page Orientation.
*
* @var string
+ *
* @see http://www.schemacentral.com/sc/ooxml/a-w_orient-1.html
*/
private $orientation = self::ORIENTATION_PORTRAIT;
/**
- * Paper size
+ * Paper size.
*
* @var \PhpOffice\PhpWord\Style\Paper
*/
private $paper;
/**
- * Page Size Width
+ * Page Size Width.
*
- * @var int|float
+ * @var float|int
*/
private $pageSizeW = self::DEFAULT_WIDTH;
/**
- * Page Size Height
+ * Page Size Height.
*
- * @var int|float
+ * @var float|int
*/
private $pageSizeH = self::DEFAULT_HEIGHT;
/**
- * Top margin spacing
+ * Top margin spacing.
*
- * @var int|float
+ * @var float|int
*/
private $marginTop = self::DEFAULT_MARGIN;
/**
- * Left margin spacing
+ * Left margin spacing.
*
- * @var int|float
+ * @var float|int
*/
private $marginLeft = self::DEFAULT_MARGIN;
/**
- * Right margin spacing
+ * Right margin spacing.
*
- * @var int|float
+ * @var float|int
*/
private $marginRight = self::DEFAULT_MARGIN;
/**
- * Bottom margin spacing
+ * Bottom margin spacing.
*
- * @var int|float
+ * @var float|int
*/
private $marginBottom = self::DEFAULT_MARGIN;
/**
- * Page gutter spacing
+ * Page gutter spacing.
+ *
+ * @var float|int
*
- * @var int|float
* @see http://www.schemacentral.com/sc/ooxml/e-w_pgMar-1.html
*/
private $gutter = self::DEFAULT_GUTTER;
/**
- * Header height
+ * Header height.
*
- * @var int|float
+ * @var float|int
*/
private $headerHeight = self::DEFAULT_HEADER_HEIGHT;
/**
- * Footer height
+ * Footer height.
*
- * @var int|float
+ * @var float|int
*/
private $footerHeight = self::DEFAULT_FOOTER_HEIGHT;
/**
- * Page Numbering Start
+ * Page Numbering Start.
*
* @var int
*/
private $pageNumberingStart;
/**
- * Section columns count
+ * Section columns count.
*
* @var int
*/
private $colsNum = self::DEFAULT_COLUMN_COUNT;
/**
- * Section spacing between columns
+ * Section spacing between columns.
*
- * @var int|float
+ * @var float|int
*/
private $colsSpace = self::DEFAULT_COLUMN_SPACING;
/**
- * Section break type
+ * Section break type.
*
* Options:
* - nextPage: Next page section break
@@ -162,23 +164,24 @@ class Section extends Border
private $breakType;
/**
- * Line numbering
+ * Line numbering.
*
* @var \PhpOffice\PhpWord\Style\LineNumbering
+ *
* @see http://www.schemacentral.com/sc/ooxml/e-w_lnNumType-1.html
*/
private $lineNumbering;
/**
* Vertical Text Alignment on Page
- * One of \PhpOffice\PhpWord\SimpleType\VerticalJc
+ * One of \PhpOffice\PhpWord\SimpleType\VerticalJc.
*
* @var string
*/
private $vAlign;
/**
- * Create new instance
+ * Create new instance.
*/
public function __construct()
{
@@ -186,7 +189,7 @@ public function __construct()
}
/**
- * Get paper size
+ * Get paper size.
*
* @return string
*/
@@ -196,9 +199,10 @@ public function getPaperSize()
}
/**
- * Set paper size
+ * Set paper size.
*
* @param string $value
+ *
* @return self
*/
public function setPaperSize($value = '')
@@ -217,10 +221,11 @@ public function setPaperSize($value = '')
}
/**
- * Set Setting Value
+ * Set Setting Value.
*
* @param string $key
* @param string $value
+ *
* @return self
*/
public function setSettingValue($key, $value)
@@ -229,20 +234,21 @@ public function setSettingValue($key, $value)
}
/**
- * Set orientation
+ * Set orientation.
*
* @param string $value
+ *
* @return self
*/
public function setOrientation($value = null)
{
- $enum = array(self::ORIENTATION_PORTRAIT, self::ORIENTATION_LANDSCAPE);
+ $enum = [self::ORIENTATION_PORTRAIT, self::ORIENTATION_LANDSCAPE];
$this->orientation = $this->setEnumVal($value, $enum, $this->orientation);
- /** @var int|float $longSide Type hint */
+ /** @var float|int $longSide Type hint */
$longSide = $this->pageSizeW >= $this->pageSizeH ? $this->pageSizeW : $this->pageSizeH;
- /** @var int|float $shortSide Type hint */
+ /** @var float|int $shortSide Type hint */
$shortSide = $this->pageSizeW < $this->pageSizeH ? $this->pageSizeW : $this->pageSizeH;
if ($this->orientation == self::ORIENTATION_PORTRAIT) {
@@ -257,7 +263,7 @@ public function setOrientation($value = null)
}
/**
- * Get Page Orientation
+ * Get Page Orientation.
*
* @return string
*/
@@ -267,7 +273,7 @@ public function getOrientation()
}
/**
- * Set Portrait Orientation
+ * Set Portrait Orientation.
*
* @return self
*/
@@ -277,7 +283,7 @@ public function setPortrait()
}
/**
- * Set Landscape Orientation
+ * Set Landscape Orientation.
*
* @return self
*/
@@ -287,9 +293,9 @@ public function setLandscape()
}
/**
- * Get Page Size Width
+ * Get Page Size Width.
*
- * @return int|float|null
+ * @return null|float|int
*
* @since 0.12.0
*/
@@ -299,7 +305,7 @@ public function getPageSizeW()
}
/**
- * @param int|float|null $value
+ * @param null|float|int $value
*
* @return \PhpOffice\PhpWord\Style\Section
*
@@ -313,9 +319,9 @@ public function setPageSizeW($value = null)
}
/**
- * Get Page Size Height
+ * Get Page Size Height.
*
- * @return int|float|null
+ * @return null|float|int
*
* @since 0.12.0
*/
@@ -325,7 +331,7 @@ public function getPageSizeH()
}
/**
- * @param int|float|null $value
+ * @param null|float|int $value
*
* @return \PhpOffice\PhpWord\Style\Section
*
@@ -339,9 +345,9 @@ public function setPageSizeH($value = null)
}
/**
- * Get Margin Top
+ * Get Margin Top.
*
- * @return int|float
+ * @return float|int
*/
public function getMarginTop()
{
@@ -349,9 +355,10 @@ public function getMarginTop()
}
/**
- * Set Margin Top
+ * Set Margin Top.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setMarginTop($value = null)
@@ -362,9 +369,9 @@ public function setMarginTop($value = null)
}
/**
- * Get Margin Left
+ * Get Margin Left.
*
- * @return int|float
+ * @return float|int
*/
public function getMarginLeft()
{
@@ -372,9 +379,10 @@ public function getMarginLeft()
}
/**
- * Set Margin Left
+ * Set Margin Left.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setMarginLeft($value = null)
@@ -385,9 +393,9 @@ public function setMarginLeft($value = null)
}
/**
- * Get Margin Right
+ * Get Margin Right.
*
- * @return int|float
+ * @return float|int
*/
public function getMarginRight()
{
@@ -395,9 +403,10 @@ public function getMarginRight()
}
/**
- * Set Margin Right
+ * Set Margin Right.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setMarginRight($value = null)
@@ -408,9 +417,9 @@ public function setMarginRight($value = null)
}
/**
- * Get Margin Bottom
+ * Get Margin Bottom.
*
- * @return int|float
+ * @return float|int
*/
public function getMarginBottom()
{
@@ -418,9 +427,10 @@ public function getMarginBottom()
}
/**
- * Set Margin Bottom
+ * Set Margin Bottom.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setMarginBottom($value = null)
@@ -431,9 +441,9 @@ public function setMarginBottom($value = null)
}
/**
- * Get gutter
+ * Get gutter.
*
- * @return int|float
+ * @return float|int
*/
public function getGutter()
{
@@ -441,9 +451,10 @@ public function getGutter()
}
/**
- * Set gutter
+ * Set gutter.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setGutter($value = null)
@@ -454,9 +465,9 @@ public function setGutter($value = null)
}
/**
- * Get Header Height
+ * Get Header Height.
*
- * @return int|float
+ * @return float|int
*/
public function getHeaderHeight()
{
@@ -464,9 +475,10 @@ public function getHeaderHeight()
}
/**
- * Set Header Height
+ * Set Header Height.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setHeaderHeight($value = null)
@@ -477,9 +489,9 @@ public function setHeaderHeight($value = null)
}
/**
- * Get Footer Height
+ * Get Footer Height.
*
- * @return int|float
+ * @return float|int
*/
public function getFooterHeight()
{
@@ -487,9 +499,10 @@ public function getFooterHeight()
}
/**
- * Set Footer Height
+ * Set Footer Height.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setFooterHeight($value = null)
@@ -500,7 +513,7 @@ public function setFooterHeight($value = null)
}
/**
- * Get page numbering start
+ * Get page numbering start.
*
* @return null|int
*/
@@ -510,9 +523,10 @@ public function getPageNumberingStart()
}
/**
- * Set page numbering start
+ * Set page numbering start.
*
* @param null|int $pageNumberingStart
+ *
* @return self
*/
public function setPageNumberingStart($pageNumberingStart = null)
@@ -523,7 +537,7 @@ public function setPageNumberingStart($pageNumberingStart = null)
}
/**
- * Get Section Columns Count
+ * Get Section Columns Count.
*
* @return int
*/
@@ -533,9 +547,10 @@ public function getColsNum()
}
/**
- * Set Section Columns Count
+ * Set Section Columns Count.
*
* @param int $value
+ *
* @return self
*/
public function setColsNum($value = null)
@@ -546,9 +561,9 @@ public function setColsNum($value = null)
}
/**
- * Get Section Space Between Columns
+ * Get Section Space Between Columns.
*
- * @return int|float
+ * @return float|int
*/
public function getColsSpace()
{
@@ -556,9 +571,10 @@ public function getColsSpace()
}
/**
- * Set Section Space Between Columns
+ * Set Section Space Between Columns.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setColsSpace($value = null)
@@ -569,7 +585,7 @@ public function setColsSpace($value = null)
}
/**
- * Get Break Type
+ * Get Break Type.
*
* @return string
*/
@@ -579,9 +595,10 @@ public function getBreakType()
}
/**
- * Set Break Type
+ * Set Break Type.
*
* @param string $value
+ *
* @return self
*/
public function setBreakType($value = null)
@@ -592,7 +609,7 @@ public function setBreakType($value = null)
}
/**
- * Get line numbering
+ * Get line numbering.
*
* @return \PhpOffice\PhpWord\Style\LineNumbering
*/
@@ -602,9 +619,10 @@ public function getLineNumbering()
}
/**
- * Set line numbering
+ * Set line numbering.
*
* @param mixed $value
+ *
* @return self
*/
public function setLineNumbering($value = null)
@@ -615,7 +633,7 @@ public function setLineNumbering($value = null)
}
/**
- * Get vertical alignment
+ * Get vertical alignment.
*
* @return string
*/
@@ -625,9 +643,10 @@ public function getVAlign()
}
/**
- * Set vertical alignment
+ * Set vertical alignment.
*
* @param string $value
+ *
* @return self
*/
public function setVAlign($value = null)
diff --git a/src/PhpWord/Style/Shading.php b/src/PhpWord/Style/Shading.php
index 154df26c7a..81d69e313d 100644
--- a/src/PhpWord/Style/Shading.php
+++ b/src/PhpWord/Style/Shading.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Shading style
+ * Shading style.
*
* @see http://www.schemacentral.com/sc/ooxml/t-w_CT_Shd.html
* @since 0.10.0
@@ -26,9 +26,10 @@
class Shading extends AbstractStyle
{
/**
- * Pattern constants (partly)
+ * Pattern constants (partly).
*
* @const string
+ *
* @see http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html
*/
const PATTERN_CLEAR = 'clear'; // No pattern
@@ -40,39 +41,40 @@ class Shading extends AbstractStyle
const PATTERN_DCROSS = 'diagCross'; // Diagonal cross pattern
/**
- * Shading pattern
+ * Shading pattern.
*
* @var string
+ *
* @see http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html
*/
private $pattern = self::PATTERN_CLEAR;
/**
- * Shading pattern color
+ * Shading pattern color.
*
* @var string
*/
private $color;
/**
- * Shading background color
+ * Shading background color.
*
* @var string
*/
private $fill;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param array $style
*/
- public function __construct($style = array())
+ public function __construct($style = [])
{
$this->setStyleByArray($style);
}
/**
- * Get pattern
+ * Get pattern.
*
* @return string
*/
@@ -82,24 +84,25 @@ public function getPattern()
}
/**
- * Set pattern
+ * Set pattern.
*
* @param string $value
+ *
* @return self
*/
public function setPattern($value = null)
{
- $enum = array(
+ $enum = [
self::PATTERN_CLEAR, self::PATTERN_SOLID, self::PATTERN_HSTRIPE,
self::PATTERN_VSTRIPE, self::PATTERN_DSTRIPE, self::PATTERN_HCROSS, self::PATTERN_DCROSS,
- );
+ ];
$this->pattern = $this->setEnumVal($value, $enum, $this->pattern);
return $this;
}
/**
- * Get color
+ * Get color.
*
* @return string
*/
@@ -109,9 +112,10 @@ public function getColor()
}
/**
- * Set pattern
+ * Set pattern.
*
* @param string $value
+ *
* @return self
*/
public function setColor($value = null)
@@ -122,7 +126,7 @@ public function setColor($value = null)
}
/**
- * Get fill
+ * Get fill.
*
* @return string
*/
@@ -132,9 +136,10 @@ public function getFill()
}
/**
- * Set fill
+ * Set fill.
*
* @param string $value
+ *
* @return self
*/
public function setFill($value = null)
diff --git a/src/PhpWord/Style/Shadow.php b/src/PhpWord/Style/Shadow.php
index 1379a32096..3f6252d439 100644
--- a/src/PhpWord/Style/Shadow.php
+++ b/src/PhpWord/Style/Shadow.php
@@ -11,14 +11,14 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Shadow style
+ * Shadow style.
*
* @see http://www.schemacentral.com/sc/ooxml/t-v_CT_Shadow.html
* @since 0.12.0
@@ -26,31 +26,31 @@
class Shadow extends AbstractStyle
{
/**
- * Color
+ * Color.
*
* @var string
*/
private $color;
/**
- * Offset; Format: 3pt,3pt
+ * Offset; Format: 3pt,3pt.
*
* @var string
*/
private $offset;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param array $style
*/
- public function __construct($style = array())
+ public function __construct($style = [])
{
$this->setStyleByArray($style);
}
/**
- * Get color
+ * Get color.
*
* @return string
*/
@@ -60,9 +60,10 @@ public function getColor()
}
/**
- * Set color
+ * Set color.
*
* @param string $value
+ *
* @return self
*/
public function setColor($value = null)
@@ -73,7 +74,7 @@ public function setColor($value = null)
}
/**
- * Get offset
+ * Get offset.
*
* @return string
*/
@@ -83,9 +84,10 @@ public function getOffset()
}
/**
- * Set offset
+ * Set offset.
*
* @param string $value
+ *
* @return self
*/
public function setOffset($value = null)
diff --git a/src/PhpWord/Style/Shape.php b/src/PhpWord/Style/Shape.php
index 0c3f817982..7dd62a1f71 100644
--- a/src/PhpWord/Style/Shape.php
+++ b/src/PhpWord/Style/Shape.php
@@ -11,22 +11,23 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Shape style
+ * Shape style.
*
* @since 0.12.0
+ *
* @todo Skew http://www.schemacentral.com/sc/ooxml/t-o_CT_Skew.html
*/
class Shape extends AbstractStyle
{
/**
- * Points
+ * Points.
*
* - Arc: startAngle endAngle; 0 = top center, moving clockwise
* - Curve: from-x1,from-y1 to-x2,to-y2 control1-x,control1-y control2-x,control2-y
@@ -39,61 +40,61 @@ class Shape extends AbstractStyle
private $points;
/**
- * Roundness measure of corners; 0 = straightest (rectangular); 1 = roundest (circle/oval)
+ * Roundness measure of corners; 0 = straightest (rectangular); 1 = roundest (circle/oval).
*
* Only for rect
*
- * @var int|float
+ * @var float|int
*/
private $roundness;
/**
- * Frame
+ * Frame.
*
* @var \PhpOffice\PhpWord\Style\Frame
*/
private $frame;
/**
- * Fill
+ * Fill.
*
* @var \PhpOffice\PhpWord\Style\Fill
*/
private $fill;
/**
- * Outline
+ * Outline.
*
* @var \PhpOffice\PhpWord\Style\Outline
*/
private $outline;
/**
- * Shadow
+ * Shadow.
*
* @var \PhpOffice\PhpWord\Style\Shadow
*/
private $shadow;
/**
- * 3D extrusion
+ * 3D extrusion.
*
* @var \PhpOffice\PhpWord\Style\Extrusion
*/
private $extrusion;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param array $style
*/
- public function __construct($style = array())
+ public function __construct($style = [])
{
$this->setStyleByArray($style);
}
/**
- * Get points
+ * Get points.
*
* @return string
*/
@@ -103,9 +104,10 @@ public function getPoints()
}
/**
- * Set points
+ * Set points.
*
* @param string $value
+ *
* @return self
*/
public function setPoints($value = null)
@@ -116,9 +118,9 @@ public function setPoints($value = null)
}
/**
- * Get roundness
+ * Get roundness.
*
- * @return int|float
+ * @return float|int
*/
public function getRoundness()
{
@@ -126,9 +128,10 @@ public function getRoundness()
}
/**
- * Set roundness
+ * Set roundness.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setRoundness($value = null)
@@ -139,7 +142,7 @@ public function setRoundness($value = null)
}
/**
- * Get frame
+ * Get frame.
*
* @return \PhpOffice\PhpWord\Style\Frame
*/
@@ -149,9 +152,10 @@ public function getFrame()
}
/**
- * Set frame
+ * Set frame.
*
* @param mixed $value
+ *
* @return self
*/
public function setFrame($value = null)
@@ -162,7 +166,7 @@ public function setFrame($value = null)
}
/**
- * Get fill
+ * Get fill.
*
* @return \PhpOffice\PhpWord\Style\Fill
*/
@@ -172,9 +176,10 @@ public function getFill()
}
/**
- * Set fill
+ * Set fill.
*
* @param mixed $value
+ *
* @return self
*/
public function setFill($value = null)
@@ -185,7 +190,7 @@ public function setFill($value = null)
}
/**
- * Get outline
+ * Get outline.
*
* @return \PhpOffice\PhpWord\Style\Outline
*/
@@ -195,9 +200,10 @@ public function getOutline()
}
/**
- * Set outline
+ * Set outline.
*
* @param mixed $value
+ *
* @return self
*/
public function setOutline($value = null)
@@ -208,7 +214,7 @@ public function setOutline($value = null)
}
/**
- * Get shadow
+ * Get shadow.
*
* @return \PhpOffice\PhpWord\Style\Shadow
*/
@@ -218,9 +224,10 @@ public function getShadow()
}
/**
- * Set shadow
+ * Set shadow.
*
* @param mixed $value
+ *
* @return self
*/
public function setShadow($value = null)
@@ -231,7 +238,7 @@ public function setShadow($value = null)
}
/**
- * Get 3D extrusion
+ * Get 3D extrusion.
*
* @return \PhpOffice\PhpWord\Style\Extrusion
*/
@@ -241,9 +248,10 @@ public function getExtrusion()
}
/**
- * Set 3D extrusion
+ * Set 3D extrusion.
*
* @param mixed $value
+ *
* @return self
*/
public function setExtrusion($value = null)
diff --git a/src/PhpWord/Style/Spacing.php b/src/PhpWord/Style/Spacing.php
index 9bfb22822b..165cfd0262 100644
--- a/src/PhpWord/Style/Spacing.php
+++ b/src/PhpWord/Style/Spacing.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,7 +20,7 @@
use PhpOffice\PhpWord\SimpleType\LineSpacingRule;
/**
- * Spacing between lines and above/below paragraph style
+ * Spacing between lines and above/below paragraph style.
*
* @see http://www.datypic.com/sc/ooxml/t-w_CT_Spacing.html
* @since 0.10.0
@@ -28,47 +28,47 @@
class Spacing extends AbstractStyle
{
/**
- * Spacing above paragraph (twip)
+ * Spacing above paragraph (twip).
*
- * @var int|float
+ * @var float|int
*/
private $before;
/**
- * Spacing below paragraph (twip)
+ * Spacing below paragraph (twip).
*
- * @var int|float
+ * @var float|int
*/
private $after;
/**
- * Spacing between lines in paragraph (twip)
+ * Spacing between lines in paragraph (twip).
*
- * @var int|float
+ * @var float|int
*/
private $line;
/**
- * Type of spacing between lines
+ * Type of spacing between lines.
*
* @var string
*/
private $lineRule = LineSpacingRule::AUTO;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param array $style
*/
- public function __construct($style = array())
+ public function __construct($style = [])
{
$this->setStyleByArray($style);
}
/**
- * Get before
+ * Get before.
*
- * @return int|float
+ * @return float|int
*/
public function getBefore()
{
@@ -76,9 +76,10 @@ public function getBefore()
}
/**
- * Set before
+ * Set before.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setBefore($value = null)
@@ -89,9 +90,9 @@ public function setBefore($value = null)
}
/**
- * Get after
+ * Get after.
*
- * @return int|float
+ * @return float|int
*/
public function getAfter()
{
@@ -99,9 +100,10 @@ public function getAfter()
}
/**
- * Set after
+ * Set after.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setAfter($value = null)
@@ -112,9 +114,9 @@ public function setAfter($value = null)
}
/**
- * Get line
+ * Get line.
*
- * @return int|float
+ * @return float|int
*/
public function getLine()
{
@@ -122,9 +124,10 @@ public function getLine()
}
/**
- * Set distance
+ * Set distance.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setLine($value = null)
@@ -135,7 +138,7 @@ public function setLine($value = null)
}
/**
- * Get line rule
+ * Get line rule.
*
* @return string
*/
@@ -145,9 +148,10 @@ public function getLineRule()
}
/**
- * Set line rule
+ * Set line rule.
*
* @param string $value
+ *
* @return self
*/
public function setLineRule($value = null)
@@ -159,10 +163,12 @@ public function setLineRule($value = null)
}
/**
- * Get line rule
+ * Get line rule.
*
* @return string
+ *
* @deprecated Use getLineRule() instead
+ *
* @codeCoverageIgnore
*/
public function getRule()
@@ -171,11 +177,14 @@ public function getRule()
}
/**
- * Set line rule
+ * Set line rule.
*
* @param string $value
+ *
* @return self
+ *
* @deprecated Use setLineRule() instead
+ *
* @codeCoverageIgnore
*/
public function setRule($value = null)
diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php
index 2efd54a4a4..d1d851bdc4 100644
--- a/src/PhpWord/Style/TOC.php
+++ b/src/PhpWord/Style/TOC.php
@@ -11,19 +11,19 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * TOC style
+ * TOC style.
*/
class TOC extends Tab
{
/**
- * Tab leader types for backward compatibility
+ * Tab leader types for backward compatibility.
*
* @deprecated 0.11.0
*
@@ -35,14 +35,14 @@ class TOC extends Tab
const TABLEADER_NONE = self::TAB_LEADER_NONE;
/**
- * Indent
+ * Indent.
*
- * @var int|float (twip)
+ * @var float|int (twip)
*/
private $indent = 200;
/**
- * Create a new TOC Style
+ * Create a new TOC Style.
*/
public function __construct()
{
@@ -50,9 +50,9 @@ public function __construct()
}
/**
- * Get Tab Position
+ * Get Tab Position.
*
- * @return int|float
+ * @return float|int
*/
public function getTabPos()
{
@@ -60,9 +60,10 @@ public function getTabPos()
}
/**
- * Set Tab Position
+ * Set Tab Position.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setTabPos($value)
@@ -71,7 +72,7 @@ public function setTabPos($value)
}
/**
- * Get Tab Leader
+ * Get Tab Leader.
*
* @return string
*/
@@ -81,9 +82,10 @@ public function getTabLeader()
}
/**
- * Set Tab Leader
+ * Set Tab Leader.
*
* @param string $value
+ *
* @return self
*/
public function setTabLeader($value = self::TAB_LEADER_DOT)
@@ -92,9 +94,9 @@ public function setTabLeader($value = self::TAB_LEADER_DOT)
}
/**
- * Get Indent
+ * Get Indent.
*
- * @return int|float
+ * @return float|int
*/
public function getIndent()
{
@@ -102,9 +104,10 @@ public function getIndent()
}
/**
- * Set Indent
+ * Set Indent.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setIndent($value)
diff --git a/src/PhpWord/Style/Tab.php b/src/PhpWord/Style/Tab.php
index d3cf5bd7f4..02158fd498 100644
--- a/src/PhpWord/Style/Tab.php
+++ b/src/PhpWord/Style/Tab.php
@@ -11,19 +11,19 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * Tab style
+ * Tab style.
*/
class Tab extends AbstractStyle
{
/**
- * Tab stop types
+ * Tab stop types.
*
* @const string
*/
@@ -36,7 +36,7 @@ class Tab extends AbstractStyle
const TAB_STOP_NUM = 'num';
/**
- * Tab leader types
+ * Tab leader types.
*
* @const string
*/
@@ -48,23 +48,23 @@ class Tab extends AbstractStyle
const TAB_LEADER_MIDDLEDOT = 'middleDot';
/**
- * Tab stop type
+ * Tab stop type.
*
* @var string
*/
private $type = self::TAB_STOP_CLEAR;
/**
- * Tab leader character
+ * Tab leader character.
*
* @var string
*/
private $leader = self::TAB_LEADER_NONE;
/**
- * Tab stop position (twip)
+ * Tab stop position (twip).
*
- * @var int|float
+ * @var float|int
*/
private $position = 0;
@@ -79,14 +79,14 @@ class Tab extends AbstractStyle
*/
public function __construct($type = null, $position = 0, $leader = null)
{
- $stopTypes = array(
+ $stopTypes = [
self::TAB_STOP_CLEAR, self::TAB_STOP_LEFT, self::TAB_STOP_CENTER,
self::TAB_STOP_RIGHT, self::TAB_STOP_DECIMAL, self::TAB_STOP_BAR, self::TAB_STOP_NUM,
- );
- $leaderTypes = array(
+ ];
+ $leaderTypes = [
self::TAB_LEADER_NONE, self::TAB_LEADER_DOT, self::TAB_LEADER_HYPHEN,
self::TAB_LEADER_UNDERSCORE, self::TAB_LEADER_HEAVY, self::TAB_LEADER_MIDDLEDOT,
- );
+ ];
$this->type = $this->setEnumVal($type, $stopTypes, $this->type);
$this->position = $this->setNumericVal($position, $this->position);
@@ -94,7 +94,7 @@ public function __construct($type = null, $position = 0, $leader = null)
}
/**
- * Get stop type
+ * Get stop type.
*
* @return string
*/
@@ -104,25 +104,26 @@ public function getType()
}
/**
- * Set stop type
+ * Set stop type.
*
* @param string $value
+ *
* @return self
*/
public function setType($value)
{
- $enum = array(
+ $enum = [
self::TAB_STOP_CLEAR, self::TAB_STOP_LEFT, self::TAB_STOP_CENTER,
self::TAB_STOP_RIGHT, self::TAB_STOP_DECIMAL, self::TAB_STOP_BAR,
self::TAB_STOP_NUM,
- );
+ ];
$this->type = $this->setEnumVal($value, $enum, $this->type);
return $this;
}
/**
- * Get leader
+ * Get leader.
*
* @return string
*/
@@ -132,26 +133,27 @@ public function getLeader()
}
/**
- * Set leader
+ * Set leader.
*
* @param string $value
+ *
* @return self
*/
public function setLeader($value)
{
- $enum = array(
+ $enum = [
self::TAB_LEADER_NONE, self::TAB_LEADER_DOT, self::TAB_LEADER_HYPHEN,
self::TAB_LEADER_UNDERSCORE, self::TAB_LEADER_HEAVY, self::TAB_LEADER_MIDDLEDOT,
- );
+ ];
$this->leader = $this->setEnumVal($value, $enum, $this->leader);
return $this;
}
/**
- * Get position
+ * Get position.
*
- * @return int|float
+ * @return float|int
*/
public function getPosition()
{
@@ -159,9 +161,10 @@ public function getPosition()
}
/**
- * Set position
+ * Set position.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setPosition($value)
diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php
index f777ac671f..c2d6406d37 100644
--- a/src/PhpWord/Style/Table.php
+++ b/src/PhpWord/Style/Table.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -39,13 +39,13 @@ class Table extends Border
//values for http://www.datypic.com/sc/ooxml/t-w_ST_TblLayoutType.html
/**
- * AutoFit Table Layout
+ * AutoFit Table Layout.
*
* @var string
*/
const LAYOUT_AUTO = 'autofit';
/**
- * Fixed Width Table Layout
+ * Fixed Width Table Layout.
*
* @var string
*/
@@ -59,70 +59,70 @@ class Table extends Border
private $isFirstRow = false;
/**
- * Style for first row
+ * Style for first row.
*
* @var \PhpOffice\PhpWord\Style\Table
*/
private $firstRowStyle;
/**
- * Cell margin top
+ * Cell margin top.
*
* @var int
*/
private $cellMarginTop;
/**
- * Cell margin left
+ * Cell margin left.
*
* @var int
*/
private $cellMarginLeft;
/**
- * Cell margin right
+ * Cell margin right.
*
* @var int
*/
private $cellMarginRight;
/**
- * Cell margin bottom
+ * Cell margin bottom.
*
* @var int
*/
private $cellMarginBottom;
/**
- * Border size inside horizontal
+ * Border size inside horizontal.
*
* @var int
*/
private $borderInsideHSize;
/**
- * Border color inside horizontal
+ * Border color inside horizontal.
*
* @var string
*/
private $borderInsideHColor;
/**
- * Border size inside vertical
+ * Border size inside vertical.
*
* @var int
*/
private $borderInsideVSize;
/**
- * Border color inside vertical
+ * Border color inside vertical.
*
* @var string
*/
private $borderInsideVColor;
/**
- * Shading
+ * Shading.
*
* @var \PhpOffice\PhpWord\Style\Shading
*/
@@ -134,7 +134,7 @@ class Table extends Border
private $alignment = '';
/**
- * @var int|float Width value
+ * @var float|int Width value
*/
private $width = 0;
@@ -144,9 +144,9 @@ class Table extends Border
private $unit = TblWidth::AUTO;
/**
- * @var int|float cell spacing value
+ * @var float|int cell spacing value
*/
- protected $cellSpacing = null;
+ protected $cellSpacing;
/**
* @var string Table Layout
@@ -154,32 +154,33 @@ class Table extends Border
private $layout = self::LAYOUT_AUTO;
/**
- * Position
+ * Position.
*
* @var \PhpOffice\PhpWord\Style\TablePosition
*/
private $position;
- /** @var TblWidthComplexType|null */
+ /** @var null|TblWidthComplexType */
private $indent;
/**
- * The width of each column, computed based on the max cell width of each column
+ * The width of each column, computed based on the max cell width of each column.
*
* @var int[]
*/
private $columnWidths;
/**
- * Visually Right to Left Table
+ * Visually Right to Left Table.
*
* @see http://www.datypic.com/sc/ooxml/e-w_bidiVisual-1.html
+ *
* @var bool
*/
private $bidiVisual = false;
/**
- * Create new table style
+ * Create new table style.
*
* @param mixed $tableStyle
* @param mixed $firstRowStyle
@@ -202,7 +203,7 @@ public function __construct($tableStyle = null, $firstRowStyle = null)
/**
* @param float|int $cellSpacing
*/
- public function setCellSpacing($cellSpacing = null)
+ public function setCellSpacing($cellSpacing = null): void
{
$this->cellSpacing = $cellSpacing;
}
@@ -216,7 +217,7 @@ public function getCellSpacing()
}
/**
- * Set first row
+ * Set first row.
*
* @return \PhpOffice\PhpWord\Style\Table
*/
@@ -226,7 +227,7 @@ public function getFirstRow()
}
/**
- * Get background
+ * Get background.
*
* @return string
*/
@@ -240,39 +241,41 @@ public function getBgColor()
}
/**
- * Set background
+ * Set background.
*
* @param string $value
+ *
* @return self
*/
public function setBgColor($value = null)
{
- $this->setShading(array('fill' => $value));
+ $this->setShading(['fill' => $value]);
return $this;
}
/**
- * Get TLRBHV Border Size
+ * Get TLRBHV Border Size.
*
* @return int[]
*/
public function getBorderSize()
{
- return array(
+ return [
$this->getBorderTopSize(),
$this->getBorderLeftSize(),
$this->getBorderRightSize(),
$this->getBorderBottomSize(),
$this->getBorderInsideHSize(),
$this->getBorderInsideVSize(),
- );
+ ];
}
/**
- * Set TLRBHV Border Size
+ * Set TLRBHV Border Size.
*
* @param int $value Border size in eighths of a point (1/8 point)
+ *
* @return self
*/
public function setBorderSize($value = null)
@@ -288,26 +291,27 @@ public function setBorderSize($value = null)
}
/**
- * Get TLRBHV Border Color
+ * Get TLRBHV Border Color.
*
* @return string[]
*/
public function getBorderColor()
{
- return array(
+ return [
$this->getBorderTopColor(),
$this->getBorderLeftColor(),
$this->getBorderRightColor(),
$this->getBorderBottomColor(),
$this->getBorderInsideHColor(),
$this->getBorderInsideVColor(),
- );
+ ];
}
/**
- * Set TLRBHV Border Color
+ * Set TLRBHV Border Color.
*
* @param string $value
+ *
* @return self
*/
public function setBorderColor($value = null)
@@ -323,7 +327,7 @@ public function setBorderColor($value = null)
}
/**
- * Get border size inside horizontal
+ * Get border size inside horizontal.
*
* @return int
*/
@@ -333,9 +337,10 @@ public function getBorderInsideHSize()
}
/**
- * Set border size inside horizontal
+ * Set border size inside horizontal.
*
* @param int $value
+ *
* @return self
*/
public function setBorderInsideHSize($value = null)
@@ -344,7 +349,7 @@ public function setBorderInsideHSize($value = null)
}
/**
- * Get border color inside horizontal
+ * Get border color inside horizontal.
*
* @return string
*/
@@ -354,9 +359,10 @@ public function getBorderInsideHColor()
}
/**
- * Set border color inside horizontal
+ * Set border color inside horizontal.
*
* @param string $value
+ *
* @return self
*/
public function setBorderInsideHColor($value = null)
@@ -365,7 +371,7 @@ public function setBorderInsideHColor($value = null)
}
/**
- * Get border size inside vertical
+ * Get border size inside vertical.
*
* @return int
*/
@@ -375,9 +381,10 @@ public function getBorderInsideVSize()
}
/**
- * Set border size inside vertical
+ * Set border size inside vertical.
*
* @param int $value
+ *
* @return self
*/
public function setBorderInsideVSize($value = null)
@@ -386,7 +393,7 @@ public function setBorderInsideVSize($value = null)
}
/**
- * Get border color inside vertical
+ * Get border color inside vertical.
*
* @return string
*/
@@ -396,9 +403,10 @@ public function getBorderInsideVColor()
}
/**
- * Set border color inside vertical
+ * Set border color inside vertical.
*
* @param string $value
+ *
* @return self
*/
public function setBorderInsideVColor($value = null)
@@ -407,7 +415,7 @@ public function setBorderInsideVColor($value = null)
}
/**
- * Get cell margin top
+ * Get cell margin top.
*
* @return int
*/
@@ -417,9 +425,10 @@ public function getCellMarginTop()
}
/**
- * Set cell margin top
+ * Set cell margin top.
*
* @param int $value
+ *
* @return self
*/
public function setCellMarginTop($value = null)
@@ -428,7 +437,7 @@ public function setCellMarginTop($value = null)
}
/**
- * Get cell margin left
+ * Get cell margin left.
*
* @return int
*/
@@ -438,9 +447,10 @@ public function getCellMarginLeft()
}
/**
- * Set cell margin left
+ * Set cell margin left.
*
* @param int $value
+ *
* @return self
*/
public function setCellMarginLeft($value = null)
@@ -449,7 +459,7 @@ public function setCellMarginLeft($value = null)
}
/**
- * Get cell margin right
+ * Get cell margin right.
*
* @return int
*/
@@ -459,9 +469,10 @@ public function getCellMarginRight()
}
/**
- * Set cell margin right
+ * Set cell margin right.
*
* @param int $value
+ *
* @return self
*/
public function setCellMarginRight($value = null)
@@ -470,7 +481,7 @@ public function setCellMarginRight($value = null)
}
/**
- * Get cell margin bottom
+ * Get cell margin bottom.
*
* @return int
*/
@@ -480,9 +491,10 @@ public function getCellMarginBottom()
}
/**
- * Set cell margin bottom
+ * Set cell margin bottom.
*
* @param int $value
+ *
* @return self
*/
public function setCellMarginBottom($value = null)
@@ -491,24 +503,25 @@ public function setCellMarginBottom($value = null)
}
/**
- * Get cell margin
+ * Get cell margin.
*
* @return int[]
*/
public function getCellMargin()
{
- return array(
+ return [
$this->cellMarginTop,
$this->cellMarginLeft,
$this->cellMarginRight,
$this->cellMarginBottom,
- );
+ ];
}
/**
- * Set TLRB cell margin
+ * Set TLRB cell margin.
*
* @param int $value Margin in twips
+ *
* @return self
*/
public function setCellMargin($value = null)
@@ -522,7 +535,7 @@ public function setCellMargin($value = null)
}
/**
- * Check if any of the margin is not null
+ * Check if any of the margin is not null.
*
* @return bool
*/
@@ -534,7 +547,7 @@ public function hasMargin()
}
/**
- * Get shading
+ * Get shading.
*
* @return \PhpOffice\PhpWord\Style\Shading
*/
@@ -544,9 +557,10 @@ public function getShading()
}
/**
- * Set shading
+ * Set shading.
*
* @param mixed $value
+ *
* @return self
*/
public function setShading($value = null)
@@ -609,9 +623,9 @@ public function setAlign($value = null)
}
/**
- * Get width
+ * Get width.
*
- * @return int|float
+ * @return float|int
*/
public function getWidth()
{
@@ -619,9 +633,10 @@ public function getWidth()
}
/**
- * Set width
+ * Set width.
+ *
+ * @param float|int $value
*
- * @param int|float $value
* @return self
*/
public function setWidth($value = null)
@@ -632,7 +647,7 @@ public function setWidth($value = null)
}
/**
- * Get width unit
+ * Get width unit.
*
* @return string
*/
@@ -642,9 +657,10 @@ public function getUnit()
}
/**
- * Set width unit
+ * Set width unit.
*
* @param string $value
+ *
* @return self
*/
public function setUnit($value = null)
@@ -656,7 +672,7 @@ public function setUnit($value = null)
}
/**
- * Get layout
+ * Get layout.
*
* @return string
*/
@@ -666,27 +682,29 @@ public function getLayout()
}
/**
- * Set layout
+ * Set layout.
*
* @param string $value
+ *
* @return self
*/
public function setLayout($value = null)
{
- $enum = array(self::LAYOUT_AUTO, self::LAYOUT_FIXED);
+ $enum = [self::LAYOUT_AUTO, self::LAYOUT_FIXED];
$this->layout = $this->setEnumVal($value, $enum, $this->layout);
return $this;
}
/**
- * Get table style only property by checking if it's a firstRow
+ * Get table style only property by checking if it's a firstRow.
*
* This is necessary since firstRow style is cloned from table style but
* without certain properties activated, e.g. margins
*
* @param string $property
- * @return int|string|null
+ *
+ * @return null|int|string
*/
private function getTableOnlyProperty($property)
{
@@ -698,7 +716,7 @@ private function getTableOnlyProperty($property)
}
/**
- * Set table style only property by checking if it's a firstRow
+ * Set table style only property by checking if it's a firstRow.
*
* This is necessary since firstRow style is cloned from table style but
* without certain properties activated, e.g. margins
@@ -706,6 +724,7 @@ private function getTableOnlyProperty($property)
* @param string $property
* @param int|string $value
* @param bool $isNumeric
+ *
* @return self
*/
private function setTableOnlyProperty($property, $value, $isNumeric = true)
@@ -722,7 +741,7 @@ private function setTableOnlyProperty($property, $value, $isNumeric = true)
}
/**
- * Get position
+ * Get position.
*
* @return \PhpOffice\PhpWord\Style\TablePosition
*/
@@ -732,9 +751,10 @@ public function getPosition()
}
/**
- * Set position
+ * Set position.
*
* @param mixed $value
+ *
* @return self
*/
public function setPosition($value = null)
@@ -753,8 +773,8 @@ public function getIndent()
}
/**
- * @param TblWidthComplexType $indent
* @return self
+ *
* @see http://www.datypic.com/sc/ooxml/e-w_tblInd-1.html
*/
public function setIndent(TblWidthComplexType $indent)
@@ -765,7 +785,7 @@ public function setIndent(TblWidthComplexType $indent)
}
/**
- * Get the columnWidths
+ * Get the columnWidths.
*
* @return null|int[]
*/
@@ -775,17 +795,17 @@ public function getColumnWidths()
}
/**
- * The column widths
+ * The column widths.
*
* @param int[] $value
*/
- public function setColumnWidths(array $value = null)
+ public function setColumnWidths(?array $value = null): void
{
$this->columnWidths = $value;
}
/**
- * Get bidiVisual
+ * Get bidiVisual.
*
* @return bool
*/
@@ -795,10 +815,11 @@ public function isBidiVisual()
}
/**
- * Set bidiVisual
+ * Set bidiVisual.
*
* @param bool $bidi
* Set to true to visually present table as Right to Left
+ *
* @return self
*/
public function setBidiVisual($bidi)
diff --git a/src/PhpWord/Style/TablePosition.php b/src/PhpWord/Style/TablePosition.php
index d4b7083102..a61926b83c 100644
--- a/src/PhpWord/Style/TablePosition.php
+++ b/src/PhpWord/Style/TablePosition.php
@@ -11,23 +11,24 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * TablePosition style
+ * TablePosition style.
*
* @see http://www.datypic.com/sc/ooxml/e-w_tblpPr-1.html
*/
class TablePosition extends AbstractStyle
{
/**
- * Vertical anchor constants
+ * Vertical anchor constants.
*
* @const string
+ *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_VAnchor.html
*/
const VANCHOR_TEXT = 'text'; // Relative to vertical text extents
@@ -35,9 +36,10 @@ class TablePosition extends AbstractStyle
const VANCHOR_PAGE = 'page'; // Relative to page
/**
- * Horizontal anchor constants
+ * Horizontal anchor constants.
*
* @const string
+ *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_HAnchor.html
*/
const HANCHOR_TEXT = 'text'; // Relative to text extents
@@ -45,9 +47,10 @@ class TablePosition extends AbstractStyle
const HANCHOR_PAGE = 'page'; // Relative to page
/**
- * Horizontal alignment constants
+ * Horizontal alignment constants.
*
* @const string
+ *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_XAlign.html
*/
const XALIGN_LEFT = 'left'; // Left aligned horizontally
@@ -57,9 +60,10 @@ class TablePosition extends AbstractStyle
const XALIGN_OUTSIDE = 'outside'; // Outside
/**
- * Vertical alignment constants
+ * Vertical alignment constants.
*
* @const string
+ *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_YAlign.html
*/
const YALIGN_INLINE = 'inline'; // In line with text
@@ -70,91 +74,95 @@ class TablePosition extends AbstractStyle
const YALIGN_OUTSIDE = 'outside'; // Centered vertically
/**
- * Distance from left of table to text
+ * Distance from left of table to text.
*
* @var int
*/
private $leftFromText;
/**
- * Distance from right of table to text
+ * Distance from right of table to text.
*
* @var int
*/
private $rightFromText;
/**
- * Distance from top of table to text
+ * Distance from top of table to text.
*
* @var int
*/
private $topFromText;
/**
- * Distance from bottom of table to text
+ * Distance from bottom of table to text.
*
* @var int
*/
private $bottomFromText;
/**
- * Table vertical anchor
+ * Table vertical anchor.
*
* @var string
+ *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_VAnchor.html
*/
private $vertAnchor;
/**
- * Table horizontal anchor
+ * Table horizontal anchor.
*
* @var string
+ *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_HAnchor.html
*/
private $horzAnchor;
/**
- * Relative horizontal alignment from anchor
+ * Relative horizontal alignment from anchor.
*
* @var string
+ *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_XAlign.html
*/
private $tblpXSpec;
/**
- * Absolute horizontal distance from anchor
+ * Absolute horizontal distance from anchor.
*
* @var int
*/
private $tblpX;
/**
- * Relative vertical alignment from anchor
+ * Relative vertical alignment from anchor.
*
* @var string
+ *
* @see http://www.datypic.com/sc/ooxml/t-w_ST_YAlign.html
*/
private $tblpYSpec;
/**
- * Absolute vertical distance from anchor
+ * Absolute vertical distance from anchor.
*
* @var int
*/
private $tblpY;
/**
- * Create a new instance
+ * Create a new instance.
*
* @param array $style
*/
- public function __construct($style = array())
+ public function __construct($style = [])
{
$this->setStyleByArray($style);
}
/**
- * Get distance from left of table to text
+ * Get distance from left of table to text.
*
* @return int
*/
@@ -164,9 +172,10 @@ public function getLeftFromText()
}
/**
- * Set distance from left of table to text
+ * Set distance from left of table to text.
*
* @param int $value
+ *
* @return self
*/
public function setLeftFromText($value = null)
@@ -177,7 +186,7 @@ public function setLeftFromText($value = null)
}
/**
- * Get distance from right of table to text
+ * Get distance from right of table to text.
*
* @return int
*/
@@ -187,9 +196,10 @@ public function getRightFromText()
}
/**
- * Set distance from right of table to text
+ * Set distance from right of table to text.
*
* @param int $value
+ *
* @return self
*/
public function setRightFromText($value = null)
@@ -200,7 +210,7 @@ public function setRightFromText($value = null)
}
/**
- * Get distance from top of table to text
+ * Get distance from top of table to text.
*
* @return int
*/
@@ -210,9 +220,10 @@ public function getTopFromText()
}
/**
- * Set distance from top of table to text
+ * Set distance from top of table to text.
*
* @param int $value
+ *
* @return self
*/
public function setTopFromText($value = null)
@@ -223,7 +234,7 @@ public function setTopFromText($value = null)
}
/**
- * Get distance from bottom of table to text
+ * Get distance from bottom of table to text.
*
* @return int
*/
@@ -233,9 +244,10 @@ public function getBottomFromText()
}
/**
- * Set distance from bottom of table to text
+ * Set distance from bottom of table to text.
*
* @param int $value
+ *
* @return self
*/
public function setBottomFromText($value = null)
@@ -246,7 +258,7 @@ public function setBottomFromText($value = null)
}
/**
- * Get table vertical anchor
+ * Get table vertical anchor.
*
* @return string
*/
@@ -256,25 +268,26 @@ public function getVertAnchor()
}
/**
- * Set table vertical anchor
+ * Set table vertical anchor.
*
* @param string $value
+ *
* @return self
*/
public function setVertAnchor($value = null)
{
- $enum = array(
- self::VANCHOR_TEXT,
- self::VANCHOR_MARGIN,
- self::VANCHOR_PAGE,
- );
+ $enum = [
+ self::VANCHOR_TEXT,
+ self::VANCHOR_MARGIN,
+ self::VANCHOR_PAGE,
+ ];
$this->vertAnchor = $this->setEnumVal($value, $enum, $this->vertAnchor);
return $this;
}
/**
- * Get table horizontal anchor
+ * Get table horizontal anchor.
*
* @return string
*/
@@ -284,25 +297,26 @@ public function getHorzAnchor()
}
/**
- * Set table horizontal anchor
+ * Set table horizontal anchor.
*
* @param string $value
+ *
* @return self
*/
public function setHorzAnchor($value = null)
{
- $enum = array(
- self::HANCHOR_TEXT,
- self::HANCHOR_MARGIN,
- self::HANCHOR_PAGE,
- );
+ $enum = [
+ self::HANCHOR_TEXT,
+ self::HANCHOR_MARGIN,
+ self::HANCHOR_PAGE,
+ ];
$this->horzAnchor = $this->setEnumVal($value, $enum, $this->horzAnchor);
return $this;
}
/**
- * Get relative horizontal alignment from anchor
+ * Get relative horizontal alignment from anchor.
*
* @return string
*/
@@ -312,27 +326,28 @@ public function getTblpXSpec()
}
/**
- * Set relative horizontal alignment from anchor
+ * Set relative horizontal alignment from anchor.
*
* @param string $value
+ *
* @return self
*/
public function setTblpXSpec($value = null)
{
- $enum = array(
+ $enum = [
self::XALIGN_LEFT,
self::XALIGN_CENTER,
self::XALIGN_RIGHT,
self::XALIGN_INSIDE,
self::XALIGN_OUTSIDE,
- );
+ ];
$this->tblpXSpec = $this->setEnumVal($value, $enum, $this->tblpXSpec);
return $this;
}
/**
- * Get absolute horizontal distance from anchor
+ * Get absolute horizontal distance from anchor.
*
* @return int
*/
@@ -342,9 +357,10 @@ public function getTblpX()
}
/**
- * Set absolute horizontal distance from anchor
+ * Set absolute horizontal distance from anchor.
*
* @param int $value
+ *
* @return self
*/
public function setTblpX($value = null)
@@ -355,7 +371,7 @@ public function setTblpX($value = null)
}
/**
- * Get relative vertical alignment from anchor
+ * Get relative vertical alignment from anchor.
*
* @return string
*/
@@ -365,28 +381,29 @@ public function getTblpYSpec()
}
/**
- * Set relative vertical alignment from anchor
+ * Set relative vertical alignment from anchor.
*
* @param string $value
+ *
* @return self
*/
public function setTblpYSpec($value = null)
{
- $enum = array(
+ $enum = [
self::YALIGN_INLINE,
self::YALIGN_TOP,
self::YALIGN_CENTER,
self::YALIGN_BOTTOM,
self::YALIGN_INSIDE,
self::YALIGN_OUTSIDE,
- );
+ ];
$this->tblpYSpec = $this->setEnumVal($value, $enum, $this->tblpYSpec);
return $this;
}
/**
- * Get absolute vertical distance from anchor
+ * Get absolute vertical distance from anchor.
*
* @return int
*/
@@ -396,9 +413,10 @@ public function getTblpY()
}
/**
- * Set absolute vertical distance from anchor
+ * Set absolute vertical distance from anchor.
*
* @param int $value
+ *
* @return self
*/
public function setTblpY($value = null)
diff --git a/src/PhpWord/Style/TextBox.php b/src/PhpWord/Style/TextBox.php
index e9c0f0c064..e43e6fa231 100644
--- a/src/PhpWord/Style/TextBox.php
+++ b/src/PhpWord/Style/TextBox.php
@@ -11,56 +11,56 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Style;
/**
- * TextBox style
+ * TextBox style.
*
* @since 0.11.0
*/
class TextBox extends Image
{
/**
- * margin top
+ * margin top.
*
* @var int
*/
- private $innerMarginTop = null;
+ private $innerMarginTop;
/**
- * margin left
+ * margin left.
*
* @var int
*/
- private $innerMarginLeft = null;
+ private $innerMarginLeft;
/**
- * margin right
+ * margin right.
*
* @var int
*/
- private $innerMarginRight = null;
+ private $innerMarginRight;
/**
- * Cell margin bottom
+ * Cell margin bottom.
*
* @var int
*/
- private $innerMarginBottom = null;
+ private $innerMarginBottom;
/**
- * border size
+ * border size.
*
* @var int
*/
- private $borderSize = null;
+ private $borderSize;
/**
- * border color
+ * border color.
*
* @var string
*/
@@ -71,13 +71,13 @@ class TextBox extends Image
*
* @param int $value
*/
- public function setInnerMarginTop($value = null)
+ public function setInnerMarginTop($value = null): void
{
$this->innerMarginTop = $value;
}
/**
- * Get margin top
+ * Get margin top.
*
* @return int
*/
@@ -91,13 +91,13 @@ public function getInnerMarginTop()
*
* @param int $value
*/
- public function setInnerMarginLeft($value = null)
+ public function setInnerMarginLeft($value = null): void
{
$this->innerMarginLeft = $value;
}
/**
- * Get margin left
+ * Get margin left.
*
* @return int
*/
@@ -111,13 +111,13 @@ public function getInnerMarginLeft()
*
* @param int $value
*/
- public function setInnerMarginRight($value = null)
+ public function setInnerMarginRight($value = null): void
{
$this->innerMarginRight = $value;
}
/**
- * Get margin right
+ * Get margin right.
*
* @return int
*/
@@ -131,13 +131,13 @@ public function getInnerMarginRight()
*
* @param int $value
*/
- public function setInnerMarginBottom($value = null)
+ public function setInnerMarginBottom($value = null): void
{
$this->innerMarginBottom = $value;
}
/**
- * Get margin bottom
+ * Get margin bottom.
*
* @return int
*/
@@ -151,7 +151,7 @@ public function getInnerMarginBottom()
*
* @param int $value Margin in twips
*/
- public function setInnerMargin($value = null)
+ public function setInnerMargin($value = null): void
{
$this->setInnerMarginTop($value);
$this->setInnerMarginLeft($value);
@@ -160,13 +160,13 @@ public function setInnerMargin($value = null)
}
/**
- * Get cell margin
+ * Get cell margin.
*
* @return int[]
*/
public function getInnerMargin()
{
- return array($this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom);
+ return [$this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom];
}
/**
@@ -179,7 +179,7 @@ public function hasInnerMargins()
$hasInnerMargins = false;
$margins = $this->getInnerMargin();
$numMargins = count($margins);
- for ($i = 0; $i < $numMargins; $i++) {
+ for ($i = 0; $i < $numMargins; ++$i) {
if ($margins[$i] !== null) {
$hasInnerMargins = true;
}
@@ -193,13 +193,13 @@ public function hasInnerMargins()
*
* @param int $value Size in points
*/
- public function setBorderSize($value = null)
+ public function setBorderSize($value = null): void
{
$this->borderSize = $value;
}
/**
- * Get border size
+ * Get border size.
*
* @return int
*/
@@ -213,13 +213,13 @@ public function getBorderSize()
*
* @param string $value
*/
- public function setBorderColor($value = null)
+ public function setBorderColor($value = null): void
{
$this->borderColor = $value;
}
/**
- * Get border color
+ * Get border color.
*
* @return string
*/
diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php
index c42696f08c..e0e09450a8 100644
--- a/src/PhpWord/Template.php
+++ b/src/PhpWord/Template.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index 09f5461995..1cf3242984 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -12,12 +12,13 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord;
+use DOMDocument;
use PhpOffice\PhpWord\Escaper\RegExp;
use PhpOffice\PhpWord\Escaper\Xml;
use PhpOffice\PhpWord\Exception\CopyFileException;
@@ -26,6 +27,7 @@
use PhpOffice\PhpWord\Shared\Text;
use PhpOffice\PhpWord\Shared\XMLWriter;
use PhpOffice\PhpWord\Shared\ZipArchive;
+use XSLTProcessor;
class TemplateProcessor
{
@@ -44,39 +46,39 @@ class TemplateProcessor
protected $tempDocumentFilename;
/**
- * Content of main document part (in XML format) of the temporary document
+ * Content of main document part (in XML format) of the temporary document.
*
* @var string
*/
protected $tempDocumentMainPart;
/**
- * Content of settings part (in XML format) of the temporary document
+ * Content of settings part (in XML format) of the temporary document.
*
* @var string
*/
protected $tempDocumentSettingsPart;
/**
- * Content of headers (in XML format) of the temporary document
+ * Content of headers (in XML format) of the temporary document.
*
* @var string[]
*/
- protected $tempDocumentHeaders = array();
+ protected $tempDocumentHeaders = [];
/**
- * Content of footers (in XML format) of the temporary document
+ * Content of footers (in XML format) of the temporary document.
*
* @var string[]
*/
- protected $tempDocumentFooters = array();
+ protected $tempDocumentFooters = [];
/**
* Document relations (in XML format) of the temporary document.
*
* @var string[]
*/
- protected $tempDocumentRelations = array();
+ protected $tempDocumentRelations = [];
/**
* Document content types (in XML format) of the temporary document.
@@ -86,19 +88,16 @@ class TemplateProcessor
protected $tempDocumentContentTypes = '';
/**
- * new inserted images list
+ * new inserted images list.
*
* @var string[]
*/
- protected $tempDocumentNewImages = array();
+ protected $tempDocumentNewImages = [];
/**
* @since 0.12.0 Throws CreateTemporaryFileException and CopyFileException instead of Exception
*
* @param string $documentTemplate The fully qualified template filename
- *
- * @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
- * @throws \PhpOffice\PhpWord\Exception\CopyFileException
*/
public function __construct($documentTemplate)
{
@@ -119,12 +118,12 @@ public function __construct($documentTemplate)
$index = 1;
while (false !== $this->zipClass->locateName($this->getHeaderName($index))) {
$this->tempDocumentHeaders[$index] = $this->readPartWithRels($this->getHeaderName($index));
- $index++;
+ ++$index;
}
$index = 1;
while (false !== $this->zipClass->locateName($this->getFooterName($index))) {
$this->tempDocumentFooters[$index] = $this->readPartWithRels($this->getFooterName($index));
- $index++;
+ ++$index;
}
$this->tempDocumentMainPart = $this->readPartWithRels($this->getMainPartName());
@@ -133,7 +132,7 @@ public function __construct($documentTemplate)
}
/**
- * Expose zip class
+ * Expose zip class.
*
* To replace an image: $templateProcessor->zip()->AddFromString("word/media/image1.jpg", file_get_contents($file));
* To read a file: $templateProcessor->zip()->getFromName("word/media/image1.jpg");
@@ -163,9 +162,7 @@ protected function readPartWithRels($fileName)
/**
* @param string $xml
- * @param \XSLTProcessor $xsltProcessor
- *
- * @throws \PhpOffice\PhpWord\Exception\Exception
+ * @param XSLTProcessor $xsltProcessor
*
* @return string
*/
@@ -174,7 +171,7 @@ protected function transformSingleXml($xml, $xsltProcessor)
if (\PHP_VERSION_ID < 80000) {
$orignalLibEntityLoader = libxml_disable_entity_loader(true);
}
- $domDocument = new \DOMDocument();
+ $domDocument = new DOMDocument();
if (false === $domDocument->loadXML($xml)) {
throw new Exception('Could not load the given XML document.');
}
@@ -192,7 +189,7 @@ protected function transformSingleXml($xml, $xsltProcessor)
/**
* @param mixed $xml
- * @param \XSLTProcessor $xsltProcessor
+ * @param XSLTProcessor $xsltProcessor
*
* @return mixed
*/
@@ -216,15 +213,13 @@ protected function transformXml($xml, $xsltProcessor)
* Note: since the method doesn't make any guess on logic of the provided XSL style sheet,
* make sure that output is correctly escaped. Otherwise you may get broken document.
*
- * @param \DOMDocument $xslDomDocument
+ * @param DOMDocument $xslDomDocument
* @param array $xslOptions
* @param string $xslOptionsUri
- *
- * @throws \PhpOffice\PhpWord\Exception\Exception
*/
- public function applyXslStyleSheet($xslDomDocument, $xslOptions = array(), $xslOptionsUri = '')
+ public function applyXslStyleSheet($xslDomDocument, $xslOptions = [], $xslOptionsUri = ''): void
{
- $xsltProcessor = new \XSLTProcessor();
+ $xsltProcessor = new XSLTProcessor();
$xsltProcessor->importStylesheet($xslDomDocument);
if (false === $xsltProcessor->setParameter($xslOptionsUri, $xslOptions)) {
@@ -257,18 +252,18 @@ protected static function ensureMacroCompleted($macro)
*/
protected static function ensureUtf8Encoded($subject)
{
- if (!Text::isUTF8($subject) && !is_null($subject)) {
+ if (!Text::isUTF8($subject) && null !== $subject) {
$subject = utf8_encode($subject);
}
- return (!is_null($subject)) ? $subject : '';
+ return (null !== $subject) ? $subject : '';
}
/**
* @param string $search
* @param \PhpOffice\PhpWord\Element\AbstractElement $complexType
*/
- public function setComplexValue($search, \PhpOffice\PhpWord\Element\AbstractElement $complexType)
+ public function setComplexValue($search, Element\AbstractElement $complexType): void
{
$elementName = substr(get_class($complexType), strrpos(get_class($complexType), '\\') + 1);
$objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $elementName;
@@ -296,7 +291,7 @@ public function setComplexValue($search, \PhpOffice\PhpWord\Element\AbstractElem
* @param string $search
* @param \PhpOffice\PhpWord\Element\AbstractElement $complexType
*/
- public function setComplexBlock($search, \PhpOffice\PhpWord\Element\AbstractElement $complexType)
+ public function setComplexBlock($search, Element\AbstractElement $complexType): void
{
$elementName = substr(get_class($complexType), strrpos(get_class($complexType), '\\') + 1);
$objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $elementName;
@@ -314,7 +309,7 @@ public function setComplexBlock($search, \PhpOffice\PhpWord\Element\AbstractElem
* @param mixed $replace
* @param int $limit
*/
- public function setValue($search, $replace, $limit = self::MAXIMUM_REPLACEMENTS_DEFAULT)
+ public function setValue($search, $replace, $limit = self::MAXIMUM_REPLACEMENTS_DEFAULT): void
{
if (is_array($search)) {
foreach ($search as &$item) {
@@ -346,10 +341,8 @@ public function setValue($search, $replace, $limit = self::MAXIMUM_REPLACEMENTS_
/**
* Set values from a one-dimensional array of "variable => value"-pairs.
- *
- * @param array $values
*/
- public function setValues(array $values)
+ public function setValues(array $values): void
{
foreach ($values as $macro => $replace) {
$this->setValue($macro, $replace);
@@ -358,9 +351,8 @@ public function setValues(array $values)
/**
* @param string $search
- * @param \PhpOffice\PhpWord\Element\AbstractElement $complexType
*/
- public function setChart($search, \PhpOffice\PhpWord\Element\AbstractElement $chart)
+ public function setChart($search, Element\AbstractElement $chart): void
{
$elementName = substr(get_class($chart), strrpos(get_class($chart), '\\') + 1);
$objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $elementName;
@@ -401,29 +393,32 @@ private function getImageArgs($varNameWithArgs)
$varElements = explode(':', $varNameWithArgs);
array_shift($varElements); // first element is name of variable => remove it
- $varInlineArgs = array();
+ $varInlineArgs = [];
// size format documentation: https://msdn.microsoft.com/en-us/library/documentformat.openxml.vml.shape%28v=office.14%29.aspx?f=255&MSPPError=-2147217396
foreach ($varElements as $argIdx => $varArg) {
if (strpos($varArg, '=')) { // arg=value
- list($argName, $argValue) = explode('=', $varArg, 2);
+ [$argName, $argValue] = explode('=', $varArg, 2);
$argName = strtolower($argName);
if ($argName == 'size') {
- list($varInlineArgs['width'], $varInlineArgs['height']) = explode('x', $argValue, 2);
+ [$varInlineArgs['width'], $varInlineArgs['height']] = explode('x', $argValue, 2);
} else {
$varInlineArgs[strtolower($argName)] = $argValue;
}
} elseif (preg_match('/^([0-9]*[a-z%]{0,2}|auto)x([0-9]*[a-z%]{0,2}|auto)$/i', $varArg)) { // 60x40
- list($varInlineArgs['width'], $varInlineArgs['height']) = explode('x', $varArg, 2);
+ [$varInlineArgs['width'], $varInlineArgs['height']] = explode('x', $varArg, 2);
} else { // :60:40:f
switch ($argIdx) {
case 0:
$varInlineArgs['width'] = $varArg;
+
break;
case 1:
$varInlineArgs['height'] = $varArg;
+
break;
case 2:
$varInlineArgs['ratio'] = $varArg;
+
break;
}
}
@@ -435,13 +430,13 @@ private function getImageArgs($varNameWithArgs)
private function chooseImageDimension($baseValue, $inlineValue, $defaultValue)
{
$value = $baseValue;
- if (is_null($value) && isset($inlineValue)) {
+ if (null === $value && isset($inlineValue)) {
$value = $inlineValue;
}
- if (!preg_match('/^([0-9]*(cm|mm|in|pt|pc|px|%|em|ex|)|auto)$/i', isset($value) ? $value : '')) {
+ if (!preg_match('/^([0-9]*(cm|mm|in|pt|pc|px|%|em|ex|)|auto)$/i', $value ?? '')) {
$value = null;
}
- if (is_null($value)) {
+ if (null === $value) {
$value = $defaultValue;
}
if (is_numeric($value)) {
@@ -451,7 +446,7 @@ private function chooseImageDimension($baseValue, $inlineValue, $defaultValue)
return $value;
}
- private function fixImageWidthHeightRatio(&$width, &$height, $actualWidth, $actualHeight)
+ private function fixImageWidthHeightRatio(&$width, &$height, $actualWidth, $actualHeight): void
{
$imageRatio = $actualWidth / $actualHeight;
@@ -461,20 +456,20 @@ private function fixImageWidthHeightRatio(&$width, &$height, $actualWidth, $actu
} elseif ($width === '') { // defined width is empty
$heightFloat = (float) $height;
$widthFloat = $heightFloat * $imageRatio;
- $matches = array();
- preg_match("/\d([a-z%]+)$/", $height, $matches);
+ $matches = [];
+ preg_match('/\\d([a-z%]+)$/', $height, $matches);
$width = $widthFloat . $matches[1];
} elseif ($height === '') { // defined height is empty
$widthFloat = (float) $width;
$heightFloat = $widthFloat / $imageRatio;
- $matches = array();
- preg_match("/\d([a-z%]+)$/", $width, $matches);
+ $matches = [];
+ preg_match('/\\d([a-z%]+)$/', $width, $matches);
$height = $heightFloat . $matches[1];
} else { // we have defined size, but we need also check it aspect ratio
- $widthMatches = array();
- preg_match("/\d([a-z%]+)$/", $width, $widthMatches);
- $heightMatches = array();
- preg_match("/\d([a-z%]+)$/", $height, $heightMatches);
+ $widthMatches = [];
+ preg_match('/\\d([a-z%]+)$/', $width, $widthMatches);
+ $heightMatches = [];
+ preg_match('/\\d([a-z%]+)$/', $height, $heightMatches);
// try to fix only if dimensions are same
if ($widthMatches[1] == $heightMatches[1]) {
$dimention = $widthMatches[1];
@@ -519,46 +514,46 @@ private function prepareImageAttrs($replaceImage, $varInlineArgs)
$imgPath = $replaceImage;
}
- $width = $this->chooseImageDimension($width, isset($varInlineArgs['width']) ? $varInlineArgs['width'] : null, 115);
- $height = $this->chooseImageDimension($height, isset($varInlineArgs['height']) ? $varInlineArgs['height'] : null, 70);
+ $width = $this->chooseImageDimension($width, $varInlineArgs['width'] ?? null, 115);
+ $height = $this->chooseImageDimension($height, $varInlineArgs['height'] ?? null, 70);
$imageData = @getimagesize($imgPath);
if (!is_array($imageData)) {
throw new Exception(sprintf('Invalid image: %s', $imgPath));
}
- list($actualWidth, $actualHeight, $imageType) = $imageData;
+ [$actualWidth, $actualHeight, $imageType] = $imageData;
// fix aspect ratio (by default)
- if (is_null($ratio) && isset($varInlineArgs['ratio'])) {
+ if (null === $ratio && isset($varInlineArgs['ratio'])) {
$ratio = $varInlineArgs['ratio'];
}
- if (is_null($ratio) || !in_array(strtolower($ratio), array('', '-', 'f', 'false'))) {
+ if (null === $ratio || !in_array(strtolower($ratio), ['', '-', 'f', 'false'])) {
$this->fixImageWidthHeightRatio($width, $height, $actualWidth, $actualHeight);
}
- $imageAttrs = array(
- 'src' => $imgPath,
- 'mime' => image_type_to_mime_type($imageType),
- 'width' => $width,
+ $imageAttrs = [
+ 'src' => $imgPath,
+ 'mime' => image_type_to_mime_type($imageType),
+ 'width' => $width,
'height' => $height,
- );
+ ];
return $imageAttrs;
}
- private function addImageToRelations($partFileName, $rid, $imgPath, $imageMimeType)
+ private function addImageToRelations($partFileName, $rid, $imgPath, $imageMimeType): void
{
// define templates
$typeTpl = '';
$relationTpl = '';
$newRelationsTpl = '' . "\n" . '';
$newRelationsTypeTpl = '';
- $extTransform = array(
+ $extTransform = [
'image/jpeg' => 'jpeg',
- 'image/png' => 'png',
- 'image/bmp' => 'bmp',
- 'image/gif' => 'gif',
- );
+ 'image/png' => 'png',
+ 'image/bmp' => 'bmp',
+ 'image/gif' => 'gif',
+ ];
// get image embed name
if (isset($this->tempDocumentNewImages[$imgPath])) {
@@ -577,11 +572,11 @@ private function addImageToRelations($partFileName, $rid, $imgPath, $imageMimeTy
$this->tempDocumentNewImages[$imgPath] = $imgName;
// setup type for image
- $xmlImageType = str_replace(array('{IMG}', '{EXT}'), array($imgName, $imgExt), $typeTpl);
+ $xmlImageType = str_replace(['{IMG}', '{EXT}'], [$imgName, $imgExt], $typeTpl);
$this->tempDocumentContentTypes = str_replace('', $xmlImageType, $this->tempDocumentContentTypes) . '';
}
- $xmlImageRelation = str_replace(array('{RID}', '{IMG}'), array($rid, $imgName), $relationTpl);
+ $xmlImageRelation = str_replace(['{RID}', '{IMG}'], [$rid, $imgName], $relationTpl);
if (!isset($this->tempDocumentRelations[$partFileName])) {
// create new relations file
@@ -600,29 +595,29 @@ private function addImageToRelations($partFileName, $rid, $imgPath, $imageMimeTy
* @param mixed $replace Path to image, or array("path" => xx, "width" => yy, "height" => zz)
* @param int $limit
*/
- public function setImageValue($search, $replace, $limit = self::MAXIMUM_REPLACEMENTS_DEFAULT)
+ public function setImageValue($search, $replace, $limit = self::MAXIMUM_REPLACEMENTS_DEFAULT): void
{
// prepare $search_replace
if (!is_array($search)) {
- $search = array($search);
+ $search = [$search];
}
- $replacesList = array();
+ $replacesList = [];
if (!is_array($replace) || isset($replace['path'])) {
$replacesList[] = $replace;
} else {
$replacesList = array_values($replace);
}
- $searchReplace = array();
+ $searchReplace = [];
foreach ($search as $searchIdx => $searchString) {
- $searchReplace[$searchString] = isset($replacesList[$searchIdx]) ? $replacesList[$searchIdx] : $replacesList[0];
+ $searchReplace[$searchString] = $replacesList[$searchIdx] ?? $replacesList[0];
}
// collect document parts
- $searchParts = array(
+ $searchParts = [
$this->getMainPartName() => &$this->tempDocumentMainPart,
- );
+ ];
foreach (array_keys($this->tempDocumentHeaders) as $headerIndex) {
$searchParts[$this->getHeaderName($headerIndex)] = &$this->tempDocumentHeaders[$headerIndex];
}
@@ -654,15 +649,15 @@ public function setImageValue($search, $replace, $limit = self::MAXIMUM_REPLACEM
// replace preparations
$this->addImageToRelations($partFileName, $rid, $imgPath, $preparedImageAttrs['mime']);
- $xmlImage = str_replace(array('{RID}', '{WIDTH}', '{HEIGHT}'), array($rid, $preparedImageAttrs['width'], $preparedImageAttrs['height']), $imgTpl);
+ $xmlImage = str_replace(['{RID}', '{WIDTH}', '{HEIGHT}'], [$rid, $preparedImageAttrs['width'], $preparedImageAttrs['height']], $imgTpl);
// replace variable
$varNameWithArgsFixed = static::ensureMacroCompleted($varNameWithArgs);
- $matches = array();
+ $matches = [];
if (preg_match('/(<[^<]+>)([^<]*)(' . preg_quote($varNameWithArgsFixed) . ')([^>]*)(<[^>]+>)/Uu', $partContent, $matches)) {
$wholeTag = $matches[0];
array_shift($matches);
- list($openTag, $prefix, , $postfix, $closeTag) = $matches;
+ [$openTag, $prefix, , $postfix, $closeTag] = $matches;
$replaceXml = $openTag . $prefix . $closeTag . $xmlImage . $openTag . $postfix . $closeTag;
// replace on each iteration, because in one tag we can have 2+ inline variables => before proceed next variable we need to change $partContent
$partContent = $this->setValueForPart($wholeTag, $replaceXml, $partContent, $limit);
@@ -717,10 +712,8 @@ public function getVariables()
*
* @param string $search
* @param int $numberOfClones
- *
- * @throws \PhpOffice\PhpWord\Exception\Exception
*/
- public function cloneRow($search, $numberOfClones)
+ public function cloneRow($search, $numberOfClones): void
{
$search = static::ensureMacroCompleted($search);
@@ -760,7 +753,7 @@ public function cloneRow($search, $numberOfClones)
}
$result = $this->getSlice(0, $rowStart);
- $result .= implode($this->indexClonedVariables($numberOfClones, $xmlRow));
+ $result .= implode('', $this->indexClonedVariables($numberOfClones, $xmlRow));
$result .= $this->getSlice($rowEnd);
$this->tempDocumentMainPart = $result;
@@ -772,7 +765,7 @@ public function cloneRow($search, $numberOfClones)
* @param string $search
* @param array $values
*/
- public function cloneRowAndSetValues($search, $values)
+ public function cloneRowAndSetValues($search, $values): void
{
$this->cloneRow($search, count($values));
@@ -793,12 +786,12 @@ public function cloneRowAndSetValues($search, $values)
* @param bool $indexVariables If true, any variables inside the block will be indexed (postfixed with #1, #2, ...)
* @param array $variableReplacements Array containing replacements for macros found inside the block to clone
*
- * @return string|null
+ * @return null|string
*/
public function cloneBlock($blockname, $clones = 1, $replace = true, $indexVariables = false, $variableReplacements = null)
{
$xmlBlock = null;
- $matches = array();
+ $matches = [];
preg_match(
'/(.*((?s)))(.*)((?s))/is',
$this->tempDocumentMainPart,
@@ -812,8 +805,8 @@ public function cloneBlock($blockname, $clones = 1, $replace = true, $indexVaria
} elseif ($variableReplacements !== null && is_array($variableReplacements)) {
$cloned = $this->replaceClonedVariables($variableReplacements, $xmlBlock);
} else {
- $cloned = array();
- for ($i = 1; $i <= $clones; $i++) {
+ $cloned = [];
+ for ($i = 1; $i <= $clones; ++$i) {
$cloned[] = $xmlBlock;
}
}
@@ -836,9 +829,9 @@ public function cloneBlock($blockname, $clones = 1, $replace = true, $indexVaria
* @param string $blockname
* @param string $replacement
*/
- public function replaceBlock($blockname, $replacement)
+ public function replaceBlock($blockname, $replacement): void
{
- $matches = array();
+ $matches = [];
preg_match(
'/(<\?xml.*)(\${' . $blockname . '}<\/w:.*?p>)(.*)()/is',
$this->tempDocumentMainPart,
@@ -859,20 +852,20 @@ public function replaceBlock($blockname, $replacement)
*
* @param string $blockname
*/
- public function deleteBlock($blockname)
+ public function deleteBlock($blockname): void
{
$this->replaceBlock($blockname, '');
}
/**
- * Automatically Recalculate Fields on Open
+ * Automatically Recalculate Fields on Open.
*
* @param bool $update
*/
- public function setUpdateFields($update = true)
+ public function setUpdateFields($update = true): void
{
$string = $update ? 'true' : 'false';
- $matches = array();
+ $matches = [];
if (preg_match('//', $this->tempDocumentSettingsPart, $matches)) {
$this->tempDocumentSettingsPart = str_replace($matches[0], '', $this->tempDocumentSettingsPart);
} else {
@@ -883,8 +876,6 @@ public function setUpdateFields($update = true)
/**
* Saves the result document.
*
- * @throws \PhpOffice\PhpWord\Exception\Exception
- *
* @return string
*/
public function save()
@@ -914,7 +905,7 @@ public function save()
* @param string $fileName
* @param string $xml
*/
- protected function savePartWithRels($fileName, $xml)
+ protected function savePartWithRels($fileName, $xml): void
{
$this->zipClass->addFromString($fileName, $xml);
if (isset($this->tempDocumentRelations[$fileName])) {
@@ -930,7 +921,7 @@ protected function savePartWithRels($fileName, $xml)
*
* @param string $fileName
*/
- public function saveAs($fileName)
+ public function saveAs($fileName): void
{
$tempFileName = $this->save();
@@ -997,7 +988,7 @@ protected function setValueForPart($search, $replace, $documentPartXML, $limit)
*/
protected function getVariablesForPart($documentPartXML)
{
- $matches = array();
+ $matches = [];
preg_match_all('/\$\{(.*?)}/i', $documentPartXML, $matches);
return $matches[1];
@@ -1026,14 +1017,14 @@ protected function getMainPartName()
$pattern = '~PartName="\/(word\/document.*?\.xml)" ContentType="application\/vnd\.openxmlformats-officedocument\.wordprocessingml\.document\.main\+xml"~';
- $matches = array();
+ $matches = [];
preg_match($pattern, $contentTypes, $matches);
return array_key_exists(1, $matches) ? $matches[1] : 'word/document.xml';
}
/**
- * The name of the file containing the Settings part
+ * The name of the file containing the Settings part.
*
* @return string
*/
@@ -1071,7 +1062,7 @@ protected function getNextRelationsIndex($documentPartName)
if (isset($this->tempDocumentRelations[$documentPartName])) {
$candidate = substr_count($this->tempDocumentRelations[$documentPartName], 'tempDocumentRelations[$documentPartName], 'Id="rId' . $candidate . '"') !== false) {
- $candidate++;
+ ++$candidate;
}
return $candidate;
@@ -1093,8 +1084,6 @@ protected function getDocumentContentTypesName()
*
* @param int $offset
*
- * @throws \PhpOffice\PhpWord\Exception\Exception
- *
* @return int
*/
protected function findRowStart($offset)
@@ -1142,7 +1131,7 @@ protected function getSlice($startPosition, $endPosition = 0)
/**
* Replaces variable names in cloned
- * rows/blocks with indexed names
+ * rows/blocks with indexed names.
*
* @param int $count
* @param string $xmlBlock
@@ -1151,8 +1140,8 @@ protected function getSlice($startPosition, $endPosition = 0)
*/
protected function indexClonedVariables($count, $xmlBlock)
{
- $results = array();
- for ($i = 1; $i <= $count; $i++) {
+ $results = [];
+ for ($i = 1; $i <= $count; ++$i) {
$results[] = preg_replace('/\$\{([^:]*?)(:.*?)?\}/', '\${\1#' . $i . '\2}', $xmlBlock);
}
@@ -1160,7 +1149,7 @@ protected function indexClonedVariables($count, $xmlBlock)
}
/**
- * Raplaces variables with values from array, array keys are the variable names
+ * Raplaces variables with values from array, array keys are the variable names.
*
* @param array $variableReplacements
* @param string $xmlBlock
@@ -1169,7 +1158,7 @@ protected function indexClonedVariables($count, $xmlBlock)
*/
protected function replaceClonedVariables($variableReplacements, $xmlBlock)
{
- $results = array();
+ $results = [];
foreach ($variableReplacements as $replacementArray) {
$localXmlBlock = $xmlBlock;
foreach ($replacementArray as $search => $replacement) {
@@ -1182,11 +1171,12 @@ protected function replaceClonedVariables($variableReplacements, $xmlBlock)
}
/**
- * Replace an XML block surrounding a macro with a new block
+ * Replace an XML block surrounding a macro with a new block.
*
* @param string $macro Name of macro
* @param string $block New block content
* @param string $blockType XML tag type of block
+ *
* @return \PhpOffice\PhpWord\TemplateProcessor Fluent interface
*/
public function replaceXmlBlock($macro, $block, $blockType = 'w:p')
@@ -1201,12 +1191,13 @@ public function replaceXmlBlock($macro, $block, $blockType = 'w:p')
/**
* Find start and end of XML block containing the given macro
- * e.g. ...${macro}...
+ * e.g. ...${macro}....
*
* Note that only the first instance of the macro will be found
*
* @param string $macro Name of macro
* @param string $blockType XML tag for block
+ *
* @return bool|int[] FALSE if not found, otherwise array with start and end
*/
protected function findContainingXmlBlockForMacro($macro, $blockType = 'w:p')
@@ -1225,11 +1216,11 @@ protected function findContainingXmlBlockForMacro($macro, $blockType = 'w:p')
return false;
}
- return array('start' => $start, 'end' => $end);
+ return ['start' => $start, 'end' => $end];
}
/**
- * Find the position of (the start of) a macro
+ * Find the position of (the start of) a macro.
*
* Returns -1 if not found, otherwise position of opening $
*
@@ -1237,6 +1228,7 @@ protected function findContainingXmlBlockForMacro($macro, $blockType = 'w:p')
*
* @param string $search Macro name
* @param int $offset Offset from which to start searching
+ *
* @return int -1 if macro not found
*/
protected function findMacro($search, $offset = 0)
@@ -1248,10 +1240,11 @@ protected function findMacro($search, $offset = 0)
}
/**
- * Find the start position of the nearest XML block start before $offset
+ * Find the start position of the nearest XML block start before $offset.
*
* @param int $offset Search position
* @param string $blockType XML Block tag
+ *
* @return int -1 if block start not found
*/
protected function findXmlBlockStart($offset, $blockType)
@@ -1269,10 +1262,11 @@ protected function findXmlBlockStart($offset, $blockType)
}
/**
- * Find the nearest block end position after $offset
+ * Find the nearest block end position after $offset.
*
* @param int $offset Search position
* @param string $blockType XML Block tag
+ *
* @return int -1 if block end not found
*/
protected function findXmlBlockEnd($offset, $blockType)
@@ -1284,9 +1278,10 @@ protected function findXmlBlockEnd($offset, $blockType)
}
/**
- * Splits a w:r/w:t into a list of w:r where each ${macro} is in a separate w:r
+ * Splits a w:r/w:t into a list of w:r where each ${macro} is in a separate w:r.
*
* @param string $text
+ *
* @return string
*/
protected function splitTextIntoTexts($text)
@@ -1294,7 +1289,7 @@ protected function splitTextIntoTexts($text)
if (!$this->textNeedsSplitting($text)) {
return $text;
}
- $matches = array();
+ $matches = [];
if (preg_match('/()/i', $text, $matches)) {
$extractedStyle = $matches[0];
} else {
@@ -1302,15 +1297,16 @@ protected function splitTextIntoTexts($text)
}
$unformattedText = preg_replace('/>\s+', '><', $text);
- $result = str_replace(array('${', '}'), array('' . $extractedStyle . '${', '}' . $extractedStyle . ''), $unformattedText);
+ $result = str_replace(['${', '}'], ['' . $extractedStyle . '${', '}' . $extractedStyle . ''], $unformattedText);
- return str_replace(array('' . $extractedStyle . '', '', ''), array('', '', ''), $result);
+ return str_replace(['' . $extractedStyle . '', '', ''], ['', '', ''], $result);
}
/**
- * Returns true if string contains a macro that is not in it's own w:r
+ * Returns true if string contains a macro that is not in it's own w:r.
*
* @param string $text
+ *
* @return bool
*/
protected function textNeedsSplitting($text)
diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php
index 2c1ad29460..5bceac8021 100644
--- a/src/PhpWord/Writer/AbstractWriter.php
+++ b/src/PhpWord/Writer/AbstractWriter.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -24,96 +24,97 @@
use PhpOffice\PhpWord\Shared\ZipArchive;
/**
- * Abstract writer class
+ * Abstract writer class.
*
* @since 0.10.0
*/
abstract class AbstractWriter implements WriterInterface
{
/**
- * PHPWord object
+ * PHPWord object.
*
* @var \PhpOffice\PhpWord\PhpWord
*/
- protected $phpWord = null;
+ protected $phpWord;
/**
- * Part name and file name pairs
+ * Part name and file name pairs.
*
* @var array
*/
- protected $parts = array();
+ protected $parts = [];
/**
- * Individual writers
+ * Individual writers.
*
* @var array
*/
- protected $writerParts = array();
+ protected $writerParts = [];
/**
- * Paths to store media files
+ * Paths to store media files.
*
* @var array
*/
- protected $mediaPaths = array('image' => '', 'object' => '');
+ protected $mediaPaths = ['image' => '', 'object' => ''];
/**
- * Use disk caching
+ * Use disk caching.
*
* @var bool
*/
private $useDiskCaching = false;
/**
- * Disk caching directory
+ * Disk caching directory.
*
* @var string
*/
private $diskCachingDirectory = './';
/**
- * Temporary directory
+ * Temporary directory.
*
* @var string
*/
private $tempDir = '';
/**
- * Original file name
+ * Original file name.
*
* @var string
*/
private $originalFilename;
/**
- * Temporary file name
+ * Temporary file name.
*
* @var string
*/
private $tempFilename;
/**
- * Get PhpWord object
+ * Get PhpWord object.
*
- * @throws \PhpOffice\PhpWord\Exception\Exception
* @return \PhpOffice\PhpWord\PhpWord
*/
public function getPhpWord()
{
- if (!is_null($this->phpWord)) {
+ if (null !== $this->phpWord) {
return $this->phpWord;
}
+
throw new Exception('No PhpWord assigned.');
}
/**
- * Set PhpWord object
+ * Set PhpWord object.
*
* @param \PhpOffice\PhpWord\PhpWord
+ *
* @return self
*/
- public function setPhpWord(PhpWord $phpWord = null)
+ public function setPhpWord(?PhpWord $phpWord = null)
{
$this->phpWord = $phpWord;
@@ -121,9 +122,10 @@ public function setPhpWord(PhpWord $phpWord = null)
}
/**
- * Get writer part
+ * Get writer part.
*
* @param string $partName Writer part name
+ *
* @return mixed
*/
public function getWriterPart($partName = '')
@@ -136,7 +138,7 @@ public function getWriterPart($partName = '')
}
/**
- * Get use disk caching status
+ * Get use disk caching status.
*
* @return bool
*/
@@ -146,19 +148,18 @@ public function isUseDiskCaching()
}
/**
- * Set use disk caching status
+ * Set use disk caching status.
*
* @param bool $value
* @param string $directory
*
- * @throws \PhpOffice\PhpWord\Exception\Exception
* @return self
*/
public function setUseDiskCaching($value = false, $directory = null)
{
$this->useDiskCaching = $value;
- if (!is_null($directory)) {
+ if (null !== $directory) {
if (is_dir($directory)) {
$this->diskCachingDirectory = $directory;
} else {
@@ -170,7 +171,7 @@ public function setUseDiskCaching($value = false, $directory = null)
}
/**
- * Get disk caching directory
+ * Get disk caching directory.
*
* @return string
*/
@@ -180,7 +181,7 @@ public function getDiskCachingDirectory()
}
/**
- * Get temporary directory
+ * Get temporary directory.
*
* @return string
*/
@@ -190,9 +191,10 @@ public function getTempDir()
}
/**
- * Set temporary directory
+ * Set temporary directory.
*
* @param string $value
+ *
* @return self
*/
public function setTempDir($value)
@@ -206,11 +208,12 @@ public function setTempDir($value)
}
/**
- * Get temporary file name
+ * Get temporary file name.
*
* If $filename is php://output or php://stdout, make it a temporary file
*
* @param string $filename
+ *
* @return string
*/
protected function getTempFile($filename)
@@ -233,10 +236,8 @@ protected function getTempFile($filename)
/**
* Cleanup temporary file.
- *
- * @throws \PhpOffice\PhpWord\Exception\CopyFileException
*/
- protected function cleanupTempFile()
+ protected function cleanupTempFile(): void
{
if ($this->originalFilename != $this->tempFilename) {
// @codeCoverageIgnoreStart
@@ -254,7 +255,7 @@ protected function cleanupTempFile()
/**
* Clear temporary directory.
*/
- protected function clearTempDir()
+ protected function clearTempDir(): void
{
if (is_dir($this->tempDir)) {
$this->deleteDir($this->tempDir);
@@ -262,12 +263,10 @@ protected function clearTempDir()
}
/**
- * Get ZipArchive object
+ * Get ZipArchive object.
*
* @param string $filename
*
- * @throws \Exception
- *
* @return \PhpOffice\PhpWord\Shared\ZipArchive
*/
protected function getZipArchive($filename)
@@ -293,20 +292,18 @@ protected function getZipArchive($filename)
}
/**
- * Open file for writing
+ * Open file for writing.
*
* @since 0.11.0
*
* @param string $filename
*
- * @throws \Exception
- *
* @return resource
*/
protected function openFile($filename)
{
$filename = $this->getTempFile($filename);
- $fileHandle = fopen($filename, 'w');
+ $fileHandle = fopen($filename, 'wb');
// @codeCoverageIgnoreStart
// Can't find any test case. Uncomment when found.
if ($fileHandle === false) {
@@ -325,7 +322,7 @@ protected function openFile($filename)
* @param resource $fileHandle
* @param string $content
*/
- protected function writeFile($fileHandle, $content)
+ protected function writeFile($fileHandle, $content): void
{
fwrite($fileHandle, $content);
fclose($fileHandle);
@@ -335,10 +332,9 @@ protected function writeFile($fileHandle, $content)
/**
* Add files to package.
*
- * @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
* @param mixed $elements
*/
- protected function addFilesToPackage(ZipArchive $zip, $elements)
+ protected function addFilesToPackage(ZipArchive $zip, $elements): void
{
foreach ($elements as $element) {
$type = $element['type']; // image|object|link
@@ -377,13 +373,13 @@ protected function addFilesToPackage(ZipArchive $zip, $elements)
* @param string $source
* @param string $target
*/
- protected function addFileToPackage($zipPackage, $source, $target)
+ protected function addFileToPackage($zipPackage, $source, $target): void
{
$isArchive = strpos($source, 'zip://') !== false;
$actualSource = null;
if ($isArchive) {
$source = substr($source, 6);
- list($zipFilename, $imageFilename) = explode('#', $source);
+ [$zipFilename, $imageFilename] = explode('#', $source);
$zip = new ZipArchive();
if ($zip->open($zipFilename) !== false) {
@@ -397,7 +393,7 @@ protected function addFileToPackage($zipPackage, $source, $target)
$actualSource = $source;
}
- if (!is_null($actualSource)) {
+ if (null !== $actualSource) {
$zipPackage->addFile($actualSource, $target);
}
}
@@ -407,7 +403,7 @@ protected function addFileToPackage($zipPackage, $source, $target)
*
* @param string $dir
*/
- private function deleteDir($dir)
+ private function deleteDir($dir): void
{
foreach (scandir($dir) as $file) {
if ($file === '.' || $file === '..') {
@@ -423,7 +419,7 @@ private function deleteDir($dir)
}
/**
- * Get use disk caching status
+ * Get use disk caching status.
*
* @deprecated 0.10.0
*
diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php
index 7f55b9d3e6..34d3fb32a6 100644
--- a/src/PhpWord/Writer/HTML.php
+++ b/src/PhpWord/Writer/HTML.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,9 +20,10 @@
use PhpOffice\PhpWord\PhpWord;
/**
- * HTML writer
+ * HTML writer.
*
* Not supported: PreserveText, PageBreak, Object
+ *
* @since 0.10.0
*/
class HTML extends AbstractWriter implements WriterInterface
@@ -35,20 +36,20 @@ class HTML extends AbstractWriter implements WriterInterface
protected $isPdf = false;
/**
- * Footnotes and endnotes collection
+ * Footnotes and endnotes collection.
*
* @var array
*/
- protected $notes = array();
+ protected $notes = [];
/**
- * Create new instance
+ * Create new instance.
*/
- public function __construct(PhpWord $phpWord = null)
+ public function __construct(?PhpWord $phpWord = null)
{
$this->setPhpWord($phpWord);
- $this->parts = array('Head', 'Body');
+ $this->parts = ['Head', 'Body'];
foreach ($this->parts as $partName) {
$partClass = 'PhpOffice\\PhpWord\\Writer\\HTML\\Part\\' . $partName;
if (class_exists($partClass)) {
@@ -64,18 +65,17 @@ public function __construct(PhpWord $phpWord = null)
* Save PhpWord to file.
*
* @param string $filename
- *
- * @throws \PhpOffice\PhpWord\Exception\Exception
*/
- public function save($filename = null)
+ public function save($filename = null): void
{
$this->writeFile($this->openFile($filename), $this->getContent());
}
/**
- * Get content
+ * Get content.
*
* @return string
+ *
* @since 0.11.0
*/
public function getContent()
@@ -93,7 +93,7 @@ public function getContent()
}
/**
- * Get is PDF
+ * Get is PDF.
*
* @return bool
*/
@@ -103,7 +103,7 @@ public function isPdf()
}
/**
- * Get notes
+ * Get notes.
*
* @return array
*/
@@ -118,13 +118,13 @@ public function getNotes()
* @param int $noteId
* @param string $noteMark
*/
- public function addNote($noteId, $noteMark)
+ public function addNote($noteId, $noteMark): void
{
$this->notes[$noteId] = $noteMark;
}
/**
- * Write document
+ * Write document.
*
* @deprecated 0.11.0
*
diff --git a/src/PhpWord/Writer/HTML/Element/AbstractElement.php b/src/PhpWord/Writer/HTML/Element/AbstractElement.php
index 30d1ccaa4c..f5b0e91719 100644
--- a/src/PhpWord/Writer/HTML/Element/AbstractElement.php
+++ b/src/PhpWord/Writer/HTML/Element/AbstractElement.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -22,28 +22,28 @@
use PhpOffice\PhpWord\Writer\AbstractWriter;
/**
- * Abstract HTML element writer
+ * Abstract HTML element writer.
*
* @since 0.11.0
*/
abstract class AbstractElement
{
/**
- * Parent writer
+ * Parent writer.
*
* @var \PhpOffice\PhpWord\Writer\AbstractWriter
*/
protected $parentWriter;
/**
- * Element
+ * Element.
*
* @var \PhpOffice\PhpWord\Element\AbstractElement
*/
protected $element;
/**
- * Without paragraph
+ * Without paragraph.
*
* @var bool
*/
@@ -55,15 +55,13 @@ abstract class AbstractElement
protected $escaper;
/**
- * Write element
+ * Write element.
*/
abstract public function write();
/**
- * Create new instance
+ * Create new instance.
*
- * @param \PhpOffice\PhpWord\Writer\AbstractWriter $parentWriter
- * @param \PhpOffice\PhpWord\Element\AbstractElement $element
* @param bool $withoutP
*/
public function __construct(AbstractWriter $parentWriter, Element $element, $withoutP = false)
@@ -79,7 +77,7 @@ public function __construct(AbstractWriter $parentWriter, Element $element, $wit
*
* @param bool $value
*/
- public function setWithoutP($value)
+ public function setWithoutP($value): void
{
$this->withoutP = $value;
}
diff --git a/src/PhpWord/Writer/HTML/Element/Bookmark.php b/src/PhpWord/Writer/HTML/Element/Bookmark.php
index 082bd76073..521a73db09 100644
--- a/src/PhpWord/Writer/HTML/Element/Bookmark.php
+++ b/src/PhpWord/Writer/HTML/Element/Bookmark.php
@@ -11,21 +11,21 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Writer\HTML\Element;
/**
- * Bookmark element HTML writer
+ * Bookmark element HTML writer.
*
* @since 0.15.0
*/
class Bookmark extends Text
{
/**
- * Write bookmark
+ * Write bookmark.
*
* @return string
*/
diff --git a/src/PhpWord/Writer/HTML/Element/Container.php b/src/PhpWord/Writer/HTML/Element/Container.php
index 006b588918..7909e73f21 100644
--- a/src/PhpWord/Writer/HTML/Element/Container.php
+++ b/src/PhpWord/Writer/HTML/Element/Container.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,21 +20,21 @@
use PhpOffice\PhpWord\Element\AbstractContainer as ContainerElement;
/**
- * Container element HTML writer
+ * Container element HTML writer.
*
* @since 0.11.0
*/
class Container extends AbstractElement
{
/**
- * Namespace; Can't use __NAMESPACE__ in inherited class (RTF)
+ * Namespace; Can't use __NAMESPACE__ in inherited class (RTF).
*
* @var string
*/
protected $namespace = 'PhpOffice\\PhpWord\\Writer\\HTML\\Element';
/**
- * Write container
+ * Write container.
*
* @return string
*/
@@ -45,7 +45,7 @@ public function write()
return '';
}
$containerClass = substr(get_class($container), strrpos(get_class($container), '\\') + 1);
- $withoutP = in_array($containerClass, array('TextRun', 'Footnote', 'Endnote')) ? true : false;
+ $withoutP = in_array($containerClass, ['TextRun', 'Footnote', 'Endnote']) ? true : false;
$content = '';
$elements = $container->getElements();
diff --git a/src/PhpWord/Writer/HTML/Element/Endnote.php b/src/PhpWord/Writer/HTML/Element/Endnote.php
index 2252dc3af8..1c35e8faa8 100644
--- a/src/PhpWord/Writer/HTML/Element/Endnote.php
+++ b/src/PhpWord/Writer/HTML/Element/Endnote.php
@@ -11,21 +11,21 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Writer\HTML\Element;
/**
- * Endnote element HTML writer
+ * Endnote element HTML writer.
*
* @since 0.10.0
*/
class Endnote extends Footnote
{
/**
- * Note type
+ * Note type.
*
* @var string
*/
diff --git a/src/PhpWord/Writer/HTML/Element/Footnote.php b/src/PhpWord/Writer/HTML/Element/Footnote.php
index ed14db1e04..0cb2ca5fcd 100644
--- a/src/PhpWord/Writer/HTML/Element/Footnote.php
+++ b/src/PhpWord/Writer/HTML/Element/Footnote.php
@@ -11,28 +11,28 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Writer\HTML\Element;
/**
- * Footnote element HTML writer
+ * Footnote element HTML writer.
*
* @since 0.10.0
*/
class Footnote extends AbstractElement
{
/**
- * Note type footnote|endnote
+ * Note type footnote|endnote.
*
* @var string
*/
protected $noteType = 'footnote';
/**
- * Write footnote/endnote marks; The actual content is written in parent writer (HTML)
+ * Write footnote/endnote marks; The actual content is written in parent writer (HTML).
*
* @return string
*/
diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php
index 7c22a1663d..40e864e6a4 100644
--- a/src/PhpWord/Writer/HTML/Element/Image.php
+++ b/src/PhpWord/Writer/HTML/Element/Image.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,14 +21,14 @@
use PhpOffice\PhpWord\Writer\HTML\Style\Image as ImageStyleWriter;
/**
- * Image element HTML writer
+ * Image element HTML writer.
*
* @since 0.10.0
*/
class Image extends Text
{
/**
- * Write image
+ * Write image.
*
* @return string
*/
diff --git a/src/PhpWord/Writer/HTML/Element/Link.php b/src/PhpWord/Writer/HTML/Element/Link.php
index f6dae5cdd3..7d302c1f85 100644
--- a/src/PhpWord/Writer/HTML/Element/Link.php
+++ b/src/PhpWord/Writer/HTML/Element/Link.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,14 +20,14 @@
use PhpOffice\PhpWord\Settings;
/**
- * Link element HTML writer
+ * Link element HTML writer.
*
* @since 0.10.0
*/
class Link extends Text
{
/**
- * Write link
+ * Write link.
*
* @return string
*/
diff --git a/src/PhpWord/Writer/HTML/Element/ListItem.php b/src/PhpWord/Writer/HTML/Element/ListItem.php
index 384b3ef165..d04798684f 100644
--- a/src/PhpWord/Writer/HTML/Element/ListItem.php
+++ b/src/PhpWord/Writer/HTML/Element/ListItem.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,14 +20,14 @@
use PhpOffice\PhpWord\Settings;
/**
- * ListItem element HTML writer
+ * ListItem element HTML writer.
*
* @since 0.10.0
*/
class ListItem extends AbstractElement
{
/**
- * Write list item
+ * Write list item.
*
* @return string
*/
diff --git a/src/PhpWord/Writer/HTML/Element/ListItemRun.php b/src/PhpWord/Writer/HTML/Element/ListItemRun.php
index a4d7e46073..5bbe23f0f3 100644
--- a/src/PhpWord/Writer/HTML/Element/ListItemRun.php
+++ b/src/PhpWord/Writer/HTML/Element/ListItemRun.php
@@ -11,21 +11,21 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Writer\HTML\Element;
/**
- * ListItem element HTML writer
+ * ListItem element HTML writer.
*
* @since 0.10.0
*/
class ListItemRun extends TextRun
{
/**
- * Write list item
+ * Write list item.
*
* @return string
*/
diff --git a/src/PhpWord/Writer/HTML/Element/PageBreak.php b/src/PhpWord/Writer/HTML/Element/PageBreak.php
index f9998e3793..762426bf26 100644
--- a/src/PhpWord/Writer/HTML/Element/PageBreak.php
+++ b/src/PhpWord/Writer/HTML/Element/PageBreak.php
@@ -11,21 +11,21 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Writer\HTML\Element;
/**
- * PageBreak element HTML writer
+ * PageBreak element HTML writer.
*
* @since 0.10.0
*/
class PageBreak extends TextBreak
{
/**
- * Write page break
+ * Write page break.
*
* @since 0.12.0
*
diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php
index 059574a272..b1a2ee9667 100644
--- a/src/PhpWord/Writer/HTML/Element/Table.php
+++ b/src/PhpWord/Writer/HTML/Element/Table.php
@@ -11,21 +11,21 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Writer\HTML\Element;
/**
- * Table element HTML writer
+ * Table element HTML writer.
*
* @since 0.10.0
*/
class Table extends AbstractElement
{
/**
- * Write table
+ * Write table.
*
* @return string
*/
@@ -41,15 +41,15 @@ public function write()
if ($rowCount > 0) {
$content .= 'element->getStyle()) . '>' . PHP_EOL;
- for ($i = 0; $i < $rowCount; $i++) {
- /** @var $row \PhpOffice\PhpWord\Element\Row Type hint */
+ for ($i = 0; $i < $rowCount; ++$i) {
+ /** @var \PhpOffice\PhpWord\Element\Row $row Type hint */
$rowStyle = $rows[$i]->getStyle();
// $height = $row->getHeight();
$tblHeader = $rowStyle->isTblHeader();
$content .= '' . PHP_EOL;
$rowCells = $rows[$i]->getCells();
$rowCellCount = count($rowCells);
- for ($j = 0; $j < $rowCellCount; $j++) {
+ for ($j = 0; $j < $rowCellCount; ++$j) {
$cellStyle = $rowCells[$j]->getStyle();
$cellBgColor = $cellStyle->getBgColor();
$cellBgColor === 'auto' && $cellBgColor = null; // auto cannot be parsed to hexadecimal number
@@ -65,11 +65,11 @@ public function write()
$cellVMerge = $cellStyle->getVMerge();
// If this is the first cell of the vertical merge, find out how man rows it spans
if ($cellVMerge === 'restart') {
- for ($k = $i + 1; $k < $rowCount; $k++) {
+ for ($k = $i + 1; $k < $rowCount; ++$k) {
$kRowCells = $rows[$k]->getCells();
if (isset($kRowCells[$j])) {
if ($kRowCells[$j]->getStyle()->getVMerge() === 'continue') {
- $cellRowSpan++;
+ ++$cellRowSpan;
} else {
break;
}
@@ -83,14 +83,14 @@ public function write()
$cellTag = $tblHeader ? 'th' : 'td';
$cellColSpanAttr = (is_numeric($cellColSpan) && ($cellColSpan > 1) ? " colspan=\"{$cellColSpan}\"" : '');
$cellRowSpanAttr = ($cellRowSpan > 1 ? " rowspan=\"{$cellRowSpan}\"" : '');
- $cellBgColorAttr = (is_null($cellBgColor) ? '' : " bgcolor=\"#{$cellBgColor}\"");
- $cellFgColorAttr = (is_null($cellFgColor) ? '' : " color=\"#{$cellFgColor}\"");
+ $cellBgColorAttr = (null === $cellBgColor ? '' : " bgcolor=\"#{$cellBgColor}\"");
+ $cellFgColorAttr = (null === $cellFgColor ? '' : " color=\"#{$cellFgColor}\"");
$content .= "<{$cellTag}{$cellColSpanAttr}{$cellRowSpanAttr}{$cellBgColorAttr}{$cellFgColorAttr}>" . PHP_EOL;
$writer = new Container($this->parentWriter, $rowCells[$j]);
$content .= $writer->write();
if ($cellRowSpan > 1) {
// There shouldn't be any content in the subsequent merged cells, but lets check anyway
- for ($k = $i + 1; $k < $rowCount; $k++) {
+ for ($k = $i + 1; $k < $rowCount; ++$k) {
$kRowCells = $rows[$k]->getCells();
if (isset($kRowCells[$j])) {
if ($kRowCells[$j]->getStyle()->getVMerge() === 'continue') {
@@ -116,9 +116,10 @@ public function write()
}
/**
- * Translates Table style in CSS equivalent
+ * Translates Table style in CSS equivalent.
+ *
+ * @param null|\PhpOffice\PhpWord\Style\Table|string $tableStyle
*
- * @param string|\PhpOffice\PhpWord\Style\Table|null $tableStyle
* @return string
*/
private function getTableStyle($tableStyle = null)
diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php
index 04d76a8327..a360f0922b 100644
--- a/src/PhpWord/Writer/HTML/Element/Text.php
+++ b/src/PhpWord/Writer/HTML/Element/Text.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -25,42 +25,42 @@
use PhpOffice\PhpWord\Writer\HTML\Style\Paragraph as ParagraphStyleWriter;
/**
- * Text element HTML writer
+ * Text element HTML writer.
*
* @since 0.10.0
*/
class Text extends AbstractElement
{
/**
- * Text written after opening
+ * Text written after opening.
*
* @var string
*/
private $openingText = '';
/**
- * Text written before closing
+ * Text written before closing.
*
* @var string
*/
private $closingText = '';
/**
- * Opening tags
+ * Opening tags.
*
* @var string
*/
private $openingTags = '';
/**
- * Closing tag
+ * Closing tag.
*
* @var string
*/
private $closingTags = '';
/**
- * Write text
+ * Write text.
*
* @return string
*/
@@ -91,7 +91,7 @@ public function write()
*
* @param string $value
*/
- public function setOpeningText($value)
+ public function setOpeningText($value): void
{
$this->openingText = $value;
}
@@ -101,13 +101,13 @@ public function setOpeningText($value)
*
* @param string $value
*/
- public function setClosingText($value)
+ public function setClosingText($value): void
{
$this->closingText = $value;
}
/**
- * Write opening
+ * Write opening.
*
* @return string
*/
@@ -129,7 +129,7 @@ protected function writeOpening()
}
/**
- * Write ending
+ * Write ending.
*
* @return string
*/
@@ -154,7 +154,7 @@ protected function writeClosing()
}
/**
- * writes the track change opening tag
+ * writes the track change opening tag.
*
* @return string the HTML, an empty string if no track change information
*/
@@ -172,7 +172,7 @@ private function writeTrackChangeOpening()
$content .= ' array('author'=> $changed->getAuthor(), 'id' => $this->element->getElementId()));
+ $changedProp = ['changed' => ['author' => $changed->getAuthor(), 'id' => $this->element->getElementId()]];
if ($changed->getDate() != null) {
$changedProp['changed']['date'] = $changed->getDate()->format('Y-m-d\TH:i:s\Z');
}
@@ -189,7 +189,7 @@ private function writeTrackChangeOpening()
}
/**
- * writes the track change closing tag
+ * writes the track change closing tag.
*
* @return string the HTML, an empty string if no track change information
*/
@@ -211,7 +211,7 @@ private function writeTrackChangeClosing()
}
/**
- * Write paragraph style
+ * Write paragraph style.
*
* @return string
*/
@@ -243,7 +243,7 @@ private function getParagraphStyle()
/**
* Get font style.
*/
- private function getFontStyle()
+ private function getFontStyle(): void
{
/** @var \PhpOffice\PhpWord\Element\Text $element Type hint */
$element = $this->element;
diff --git a/src/PhpWord/Writer/HTML/Element/TextBreak.php b/src/PhpWord/Writer/HTML/Element/TextBreak.php
index 6ff092dbf7..af73cb4a06 100644
--- a/src/PhpWord/Writer/HTML/Element/TextBreak.php
+++ b/src/PhpWord/Writer/HTML/Element/TextBreak.php
@@ -11,21 +11,21 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Writer\HTML\Element;
/**
- * TextBreak element HTML writer
+ * TextBreak element HTML writer.
*
* @since 0.10.0
*/
class TextBreak extends AbstractElement
{
/**
- * Write text break
+ * Write text break.
*
* @return string
*/
diff --git a/src/PhpWord/Writer/HTML/Element/TextRun.php b/src/PhpWord/Writer/HTML/Element/TextRun.php
index b2deaf25d8..abae7d303f 100644
--- a/src/PhpWord/Writer/HTML/Element/TextRun.php
+++ b/src/PhpWord/Writer/HTML/Element/TextRun.php
@@ -11,21 +11,21 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Writer\HTML\Element;
/**
- * TextRun element HTML writer
+ * TextRun element HTML writer.
*
* @since 0.10.0
*/
class TextRun extends Text
{
/**
- * Write text run
+ * Write text run.
*
* @return string
*/
diff --git a/src/PhpWord/Writer/HTML/Element/Title.php b/src/PhpWord/Writer/HTML/Element/Title.php
index 04ed61f57d..3749505013 100644
--- a/src/PhpWord/Writer/HTML/Element/Title.php
+++ b/src/PhpWord/Writer/HTML/Element/Title.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,14 +20,14 @@
use PhpOffice\PhpWord\Settings;
/**
- * TextRun element HTML writer
+ * TextRun element HTML writer.
*
* @since 0.10.0
*/
class Title extends AbstractElement
{
/**
- * Write heading
+ * Write heading.
*
* @return string
*/
diff --git a/src/PhpWord/Writer/HTML/Part/AbstractPart.php b/src/PhpWord/Writer/HTML/Part/AbstractPart.php
index 97c763759a..8612e28451 100644
--- a/src/PhpWord/Writer/HTML/Part/AbstractPart.php
+++ b/src/PhpWord/Writer/HTML/Part/AbstractPart.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -49,14 +49,12 @@ abstract public function write();
/**
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
*/
- public function setParentWriter(AbstractWriter $writer = null)
+ public function setParentWriter(?AbstractWriter $writer = null): void
{
$this->parentWriter = $writer;
}
/**
- * @throws \PhpOffice\PhpWord\Exception\Exception
- *
* @return \PhpOffice\PhpWord\Writer\AbstractWriter
*/
public function getParentWriter()
@@ -64,6 +62,7 @@ public function getParentWriter()
if ($this->parentWriter !== null) {
return $this->parentWriter;
}
+
throw new Exception('No parent WriterInterface assigned.');
}
}
diff --git a/src/PhpWord/Writer/HTML/Part/Body.php b/src/PhpWord/Writer/HTML/Part/Body.php
index a029f96534..19aae8aa1f 100644
--- a/src/PhpWord/Writer/HTML/Part/Body.php
+++ b/src/PhpWord/Writer/HTML/Part/Body.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,14 +21,14 @@
use PhpOffice\PhpWord\Writer\HTML\Element\TextRun as TextRunWriter;
/**
- * RTF body part writer
+ * RTF body part writer.
*
* @since 0.11.0
*/
class Body extends AbstractPart
{
/**
- * Write part
+ * Write part.
*
* @return string
*/
@@ -52,7 +52,7 @@ public function write()
}
/**
- * Write footnote/endnote contents as textruns
+ * Write footnote/endnote contents as textruns.
*
* @return string
*/
@@ -68,7 +68,7 @@ private function writeNotes()
if (!empty($notes)) {
$content .= ' ' . PHP_EOL;
foreach ($notes as $noteId => $noteMark) {
- list($noteType, $noteTypeId) = explode('-', $noteMark);
+ [$noteType, $noteTypeId] = explode('-', $noteMark);
$method = 'get' . ($noteType == 'endnote' ? 'Endnotes' : 'Footnotes');
$collection = $phpWord->$method()->getItems();
diff --git a/src/PhpWord/Writer/HTML/Part/Head.php b/src/PhpWord/Writer/HTML/Part/Head.php
index 1107becf84..a2541aa4b0 100644
--- a/src/PhpWord/Writer/HTML/Part/Head.php
+++ b/src/PhpWord/Writer/HTML/Part/Head.php
@@ -11,7 +11,7 @@
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2018 PHPWord contributors
+ *
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,30 +26,30 @@
use PhpOffice\PhpWord\Writer\HTML\Style\Paragraph as ParagraphStyleWriter;
/**
- * RTF head part writer
+ * RTF head part writer.
*
* @since 0.11.0
*/
class Head extends AbstractPart
{
/**
- * Write part
+ * Write part.
*
* @return string
*/
public function write()
{
$docProps = $this->getParentWriter()->getPhpWord()->getDocInfo();
- $propertiesMapping = array(
- 'creator' => 'author',
- 'title' => '',
+ $propertiesMapping = [
+ 'creator' => 'author',
+ 'title' => '',
'description' => '',
- 'subject' => '',
- 'keywords' => '',
- 'category' => '',
- 'company' => '',
- 'manager' => '',
- );
+ 'subject' => '',
+ 'keywords' => '',
+ 'category' => '',
+ 'company' => '',
+ 'manager' => '',
+ ];
$title = $docProps->getTitle();
$title = ($title != '') ? $title : 'PHPWord';
@@ -74,7 +74,7 @@ public function write()
}
/**
- * Get styles
+ * Get styles.
*
* @return string
*/
@@ -83,30 +83,30 @@ private function writeStyles()
$css = ' |