From b9f1151bc6f90c276153c3c9dca10a5fc7f355fb Mon Sep 17 00:00:00 2001 From: Adrien Crivelli Date: Fri, 16 Sep 2022 14:45:25 +0200 Subject: [PATCH] Drop most deprecations --- samples/Sample_33_FormField.php | 2 +- samples/Sample_36_RTL.php | 2 +- src/PhpWord/Element/AbstractContainer.php | 32 ---- src/PhpWord/Element/Footnote.php | 28 --- src/PhpWord/Element/Image.php | 24 --- src/PhpWord/Element/Link.php | 42 ----- src/PhpWord/Element/OLEObject.php | 28 --- src/PhpWord/Element/Section.php | 88 ---------- src/PhpWord/Media.php | 162 ------------------ src/PhpWord/PhpWord.php | 104 ----------- src/PhpWord/Reader/AbstractReader.php | 12 -- src/PhpWord/Settings.php | 14 +- src/PhpWord/Style/AbstractStyle.php | 19 +- src/PhpWord/Style/Cell.php | 33 ---- src/PhpWord/Style/Font.php | 80 --------- src/PhpWord/Style/Frame.php | 26 --- src/PhpWord/Style/NumberingLevel.php | 26 --- src/PhpWord/Style/Paragraph.php | 74 -------- src/PhpWord/Style/Row.php | 36 ---- src/PhpWord/Style/Spacing.php | 32 ---- src/PhpWord/Style/TOC.php | 12 -- src/PhpWord/Style/Table.php | 39 ----- src/PhpWord/Template.php | 27 --- src/PhpWord/Writer/AbstractWriter.php | 12 -- src/PhpWord/Writer/HTML.php | 14 -- tests/PhpWordTests/PhpWordTest.php | 32 ---- .../Reader/Word2007/ElementTest.php | 2 +- .../PhpWordTests/Style/AbstractStyleTest.php | 18 ++ tests/PhpWordTests/Style/FontTest.php | 2 +- tests/PhpWordTests/Style/RowTest.php | 4 +- .../Writer/ODText/Style/SectionTest.php | 6 +- 31 files changed, 33 insertions(+), 999 deletions(-) delete mode 100644 src/PhpWord/Template.php diff --git a/samples/Sample_33_FormField.php b/samples/Sample_33_FormField.php index 61abc415cc..24ef6ee947 100644 --- a/samples/Sample_33_FormField.php +++ b/samples/Sample_33_FormField.php @@ -5,7 +5,7 @@ // New Word document echo date('H:i:s'), ' Create new PhpWord object', EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); -$phpWord->getProtection()->setEditing('forms'); +$phpWord->getSettings()->getDocumentProtection()->setEditing('forms'); // New section $section = $phpWord->addSection(); diff --git a/samples/Sample_36_RTL.php b/samples/Sample_36_RTL.php index 7245818c8b..4b3e760465 100644 --- a/samples/Sample_36_RTL.php +++ b/samples/Sample_36_RTL.php @@ -22,7 +22,7 @@ $table = $section->addTable($tableStyle); $cellHCentered = ['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::CENTER]; $cellHEnd = ['alignment' => \PhpOffice\PhpWord\SimpleType\Jc::END]; -$cellVCentered = ['valign' => \PhpOffice\PhpWord\Style\Cell::VALIGN_CENTER]; +$cellVCentered = ['valign' => \PhpOffice\PhpWord\SimpleType\VerticalJc::CENTER]; //Vidually bidirectinal table $table->addRow(); diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php index 92838cddfa..726e204d00 100644 --- a/src/PhpWord/Element/AbstractContainer.php +++ b/src/PhpWord/Element/AbstractContainer.php @@ -285,36 +285,4 @@ private function checkValidity($method) return true; } - - /** - * Create textrun element. - * - * @deprecated 0.10.0 - * - * @param mixed $paragraphStyle - * - * @return \PhpOffice\PhpWord\Element\TextRun - * - * @codeCoverageIgnore - */ - public function createTextRun($paragraphStyle = null) - { - return $this->addTextRun($paragraphStyle); - } - - /** - * Create footnote element. - * - * @deprecated 0.10.0 - * - * @param mixed $paragraphStyle - * - * @return \PhpOffice\PhpWord\Element\Footnote - * - * @codeCoverageIgnore - */ - public function createFootnote($paragraphStyle = null) - { - return $this->addFootnote($paragraphStyle); - } } diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php index 291a44db76..2c1bd26f97 100644 --- a/src/PhpWord/Element/Footnote.php +++ b/src/PhpWord/Element/Footnote.php @@ -60,32 +60,4 @@ public function getParagraphStyle() { return $this->paragraphStyle; } - - /** - * Get Footnote Reference ID. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - * - * @return int - */ - public function getReferenceId() - { - return $this->getRelationId(); - } - - /** - * Set Footnote Reference ID. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - * - * @param int $rId - */ - public function setReferenceId($rId): void - { - $this->setRelationId($rId); - } } diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index dd532a4b2f..15c6997d29 100644 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -554,28 +554,4 @@ private function setProportionalSize($actualWidth, $actualHeight): void } } } - - /** - * Get is watermark. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getIsWatermark() - { - return $this->isWatermark(); - } - - /** - * Get is memory image. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getIsMemImage() - { - return $this->isMemImage(); - } } diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php index ddf5d31f70..0e6ada43c5 100644 --- a/src/PhpWord/Element/Link.php +++ b/src/PhpWord/Element/Link.php @@ -126,48 +126,6 @@ public function getParagraphStyle() return $this->paragraphStyle; } - /** - * Get link target. - * - * @deprecated 0.12.0 - * - * @return string - * - * @codeCoverageIgnore - */ - public function getTarget() - { - return $this->source; - } - - /** - * Get Link source. - * - * @deprecated 0.10.0 - * - * @return string - * - * @codeCoverageIgnore - */ - public function getLinkSrc() - { - return $this->getSource(); - } - - /** - * Get Link name. - * - * @deprecated 0.10.0 - * - * @return string - * - * @codeCoverageIgnore - */ - public function getLinkName() - { - return $this->getText(); - } - /** * is internal. * diff --git a/src/PhpWord/Element/OLEObject.php b/src/PhpWord/Element/OLEObject.php index 00092ea869..df7396cfe1 100644 --- a/src/PhpWord/Element/OLEObject.php +++ b/src/PhpWord/Element/OLEObject.php @@ -136,32 +136,4 @@ public function setImageRelationId($rId): void { $this->imageRelationId = $rId; } - - /** - * Get Object ID. - * - * @deprecated 0.10.0 - * - * @return int - * - * @codeCoverageIgnore - */ - public function getObjectId() - { - return $this->relationId + 1325353440; - } - - /** - * Set Object ID. - * - * @deprecated 0.10.0 - * - * @param int $objId - * - * @codeCoverageIgnore - */ - public function setObjectId($objId): void - { - $this->relationId = $objId; - } } diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php index e9710b8e6e..d77645ff62 100644 --- a/src/PhpWord/Element/Section.php +++ b/src/PhpWord/Element/Section.php @@ -152,20 +152,6 @@ public function getFootnoteProperties() return $this->footnoteProperties; } - /** - * Get the footnote properties. - * - * @deprecated Use the `getFootnoteProperties` method instead - * - * @return FootnoteProperties - * - * @codeCoverageIgnore - */ - public function getFootnotePropoperties() - { - return $this->footnoteProperties; - } - /** * Set the footnote properties. * @@ -230,78 +216,4 @@ private function addHeaderFooter($type = Header::AUTO, $header = true) throw new Exception('Invalid header/footer type.'); } - - /** - * Set section style. - * - * @deprecated 0.12.0 - * - * @param array $settings - * - * @codeCoverageIgnore - */ - public function setSettings($settings = null): void - { - $this->setStyle($settings); - } - - /** - * Get section style. - * - * @deprecated 0.12.0 - * - * @return \PhpOffice\PhpWord\Style\Section - * - * @codeCoverageIgnore - */ - public function getSettings() - { - return $this->getStyle(); - } - - /** - * Create header. - * - * @deprecated 0.10.0 - * - * @return Header - * - * @codeCoverageIgnore - */ - public function createHeader() - { - return $this->addHeader(); - } - - /** - * Create footer. - * - * @deprecated 0.10.0 - * - * @return Footer - * - * @codeCoverageIgnore - */ - public function createFooter() - { - return $this->addFooter(); - } - - /** - * Get footer. - * - * @deprecated 0.10.0 - * - * @return Footer - * - * @codeCoverageIgnore - */ - public function getFooter() - { - if (empty($this->footers)) { - return null; - } - - return $this->footers[1]; - } } diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php index 2e23f0b63b..22b0b06b3a 100644 --- a/src/PhpWord/Media.php +++ b/src/PhpWord/Media.php @@ -207,166 +207,4 @@ public static function resetElements(): void { self::$elements = []; } - - /** - * Add new Section Media Element. - * - * @deprecated 0.10.0 - * - * @param string $src - * @param string $type - * @param \PhpOffice\PhpWord\Element\Image $image - * - * @return int - * - * @codeCoverageIgnore - */ - public static function addSectionMediaElement($src, $type, ?Image $image = null) - { - return self::addElement('section', $type, $src, $image); - } - - /** - * Add new Section Link Element. - * - * @deprecated 0.10.0 - * - * @param string $linkSrc - * - * @return int - * - * @codeCoverageIgnore - */ - public static function addSectionLinkElement($linkSrc) - { - return self::addElement('section', 'link', $linkSrc); - } - - /** - * Get Section Media Elements. - * - * @deprecated 0.10.0 - * - * @param string $key - * - * @return array - * - * @codeCoverageIgnore - */ - public static function getSectionMediaElements($key = null) - { - return self::getElements('section', $key); - } - - /** - * Get Section Media Elements Count. - * - * @deprecated 0.10.0 - * - * @param string $key - * - * @return int - * - * @codeCoverageIgnore - */ - public static function countSectionMediaElements($key = null) - { - return self::countElements('section', $key); - } - - /** - * Add new Header Media Element. - * - * @deprecated 0.10.0 - * - * @param int $headerCount - * @param string $src - * @param \PhpOffice\PhpWord\Element\Image $image - * - * @return int - * - * @codeCoverageIgnore - */ - public static function addHeaderMediaElement($headerCount, $src, ?Image $image = null) - { - return self::addElement("header{$headerCount}", 'image', $src, $image); - } - - /** - * Get Header Media Elements Count. - * - * @deprecated 0.10.0 - * - * @param string $key - * - * @return int - * - * @codeCoverageIgnore - */ - public static function countHeaderMediaElements($key) - { - return self::countElements($key); - } - - /** - * Get Header Media Elements. - * - * @deprecated 0.10.0 - * - * @return array - * - * @codeCoverageIgnore - */ - public static function getHeaderMediaElements() - { - return self::getElements('header'); - } - - /** - * Add new Footer Media Element. - * - * @deprecated 0.10.0 - * - * @param int $footerCount - * @param string $src - * @param \PhpOffice\PhpWord\Element\Image $image - * - * @return int - * - * @codeCoverageIgnore - */ - public static function addFooterMediaElement($footerCount, $src, ?Image $image = null) - { - return self::addElement("footer{$footerCount}", 'image', $src, $image); - } - - /** - * Get Footer Media Elements Count. - * - * @deprecated 0.10.0 - * - * @param string $key - * - * @return int - * - * @codeCoverageIgnore - */ - public static function countFooterMediaElements($key) - { - return self::countElements($key); - } - - /** - * Get Footer Media Elements. - * - * @deprecated 0.10.0 - * - * @return array - * - * @codeCoverageIgnore - */ - public static function getFooterMediaElements() - { - return self::getElements('footer'); - } } diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index d93310e6e0..70ee652b29 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -44,27 +44,6 @@ */ class PhpWord { - /** - * Default font settings. - * - * @deprecated 0.11.0 Use Settings constants - * - * @const string|int - */ - const DEFAULT_FONT_NAME = Settings::DEFAULT_FONT_NAME; - /** - * @deprecated 0.11.0 Use Settings constants - */ - const DEFAULT_FONT_SIZE = Settings::DEFAULT_FONT_SIZE; - /** - * @deprecated 0.11.0 Use Settings constants - */ - const DEFAULT_FONT_COLOR = Settings::DEFAULT_FONT_COLOR; - /** - * @deprecated 0.11.0 Use Settings constants - */ - const DEFAULT_FONT_CONTENT_TYPE = Settings::DEFAULT_FONT_CONTENT_TYPE; - /** * Collection of sections. * @@ -179,21 +158,6 @@ public function getDocInfo() return $this->metadata['DocInfo']; } - /** - * Get protection. - * - * @return \PhpOffice\PhpWord\Metadata\Protection - * - * @since 0.12.0 - * @deprecated Get the Document protection from PhpWord->getSettings()->getDocumentProtection(); - * - * @codeCoverageIgnore - */ - public function getProtection() - { - return $this->getSettings()->getDocumentProtection(); - } - /** * Get compatibility. * @@ -324,26 +288,6 @@ public function setDefaultParagraphStyle($styles) return Style::setDefaultParagraphStyle($styles); } - /** - * Load template by filename. - * - * @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead. - * - * @param string $filename Fully qualified filename - * - * @return TemplateProcessor - * - * @codeCoverageIgnore - */ - public function loadTemplate($filename) - { - if (file_exists($filename)) { - return new TemplateProcessor($filename); - } - - throw new Exception("Template file {$filename} not found."); - } - /** * Save to file or download. * @@ -381,52 +325,4 @@ public function save($filename, $format = 'Word2007', $download = false) return true; } - - /** - * Create new section. - * - * @deprecated 0.10.0 - * - * @param array $settings - * - * @return \PhpOffice\PhpWord\Element\Section - * - * @codeCoverageIgnore - */ - public function createSection($settings = null) - { - return $this->addSection($settings); - } - - /** - * Get document properties object. - * - * @deprecated 0.12.0 - * - * @return \PhpOffice\PhpWord\Metadata\DocInfo - * - * @codeCoverageIgnore - */ - public function getDocumentProperties() - { - return $this->getDocInfo(); - } - - /** - * Set document properties object. - * - * @deprecated 0.12.0 - * - * @param \PhpOffice\PhpWord\Metadata\DocInfo $documentProperties - * - * @return self - * - * @codeCoverageIgnore - */ - public function setDocumentProperties($documentProperties) - { - $this->metadata['Document'] = $documentProperties; - - return $this; - } } diff --git a/src/PhpWord/Reader/AbstractReader.php b/src/PhpWord/Reader/AbstractReader.php index 4a138cd5ce..ff768e3306 100644 --- a/src/PhpWord/Reader/AbstractReader.php +++ b/src/PhpWord/Reader/AbstractReader.php @@ -109,16 +109,4 @@ public function canRead($filename) return true; } - - /** - * Read data only? - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getReadDataOnly() - { - return $this->isReadDataOnly(); - } } diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index 6664770e96..7b1f456eca 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -31,7 +31,7 @@ class Settings */ const ZIPARCHIVE = 'ZipArchive'; const PCLZIP = 'PclZip'; - const OLD_LIB = 'PhpOffice\\PhpWord\\Shared\\ZipArchive'; // @deprecated 0.11 + const OLD_LIB = \PhpOffice\PhpWord\Shared\ZipArchive::class; // @deprecated 0.11 /** * PDF rendering libraries. @@ -480,16 +480,4 @@ public static function setDefaultPaper($value) return false; } - - /** - * Return the compatibility option used by the XMLWriter. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public static function getCompatibility() - { - return self::hasCompatibility(); - } } diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php index d3e1e81877..a4be670dac 100644 --- a/src/PhpWord/Style/AbstractStyle.php +++ b/src/PhpWord/Style/AbstractStyle.php @@ -170,6 +170,11 @@ public function setStyleValue($key, $value) if (isset($this->aliases[$key])) { $key = $this->aliases[$key]; } + + if ($key === 'align') { + $key = 'alignment'; + } + $method = 'set' . Text::removeUnderscorePrefix($key); if (method_exists($this, $method)) { $this->$method($value); @@ -350,18 +355,4 @@ protected function setPairedVal(&$property, &$pairProperty, $value) return $this; } - - /** - * Set style using associative array. - * - * @deprecated 0.11.0 - * - * @return self - * - * @codeCoverageIgnore - */ - public function setArrayStyle(array $style = []) - { - return $this->setStyleByArray($style); - } } diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php index 420f8dc50c..0f05092b69 100644 --- a/src/PhpWord/Style/Cell.php +++ b/src/PhpWord/Style/Cell.php @@ -25,27 +25,6 @@ */ class Cell extends Border { - /** - * Vertical alignment constants. - * - * @const string - * - * @deprecated Use \PhpOffice\PhpWord\SimpleType\VerticalJc::TOP instead - */ - const VALIGN_TOP = 'top'; - /** - * @deprecated Use \PhpOffice\PhpWord\SimpleType\VerticalJc::CENTER instead - */ - const VALIGN_CENTER = 'center'; - /** - * @deprecated Use \PhpOffice\PhpWord\SimpleType\VerticalJc::BOTTOM instead - */ - const VALIGN_BOTTOM = 'bottom'; - /** - * @deprecated Use \PhpOffice\PhpWord\SimpleType\VerticalJc::BOTH instead - */ - const VALIGN_BOTH = 'both'; - //Text direction constants /** * Left to Right, Top to Bottom. @@ -333,16 +312,4 @@ public function setUnit($value) return $this; } - - /** - * Get default border color. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getDefaultBorderColor() - { - return self::DEFAULT_BORDER_COLOR; - } } diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index ea072c6a2d..d0cc2503e1 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -33,14 +33,6 @@ class Font extends AbstractStyle const UNDERLINE_DASHLONG = 'dashLong'; const UNDERLINE_DASHLONGHEAVY = 'dashLongHeavy'; const UNDERLINE_DOUBLE = 'dbl'; - /** - * @deprecated use UNDERLINE_DOTHASH instead, TODO remove in version 1.0 - */ - const UNDERLINE_DOTHASH = 'dotDash'; // Incorrect spelling, for backwards compatibility - /** - * @deprecated use UNDERLINE_DOTDASHHEAVY instead, TODO remove in version 1.0 - */ - const UNDERLINE_DOTHASHHEAVY = 'dotDashHeavy'; // Incorrect spelling, for backwards compatibility const UNDERLINE_DOTDASH = 'dotDash'; const UNDERLINE_DOTDASHHEAVY = 'dotDashHeavy'; const UNDERLINE_DOTDOTDASH = 'dotDotDash'; @@ -907,78 +899,6 @@ public function setLang($value = null) return $this; } - /** - * Get bold. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getBold() - { - return $this->isBold(); - } - - /** - * Get italic. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getItalic() - { - return $this->isItalic(); - } - - /** - * Get superscript. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getSuperScript() - { - return $this->isSuperScript(); - } - - /** - * Get subscript. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getSubScript() - { - return $this->isSubScript(); - } - - /** - * Get strikethrough. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getStrikethrough() - { - return $this->isStrikethrough(); - } - - /** - * Get paragraph style. - * - * @deprecated 0.11.0 - * - * @codeCoverageIgnore - */ - public function getParagraphStyle() - { - return $this->getParagraph(); - } - /** * Get hidden text. * diff --git a/src/PhpWord/Style/Frame.php b/src/PhpWord/Style/Frame.php index 489c56b26f..45fc583ed1 100644 --- a/src/PhpWord/Style/Frame.php +++ b/src/PhpWord/Style/Frame.php @@ -245,32 +245,6 @@ public function setAlignment($value) return $this; } - /** - * @deprecated 0.13.0 Use the `getAlignment` method instead. - * - * @return string - * - * @codeCoverageIgnore - */ - public function getAlign() - { - return $this->getAlignment(); - } - - /** - * @deprecated 0.13.0 Use the `setAlignment` method instead. - * - * @param string $value - * - * @return self - * - * @codeCoverageIgnore - */ - public function setAlign($value = null) - { - return $this->setAlignment($value); - } - /** * Get unit. * diff --git a/src/PhpWord/Style/NumberingLevel.php b/src/PhpWord/Style/NumberingLevel.php index 5efc830016..39c0d839d6 100644 --- a/src/PhpWord/Style/NumberingLevel.php +++ b/src/PhpWord/Style/NumberingLevel.php @@ -328,32 +328,6 @@ public function setAlignment($value) return $this; } - /** - * @deprecated 0.13.0 Use the `getAlignment` method instead. - * - * @return string - * - * @codeCoverageIgnore - */ - public function getAlign() - { - return $this->getAlignment(); - } - - /** - * @deprecated 0.13.0 Use the `setAlignment` method instead. - * - * @param string $value - * - * @return self - * - * @codeCoverageIgnore - */ - public function setAlign($value) - { - return $this->setAlignment($value); - } - /** * Get left. * diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index cce8d3ce9c..e22016517b 100644 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -272,32 +272,6 @@ public function setAlignment($value) return $this; } - /** - * @deprecated 0.13.0 Use the `getAlignment` method instead. - * - * @return string - * - * @codeCoverageIgnore - */ - public function getAlign() - { - return $this->getAlignment(); - } - - /** - * @deprecated 0.13.0 Use the `setAlignment` method instead. - * - * @param string $value - * - * @return self - * - * @codeCoverageIgnore - */ - public function setAlign($value = null) - { - return $this->setAlignment($value); - } - /** * Get parent style ID. * @@ -734,54 +708,6 @@ public function setTabs($value = null) return $this; } - /** - * Get allow first/last line to display on a separate page setting. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getWidowControl() - { - return $this->hasWidowControl(); - } - - /** - * Get keep paragraph with next paragraph setting. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getKeepNext() - { - return $this->isKeepNext(); - } - - /** - * Get keep all lines on one page setting. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getKeepLines() - { - return $this->isKeepLines(); - } - - /** - * Get start paragraph on next page setting. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getPageBreakBefore() - { - return $this->hasPageBreakBefore(); - } - /** * Get shading. * diff --git a/src/PhpWord/Style/Row.php b/src/PhpWord/Style/Row.php index e7be3992e1..765c54f80e 100644 --- a/src/PhpWord/Style/Row.php +++ b/src/PhpWord/Style/Row.php @@ -123,40 +123,4 @@ public function setExactHeight($value = true) return $this; } - - /** - * Get tblHeader. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getTblHeader() - { - return $this->isTblHeader(); - } - - /** - * Get cantSplit. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getCantSplit() - { - return $this->isCantSplit(); - } - - /** - * Get exactHeight. - * - * @deprecated 0.10.0 - * - * @codeCoverageIgnore - */ - public function getExactHeight() - { - return $this->isExactHeight(); - } } diff --git a/src/PhpWord/Style/Spacing.php b/src/PhpWord/Style/Spacing.php index 165cfd0262..7807065dd4 100644 --- a/src/PhpWord/Style/Spacing.php +++ b/src/PhpWord/Style/Spacing.php @@ -161,36 +161,4 @@ public function setLineRule($value = null) return $this; } - - /** - * Get line rule. - * - * @return string - * - * @deprecated Use getLineRule() instead - * - * @codeCoverageIgnore - */ - public function getRule() - { - return $this->lineRule; - } - - /** - * Set line rule. - * - * @param string $value - * - * @return self - * - * @deprecated Use setLineRule() instead - * - * @codeCoverageIgnore - */ - public function setRule($value = null) - { - $this->lineRule = $value; - - return $this; - } } diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php index d1d851bdc4..bd0d906907 100644 --- a/src/PhpWord/Style/TOC.php +++ b/src/PhpWord/Style/TOC.php @@ -22,18 +22,6 @@ */ class TOC extends Tab { - /** - * Tab leader types for backward compatibility. - * - * @deprecated 0.11.0 - * - * @const string - */ - const TABLEADER_DOT = self::TAB_LEADER_DOT; - const TABLEADER_UNDERSCORE = self::TAB_LEADER_UNDERSCORE; - const TABLEADER_LINE = self::TAB_LEADER_HYPHEN; - const TABLEADER_NONE = self::TAB_LEADER_NONE; - /** * Indent. * diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index c2d6406d37..b267c7568f 100644 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -24,19 +24,6 @@ class Table extends Border { - /** - * @deprecated Use \PhpOffice\PhpWord\SimpleType\TblWidth::AUTO instead - */ - const WIDTH_AUTO = 'auto'; // Automatically determined width - /** - * @deprecated Use \PhpOffice\PhpWord\SimpleType\TblWidth::PERCENT instead - */ - const WIDTH_PERCENT = 'pct'; // Width in fiftieths (1/50) of a percent (1% = 50 unit) - /** - * @deprecated Use \PhpOffice\PhpWord\SimpleType\TblWidth::TWIP instead - */ - const WIDTH_TWIP = 'dxa'; // Width in twentieths (1/20) of a point (twip) - //values for http://www.datypic.com/sc/ooxml/t-w_ST_TblLayoutType.html /** * AutoFit Table Layout. @@ -596,32 +583,6 @@ public function setAlignment($value) return $this; } - /** - * @deprecated 0.13.0 Use the `getAlignment` method instead. - * - * @return string - * - * @codeCoverageIgnore - */ - public function getAlign() - { - return $this->getAlignment(); - } - - /** - * @deprecated 0.13.0 Use the `setAlignment` method instead. - * - * @param string $value - * - * @return self - * - * @codeCoverageIgnore - */ - public function setAlign($value = null) - { - return $this->setAlignment($value); - } - /** * Get width. * diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php deleted file mode 100644 index e0e09450a8..0000000000 --- a/src/PhpWord/Template.php +++ /dev/null @@ -1,27 +0,0 @@ -isUseDiskCaching(); - } } diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php index 34d3fb32a6..ea0d654e5d 100644 --- a/src/PhpWord/Writer/HTML.php +++ b/src/PhpWord/Writer/HTML.php @@ -122,18 +122,4 @@ public function addNote($noteId, $noteMark): void { $this->notes[$noteId] = $noteMark; } - - /** - * Write document. - * - * @deprecated 0.11.0 - * - * @return string - * - * @codeCoverageIgnore - */ - public function writeDocument() - { - return $this->getContent(); - } } diff --git a/tests/PhpWordTests/PhpWordTest.php b/tests/PhpWordTests/PhpWordTest.php index 60b8c4bd36..19e141f49e 100644 --- a/tests/PhpWordTests/PhpWordTest.php +++ b/tests/PhpWordTests/PhpWordTest.php @@ -117,38 +117,6 @@ public function testAddTitleStyle(): void self::assertInstanceOf('PhpOffice\\PhpWord\\Style\\Font', Style::getStyle($titleName)); } - /** - * Test load template. - * - * @deprecated 0.12.0 - */ - public function testLoadTemplate(): void - { - $templateFqfn = __DIR__ . '/_files/templates/blank.docx'; - - $phpWord = new PhpWord(); - self::assertInstanceOf( - 'PhpOffice\\PhpWord\\TemplateProcessor', - $phpWord->loadTemplate($templateFqfn) - ); - } - - /** - * Test load template exception. - * - * @deprecated 0.12.0 - */ - public function testLoadTemplateException(): void - { - $this->expectException(\PhpOffice\PhpWord\Exception\Exception::class); - $templateFqfn = implode( - DIRECTORY_SEPARATOR, - [PHPWORD_TESTS_BASE_DIR, 'PhpWord', 'Tests', '_files', 'templates', 'blanks.docx'] - ); - $phpWord = new PhpWord(); - $phpWord->loadTemplate($templateFqfn); - } - /** * Test save. */ diff --git a/tests/PhpWordTests/Reader/Word2007/ElementTest.php b/tests/PhpWordTests/Reader/Word2007/ElementTest.php index 43801989f0..8403f44f7b 100644 --- a/tests/PhpWordTests/Reader/Word2007/ElementTest.php +++ b/tests/PhpWordTests/Reader/Word2007/ElementTest.php @@ -149,7 +149,7 @@ public function testReadListItemRunWithFormatting(): void self::assertEquals('Two', $listElements[0]->getText()); self::assertEquals(' with ', $listElements[1]->getText()); self::assertEquals('bold', $listElements[2]->getText()); - self::assertTrue($listElements[2]->getFontStyle()->getBold()); + self::assertTrue($listElements[2]->getFontStyle()->isBold()); } /** diff --git a/tests/PhpWordTests/Style/AbstractStyleTest.php b/tests/PhpWordTests/Style/AbstractStyleTest.php index 7592621377..47c265738a 100644 --- a/tests/PhpWordTests/Style/AbstractStyleTest.php +++ b/tests/PhpWordTests/Style/AbstractStyleTest.php @@ -18,6 +18,8 @@ namespace PhpOffice\PhpWordTests\Style; use InvalidArgumentException; +use PhpOffice\PhpWord\SimpleType\Jc; +use PhpOffice\PhpWord\Style\Paragraph; use ReflectionClass; /** @@ -38,6 +40,22 @@ public function testSetStyleByArray(): void self::assertEquals(1, $stub->getIndex()); } + public function testSetStyleByArrayWithAlign(): void + { + $stub = new Paragraph(); + $stub->setStyleByArray(['align' => Jc::CENTER]); + + self::assertEquals(Jc::CENTER, $stub->getAlignment()); + } + + public function testSetStyleByArrayWithAlignment(): void + { + $stub = new Paragraph(); + $stub->setStyleByArray(['alignment' => Jc::CENTER]); + + self::assertEquals(Jc::CENTER, $stub->getAlignment()); + } + /** * Test setBoolVal, setIntVal, setFloatVal, setEnumVal with normal value. */ diff --git a/tests/PhpWordTests/Style/FontTest.php b/tests/PhpWordTests/Style/FontTest.php index 557a3b2839..854a4b5951 100644 --- a/tests/PhpWordTests/Style/FontTest.php +++ b/tests/PhpWordTests/Style/FontTest.php @@ -46,7 +46,7 @@ public function testInitiation(): void $object = new Font('text', ['alignment' => Jc::BOTH]); self::assertEquals('text', $object->getStyleType()); - self::assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $object->getParagraphStyle()); + self::assertInstanceOf(\PhpOffice\PhpWord\Style\Paragraph::class, $object->getParagraph()); self::assertIsArray($object->getStyleValues()); } diff --git a/tests/PhpWordTests/Style/RowTest.php b/tests/PhpWordTests/Style/RowTest.php index 3ccd408453..6a53b9e25d 100644 --- a/tests/PhpWordTests/Style/RowTest.php +++ b/tests/PhpWordTests/Style/RowTest.php @@ -43,7 +43,7 @@ public function testBooleanValue(): void foreach ($properties as $key => $value) { // set/get $set = "set{$key}"; - $get = "get{$key}"; + $get = "is{$key}"; $expected = $value ? 1 : 0; $object->$set($value); self::assertEquals($expected, $object->$get()); @@ -70,7 +70,7 @@ public function testNonBooleanValue(): void ]; foreach ($properties as $key => $value) { $set = "set{$key}"; - $get = "get{$key}"; + $get = "is{$key}"; $object->$set($value); self::assertFalse($object->$get()); } diff --git a/tests/PhpWordTests/Writer/ODText/Style/SectionTest.php b/tests/PhpWordTests/Writer/ODText/Style/SectionTest.php index d9b6f6eea7..cbd58da455 100644 --- a/tests/PhpWordTests/Writer/ODText/Style/SectionTest.php +++ b/tests/PhpWordTests/Writer/ODText/Style/SectionTest.php @@ -42,10 +42,10 @@ public function testHeaderFooterTabs(): void $margins = \PhpOffice\PhpWord\Shared\Converter::INCH_TO_TWIP; $phpWord->addFontStyle('hdrstyle1', ['name' => 'Courier New', 'size' => 8]); $section = $phpWord->addSection(['paperSize' => 'Letter', 'marginTop' => $margins, 'marginBottom' => $margins]); - $header = $section->createHeader(); + $header = $section->addHeader(); $phpWord->addParagraphStyle('centerheader', ['align' => 'center']); $header->addText('Centered Header', 'hdrstyle1', 'centerheader'); - $footer = $section->createFooter(); + $footer = $section->addFooter(); $sizew = $section->getStyle()->getPageSizeW(); $sizel = $section->getStyle()->getMarginLeft(); $sizer = $section->getStyle()->getMarginRight(); @@ -177,7 +177,7 @@ public function testMultipleSections(): void $section = $phpWord->addSection(['paperSize' => 'Letter', 'Orientation' => 'portrait']); $section->addText('This section uses Letter paper in portrait orientation.'); $section = $phpWord->addSection(['paperSize' => 'A4', 'Orientation' => 'landscape', 'pageNumberingStart' => '9']); - $header = $section->createHeader(); + $header = $section->addHeader(); $header->addField('PAGE'); $section->addText('This section uses A4 paper in landscape orientation. It should have a page break beforehand. It artificially starts on page 9.');