Skip to content

Commit

Permalink
Merge pull request #1996 from liborm85/drop-common-package
Browse files Browse the repository at this point in the history
Remove legacy PHPOffice/Common package, fix PHP 8.0 compatibility
  • Loading branch information
troosan authored Jan 12, 2021
2 parents cf808cb + 40966dd commit 06c8248
Show file tree
Hide file tree
Showing 72 changed files with 1,773 additions and 163 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@ matrix:
dist: trusty
- php: 7.0
env: COVERAGE=1
- php: 8.0
env: DEPENDENCIES="--ignore-platform-reqs"
exclude:
- php: 5.3
dist: xenial
- php: 5.4
dist: xenial
- php: 5.5
dist: xenial
allow_failures:
- php: 8.0

cache:
directories:
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@
"require": {
"php": "^5.3.3 || ^7.0 || ^8.0",
"ext-xml": "*",
"laminas/laminas-escaper": "^2.2",
"phpoffice/common": "^0.2.9"
"laminas/laminas-escaper": "^2.2"
},
"require-dev": {
"ext-zip": "*",
Expand All @@ -71,7 +70,7 @@
"friendsofphp/php-cs-fixer": "^2.2",
"phpmd/phpmd": "2.*",
"phploc/phploc": "2.* || 3.* || 4.* || 5.* || 6.* || 7.*",
"dompdf/dompdf":"0.8.*",
"dompdf/dompdf":"0.8.* || 1.0.*",
"tecnickcom/tcpdf": "6.*",
"mpdf/mpdf": "5.7.4 || 6.* || 7.* || 8.*",
"php-coveralls/php-coveralls": "1.1.0 || ^2.0"
Expand Down
4 changes: 2 additions & 2 deletions src/PhpWord/Element/Bookmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace PhpOffice\PhpWord\Element;

use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Shared\Text as SharedText;

/**
* Bookmark element
Expand Down Expand Up @@ -45,7 +45,7 @@ class Bookmark extends AbstractElement
*/
public function __construct($name = '')
{
$this->name = CommonText::toUTF8($name);
$this->name = SharedText::toUTF8($name);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/PhpWord/Element/CheckBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace PhpOffice\PhpWord\Element;

use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Shared\Text as SharedText;

/**
* Check box element
Expand Down Expand Up @@ -55,7 +55,7 @@ public function __construct($name = null, $text = null, $fontStyle = null, $para
*/
public function setName($name)
{
$this->name = CommonText::toUTF8($name);
$this->name = SharedText::toUTF8($name);

return $this;
}
Expand Down
6 changes: 3 additions & 3 deletions src/PhpWord/Element/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace PhpOffice\PhpWord\Element;

use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Shared\Text as SharedText;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;

Expand Down Expand Up @@ -79,8 +79,8 @@ class Link extends AbstractElement
*/
public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
{
$this->source = CommonText::toUTF8($source);
$this->text = is_null($text) ? $this->source : CommonText::toUTF8($text);
$this->source = SharedText::toUTF8($source);
$this->text = is_null($text) ? $this->source : SharedText::toUTF8($text);
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
$this->internal = $internal;
Expand Down
4 changes: 2 additions & 2 deletions src/PhpWord/Element/ListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace PhpOffice\PhpWord\Element;

use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Shared\Text as SharedText;
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;

/**
Expand Down Expand Up @@ -57,7 +57,7 @@ class ListItem extends AbstractElement
*/
public function __construct($text, $depth = 0, $fontStyle = null, $listStyle = null, $paragraphStyle = null)
{
$this->textObject = new Text(CommonText::toUTF8($text), $fontStyle, $paragraphStyle);
$this->textObject = new Text(SharedText::toUTF8($text), $fontStyle, $paragraphStyle);
$this->depth = $depth;

// Version >= 0.10.0 will pass numbering style name. Older version will use old method
Expand Down
4 changes: 2 additions & 2 deletions src/PhpWord/Element/PreserveText.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace PhpOffice\PhpWord\Element;

use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Shared\Text as SharedText;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;

Expand Down Expand Up @@ -59,7 +59,7 @@ public function __construct($text = null, $fontStyle = null, $paragraphStyle = n
$this->fontStyle = $this->setNewStyle(new Font('text'), $fontStyle);
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);

$this->text = CommonText::toUTF8($text);
$this->text = SharedText::toUTF8($text);
$matches = preg_split('/({.*?})/', $this->text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
if (isset($matches[0])) {
$this->text = $matches;
Expand Down
4 changes: 2 additions & 2 deletions src/PhpWord/Element/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace PhpOffice\PhpWord\Element;

use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Shared\Text as SharedText;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;

Expand Down Expand Up @@ -136,7 +136,7 @@ public function getParagraphStyle()
*/
public function setText($text)
{
$this->text = CommonText::toUTF8($text);
$this->text = SharedText::toUTF8($text);

return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions src/PhpWord/Element/Title.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace PhpOffice\PhpWord\Element;

use PhpOffice\Common\Text as CommonText;
use PhpOffice\PhpWord\Shared\Text as SharedText;
use PhpOffice\PhpWord\Style;

/**
Expand Down Expand Up @@ -62,7 +62,7 @@ class Title extends AbstractElement
public function __construct($text, $depth = 1)
{
if (is_string($text)) {
$this->text = CommonText::toUTF8($text);
$this->text = SharedText::toUTF8($text);
} elseif ($text instanceof TextRun) {
$this->text = $text;
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Metadata/Protection.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace PhpOffice\PhpWord\Metadata;

use PhpOffice\Common\Microsoft\PasswordEncoder;
use PhpOffice\PhpWord\Shared\Microsoft\PasswordEncoder;
use PhpOffice\PhpWord\SimpleType\DocProtect;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Reader/MsDoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

namespace PhpOffice\PhpWord\Reader;

use PhpOffice\Common\Drawing;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\Drawing;
use PhpOffice\PhpWord\Shared\OLERead;
use PhpOffice\PhpWord\Style;

Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Reader/ODText.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

namespace PhpOffice\PhpWord\Reader;

use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLReader;

/**
* Reader for ODText
Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Reader/ODText/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

namespace PhpOffice\PhpWord\Reader\ODText;

use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\Element\TrackChange;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLReader;

/**
* Content reader
Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Reader/ODText/Meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

namespace PhpOffice\PhpWord\Reader\ODText;

use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLReader;

/**
* Meta reader
Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Reader/Word2007.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

namespace PhpOffice\PhpWord\Reader;

use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLReader;
use PhpOffice\PhpWord\Shared\ZipArchive;

/**
Expand Down
22 changes: 11 additions & 11 deletions src/PhpWord/Reader/Word2007/AbstractPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

namespace PhpOffice\PhpWord\Reader\Word2007;

use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\ComplexType\TblWidth as TblWidthComplexType;
use PhpOffice\PhpWord\Element\AbstractContainer;
use PhpOffice\PhpWord\Element\TextRun;
use PhpOffice\PhpWord\Element\TrackChange;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLReader;

/**
* Abstract part reader
Expand Down Expand Up @@ -95,7 +95,7 @@ public function setRels($value)
/**
* Read w:p.
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @param \PhpOffice\PhpWord\Element\AbstractContainer $parent
* @param string $docPart
Expand Down Expand Up @@ -202,7 +202,7 @@ private function getHeadingDepth(array $paragraphStyle = null)
/**
* Read w:r.
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @param \PhpOffice\PhpWord\Element\AbstractContainer $parent
* @param string $docPart
Expand Down Expand Up @@ -320,7 +320,7 @@ protected function readRunChild(XMLReader $xmlReader, \DOMElement $node, Abstrac
/**
* Read w:tbl.
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @param mixed $parent
* @param string $docPart
Expand Down Expand Up @@ -378,7 +378,7 @@ protected function readTable(XMLReader $xmlReader, \DOMElement $domNode, $parent
/**
* Read w:pPr.
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return array|null
*/
Expand Down Expand Up @@ -413,7 +413,7 @@ protected function readParagraphStyle(XMLReader $xmlReader, \DOMElement $domNode
/**
* Read w:rPr
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return array|null
*/
Expand Down Expand Up @@ -459,7 +459,7 @@ protected function readFontStyle(XMLReader $xmlReader, \DOMElement $domNode)
/**
* Read w:tblPr
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return string|array|null
* @todo Capture w:tblStylePr w:type="firstRow"
Expand Down Expand Up @@ -509,7 +509,7 @@ protected function readTableStyle(XMLReader $xmlReader, \DOMElement $domNode)
/**
* Read w:tblpPr
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return array
*/
Expand All @@ -534,7 +534,7 @@ private function readTablePosition(XMLReader $xmlReader, \DOMElement $domNode)
/**
* Read w:tblInd
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return TblWidthComplexType
*/
Expand All @@ -552,7 +552,7 @@ private function readTableIndent(XMLReader $xmlReader, \DOMElement $domNode)
/**
* Read w:tcPr
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @return array
*/
Expand Down Expand Up @@ -620,7 +620,7 @@ private function findPossibleAttribute(XMLReader $xmlReader, \DOMElement $node,
/**
* Read style definition
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $parentNode
* @param array $styleDefs
* @ignoreScrutinizerPatch
Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Reader/Word2007/DocPropsCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

namespace PhpOffice\PhpWord\Reader\Word2007;

use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLReader;

/**
* Core properties reader
Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Reader/Word2007/DocPropsCustom.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

namespace PhpOffice\PhpWord\Reader\Word2007;

use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\Metadata\DocInfo;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLReader;

/**
* Custom properties reader
Expand Down
8 changes: 4 additions & 4 deletions src/PhpWord/Reader/Word2007/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

namespace PhpOffice\PhpWord\Reader\Word2007;

use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\Element\Section;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLReader;

/**
* Document reader
Expand Down Expand Up @@ -97,7 +97,7 @@ private function readHeaderFooter($settings, Section &$section)
/**
* Read w:sectPr
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $domNode
* @ignoreScrutinizerPatch
* @return array
Expand Down Expand Up @@ -141,7 +141,7 @@ private function readSectionStyle(XMLReader $xmlReader, \DOMElement $domNode)
/**
* Read w:p node.
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $node
* @param \PhpOffice\PhpWord\Element\Section &$section
*
Expand Down Expand Up @@ -170,7 +170,7 @@ private function readWPNode(XMLReader $xmlReader, \DOMElement $node, Section &$s
/**
* Read w:sectPr node.
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \PhpOffice\PhpWord\Shared\XMLReader $xmlReader
* @param \DOMElement $node
* @param \PhpOffice\PhpWord\Element\Section &$section
*/
Expand Down
2 changes: 1 addition & 1 deletion src/PhpWord/Reader/Word2007/Footnotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

namespace PhpOffice\PhpWord\Reader\Word2007;

use PhpOffice\Common\XMLReader;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\Shared\XMLReader;

/**
* Footnotes reader
Expand Down
Loading

0 comments on commit 06c8248

Please sign in to comment.