Added type hints and matching PHPDoc. Also added @return void.
This commit is contained in:
parent
40d5770651
commit
1a80aacb4f
@ -2,16 +2,13 @@
|
|||||||
/**
|
/**
|
||||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||||
* word processing documents.
|
* word processing documents.
|
||||||
*
|
|
||||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||||
* General Public License version 3 as published by the Free Software Foundation.
|
* General Public License version 3 as published by the Free Software Foundation.
|
||||||
*
|
|
||||||
* For the full copyright and license information, please read the LICENSE
|
* For the full copyright and license information, please read the LICENSE
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @see https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
*
|
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -27,58 +24,59 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* margin top.
|
* margin top.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var null|int
|
||||||
*/
|
*/
|
||||||
private $innerMarginTop;
|
private $innerMarginTop;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* margin left.
|
* margin left.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var null|int
|
||||||
*/
|
*/
|
||||||
private $innerMarginLeft;
|
private $innerMarginLeft;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* margin right.
|
* margin right.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var null|int
|
||||||
*/
|
*/
|
||||||
private $innerMarginRight;
|
private $innerMarginRight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cell margin bottom.
|
* Cell margin bottom.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var null|int
|
||||||
*/
|
*/
|
||||||
private $innerMarginBottom;
|
private $innerMarginBottom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* border size.
|
* border size.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var null|int
|
||||||
*/
|
*/
|
||||||
private $borderSize;
|
private $borderSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* border color.
|
* border color.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var null|string
|
||||||
*/
|
*/
|
||||||
private $borderColor;
|
private $borderColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* background color.
|
* background color.
|
||||||
*
|
*
|
||||||
* @var string
|
* @var null|string
|
||||||
*/
|
*/
|
||||||
private $bgColor;
|
private $bgColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set background color.
|
* Set background color.
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param null|string $value
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setBgColor($value = null): void
|
public function setBgColor(string $value = null): void
|
||||||
{
|
{
|
||||||
$this->bgColor = $value;
|
$this->bgColor = $value;
|
||||||
}
|
}
|
||||||
@ -86,9 +84,9 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Get background color.
|
* Get background color.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
public function getBgColor()
|
public function getBgColor(): ?string
|
||||||
{
|
{
|
||||||
return $this->bgColor;
|
return $this->bgColor;
|
||||||
}
|
}
|
||||||
@ -96,9 +94,10 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Set margin top.
|
* Set margin top.
|
||||||
*
|
*
|
||||||
* @param int $value
|
* @param null|int $value
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setInnerMarginTop($value = null): void
|
public function setInnerMarginTop(int $value = null): void
|
||||||
{
|
{
|
||||||
$this->innerMarginTop = $value;
|
$this->innerMarginTop = $value;
|
||||||
}
|
}
|
||||||
@ -106,9 +105,9 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Get margin top.
|
* Get margin top.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return null|int
|
||||||
*/
|
*/
|
||||||
public function getInnerMarginTop()
|
public function getInnerMarginTop(): ?int
|
||||||
{
|
{
|
||||||
return $this->innerMarginTop;
|
return $this->innerMarginTop;
|
||||||
}
|
}
|
||||||
@ -116,9 +115,10 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Set margin left.
|
* Set margin left.
|
||||||
*
|
*
|
||||||
* @param int $value
|
* @param null|int $value
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setInnerMarginLeft($value = null): void
|
public function setInnerMarginLeft(int $value = null): void
|
||||||
{
|
{
|
||||||
$this->innerMarginLeft = $value;
|
$this->innerMarginLeft = $value;
|
||||||
}
|
}
|
||||||
@ -126,9 +126,9 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Get margin left.
|
* Get margin left.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return null|int
|
||||||
*/
|
*/
|
||||||
public function getInnerMarginLeft()
|
public function getInnerMarginLeft(): ?int
|
||||||
{
|
{
|
||||||
return $this->innerMarginLeft;
|
return $this->innerMarginLeft;
|
||||||
}
|
}
|
||||||
@ -136,9 +136,10 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Set margin right.
|
* Set margin right.
|
||||||
*
|
*
|
||||||
* @param int $value
|
* @param null|int $value
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setInnerMarginRight($value = null): void
|
public function setInnerMarginRight(int $value = null): void
|
||||||
{
|
{
|
||||||
$this->innerMarginRight = $value;
|
$this->innerMarginRight = $value;
|
||||||
}
|
}
|
||||||
@ -146,9 +147,9 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Get margin right.
|
* Get margin right.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return null|int
|
||||||
*/
|
*/
|
||||||
public function getInnerMarginRight()
|
public function getInnerMarginRight(): ?int
|
||||||
{
|
{
|
||||||
return $this->innerMarginRight;
|
return $this->innerMarginRight;
|
||||||
}
|
}
|
||||||
@ -156,9 +157,10 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Set margin bottom.
|
* Set margin bottom.
|
||||||
*
|
*
|
||||||
* @param int $value
|
* @param null|int $value
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setInnerMarginBottom($value = null): void
|
public function setInnerMarginBottom(int $value = null): void
|
||||||
{
|
{
|
||||||
$this->innerMarginBottom = $value;
|
$this->innerMarginBottom = $value;
|
||||||
}
|
}
|
||||||
@ -166,9 +168,9 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Get margin bottom.
|
* Get margin bottom.
|
||||||
*
|
*
|
||||||
* @return int
|
* @return null|int
|
||||||
*/
|
*/
|
||||||
public function getInnerMarginBottom()
|
public function getInnerMarginBottom(): ?int
|
||||||
{
|
{
|
||||||
return $this->innerMarginBottom;
|
return $this->innerMarginBottom;
|
||||||
}
|
}
|
||||||
@ -176,9 +178,10 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Set TLRB cell margin.
|
* Set TLRB cell margin.
|
||||||
*
|
*
|
||||||
* @param int $value Margin in twips
|
* @param null|int $value Margin in twips
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setInnerMargin($value = null): void
|
public function setInnerMargin(int $value = null): void
|
||||||
{
|
{
|
||||||
$this->setInnerMarginTop($value);
|
$this->setInnerMarginTop($value);
|
||||||
$this->setInnerMarginLeft($value);
|
$this->setInnerMarginLeft($value);
|
||||||
@ -191,7 +194,7 @@ class TextBox extends Image
|
|||||||
*
|
*
|
||||||
* @return int[]
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
public function getInnerMargin()
|
public function getInnerMargin(): array
|
||||||
{
|
{
|
||||||
return [$this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom];
|
return [$this->innerMarginLeft, $this->innerMarginTop, $this->innerMarginRight, $this->innerMarginBottom];
|
||||||
}
|
}
|
||||||
@ -201,7 +204,7 @@ class TextBox extends Image
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function hasInnerMargins()
|
public function hasInnerMargins(): bool
|
||||||
{
|
{
|
||||||
$hasInnerMargins = false;
|
$hasInnerMargins = false;
|
||||||
$margins = $this->getInnerMargin();
|
$margins = $this->getInnerMargin();
|
||||||
@ -218,9 +221,10 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Set border size.
|
* Set border size.
|
||||||
*
|
*
|
||||||
* @param int $value Size in points
|
* @param null|int $value Size in points
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setBorderSize($value = null): void
|
public function setBorderSize(int $value = null): void
|
||||||
{
|
{
|
||||||
$this->borderSize = $value;
|
$this->borderSize = $value;
|
||||||
}
|
}
|
||||||
@ -230,7 +234,7 @@ class TextBox extends Image
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getBorderSize()
|
public function getBorderSize(): int
|
||||||
{
|
{
|
||||||
return $this->borderSize;
|
return $this->borderSize;
|
||||||
}
|
}
|
||||||
@ -238,9 +242,10 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Set border color.
|
* Set border color.
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param null|string $value
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setBorderColor($value = null): void
|
public function setBorderColor(string $value = null): void
|
||||||
{
|
{
|
||||||
$this->borderColor = $value;
|
$this->borderColor = $value;
|
||||||
}
|
}
|
||||||
@ -248,9 +253,9 @@ class TextBox extends Image
|
|||||||
/**
|
/**
|
||||||
* Get border color.
|
* Get border color.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
public function getBorderColor()
|
public function getBorderColor(): ?string
|
||||||
{
|
{
|
||||||
return $this->borderColor;
|
return $this->borderColor;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,16 +2,13 @@
|
|||||||
/**
|
/**
|
||||||
* This file is part of PHPWord - A pure PHP library for reading and writing
|
* This file is part of PHPWord - A pure PHP library for reading and writing
|
||||||
* word processing documents.
|
* word processing documents.
|
||||||
*
|
|
||||||
* PHPWord is free software distributed under the terms of the GNU Lesser
|
* PHPWord is free software distributed under the terms of the GNU Lesser
|
||||||
* General Public License version 3 as published by the Free Software Foundation.
|
* General Public License version 3 as published by the Free Software Foundation.
|
||||||
*
|
|
||||||
* For the full copyright and license information, please read the LICENSE
|
* For the full copyright and license information, please read the LICENSE
|
||||||
* file that was distributed with this source code. For the full list of
|
* file that was distributed with this source code. For the full list of
|
||||||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
|
||||||
*
|
*
|
||||||
* @see https://github.com/PHPOffice/PHPWord
|
* @see https://github.com/PHPOffice/PHPWord
|
||||||
*
|
|
||||||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -28,18 +25,20 @@ class TextBox extends Image
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Write element.
|
* Write element.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function write(): void
|
public function write(): void
|
||||||
{
|
{
|
||||||
$xmlWriter = $this->getXmlWriter();
|
$xmlWriter = $this->getXmlWriter();
|
||||||
$element = $this->getElement();
|
$element = $this->getElement();
|
||||||
if (!$element instanceof \PhpOffice\PhpWord\Element\TextBox) {
|
if (! $element instanceof \PhpOffice\PhpWord\Element\TextBox) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$style = $element->getStyle();
|
$style = $element->getStyle();
|
||||||
$styleWriter = new TextBoxStyleWriter($xmlWriter, $style);
|
$styleWriter = new TextBoxStyleWriter($xmlWriter, $style);
|
||||||
|
|
||||||
if (!$this->withoutP) {
|
if (! $this->withoutP) {
|
||||||
$xmlWriter->startElement('w:p');
|
$xmlWriter->startElement('w:p');
|
||||||
$styleWriter->writeAlignment();
|
$styleWriter->writeAlignment();
|
||||||
}
|
}
|
||||||
@ -53,6 +52,7 @@ class TextBox extends Image
|
|||||||
if ($style->getBgColor()) {
|
if ($style->getBgColor()) {
|
||||||
$xmlWriter->writeAttribute('fillcolor', $style->getBgColor());
|
$xmlWriter->writeAttribute('fillcolor', $style->getBgColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
$styleWriter->write();
|
$styleWriter->write();
|
||||||
$styleWriter->writeBorder();
|
$styleWriter->writeBorder();
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,7 @@ class TextBox extends Frame
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Writer inner margin.
|
* Writer inner margin.
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function writeInnerMargin(): void
|
public function writeInnerMargin(): void
|
||||||
{
|
{
|
||||||
@ -44,6 +45,7 @@ class TextBox extends Frame
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Writer border.
|
* Writer border.
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function writeBorder(): void
|
public function writeBorder(): void
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user