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