diff --git a/CHANGELOG.md b/CHANGELOG.md index 845629ea..5c311f94 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ This release marked the transformation to namespaces (PHP 5.3+). ### Features -None yet +None yet. ### Bugfixes @@ -16,7 +16,11 @@ None yet ### Miscellaneous -- Documentation - @Progi1984 +- Move documentation to [Read The Docs](http://phpword.readthedocs.org/en/develop/) - @Progi1984 @ivanlanin GH-82 +- Reorganize and redesign samples folder - @ivanlanin GH-137 +- Use `PhpOffice\PhpWord` namespace for PSR compliance - @RomanSyroeshko @gabrielbull GH-159 GH-58 +- Restructure folders and change folder name `Classes` to `src` and `Tests` to `test` for PSR compliance - @RomanSyroeshko @gabrielbull +- Compliance to phpDocumentor - @ivanlanin ## 0.8.1 - 17 Mar 2014 diff --git a/docs/setup.rst b/docs/setup.rst index 10664b83..c773756f 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -47,11 +47,13 @@ Manual install To install manually, `download PHPWord package from github `__. Extract the package and put the contents to your machine. To use the -library, include ``src/PhpWord/PhpWord.php`` in your script like below. +library, include ``src/PhpWord/Autoloader.php`` in your script and +invoke ``Autoloader::register``. .. code-block:: php - require_once '/path/to/src/PhpWord/PhpWord.php'; + require_once '/path/to/src/PhpWord/Autoloader.php'; + PhpOffice\PhpWord\Autoloader::register(); Using samples ------------- diff --git a/samples/Sample_07_TemplateCloneRow.php b/samples/Sample_07_TemplateCloneRow.php index addde363..4344fafc 100755 --- a/samples/Sample_07_TemplateCloneRow.php +++ b/samples/Sample_07_TemplateCloneRow.php @@ -53,7 +53,7 @@ $document->setValue('userFirstName#3', 'Michael'); $document->setValue('userName#3', 'Ray'); $document->setValue('userPhone#3', '+1 428 889 775'); -$name = 'Sample_07_TemplateCloneRow_result.docx'; +$name = 'Sample_07_TemplateCloneRow.docx'; echo date('H:i:s'), " Write to Word2007 format", \EOL; $document->saveAs($name); rename($name, "results/{$name}"); diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index 5fcb383d..28ae61e7 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -5,7 +5,10 @@ error_reporting(E_ALL); define('CLI', (PHP_SAPI == 'cli') ? true : false); define('EOL', CLI ? PHP_EOL : '
'); -require_once '../src/PhpWord/PhpWord.php'; + +require_once '../src/PhpWord/Autoloader.php'; +PhpOffice\PhpWord\Autoloader::register(); + // Return to the caller script when runs by CLI if (CLI) { return; diff --git a/src/PhpWord/Autoloader.php b/src/PhpWord/Autoloader.php index b2012f9f..7b34eb75 100644 --- a/src/PhpWord/Autoloader.php +++ b/src/PhpWord/Autoloader.php @@ -25,11 +25,16 @@ namespace PhpOffice\PhpWord; +/** + * Autoloader + */ class Autoloader { const NAMESPACE_PREFIX = 'PhpOffice\\PhpWord\\'; /** + * Register + * * @return void */ public static function register() @@ -38,6 +43,8 @@ class Autoloader } /** + * Autoload + * * @param string $class */ public static function autoload($class) @@ -51,4 +58,4 @@ class Autoloader } } } -} \ No newline at end of file +} diff --git a/src/PhpWord/DocumentProperties.php b/src/PhpWord/DocumentProperties.php index 6dc31608..2d8a6cb0 100644 --- a/src/PhpWord/DocumentProperties.php +++ b/src/PhpWord/DocumentProperties.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord; +/** + * Document properties + */ class DocumentProperties { /** Constants */ diff --git a/src/PhpWord/Exceptions/Exception.php b/src/PhpWord/Exceptions/Exception.php index 917e5d16..b2b2fcf1 100755 --- a/src/PhpWord/Exceptions/Exception.php +++ b/src/PhpWord/Exceptions/Exception.php @@ -26,6 +26,9 @@ */ namespace PhpOffice\PhpWord\Exceptions; +/** + * General exception + */ class Exception extends \Exception { } diff --git a/src/PhpWord/Footnote.php b/src/PhpWord/Footnote.php index 539f7e47..943bedec 100644 --- a/src/PhpWord/Footnote.php +++ b/src/PhpWord/Footnote.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord; +/** + * Footnote + */ class Footnote { /** diff --git a/src/PhpWord/HashTable.php b/src/PhpWord/HashTable.php index a9589ce8..88bf40ba 100644 --- a/src/PhpWord/HashTable.php +++ b/src/PhpWord/HashTable.php @@ -28,6 +28,8 @@ namespace PhpOffice\PhpWord; use PhpOffice\PhpWord\Exceptions\Exception; /** + * Hash table + * * @codeCoverageIgnore Legacy from PHPExcel */ class HashTable @@ -47,6 +49,8 @@ class HashTable public $_keyMap = array(); /** + * Create new + * * @param \PhpOffice\PhpWord\IComparable[] $pSource Optional source array to create HashTable from */ public function __construct($pSource = null) @@ -140,6 +144,8 @@ class HashTable } /** + * Get item count + * * @return int */ public function count() @@ -148,6 +154,8 @@ class HashTable } /** + * Get hash code index + * * @param string $pHashCode * @return int Index */ @@ -157,6 +165,8 @@ class HashTable } /** + * Get by index + * * @param int $pIndex * @return \PhpOffice\PhpWord\IComparable */ @@ -170,6 +180,7 @@ class HashTable } /** + * Get by hashcode * @param string $pHashCode * @return \PhpOffice\PhpWord\IComparable * @@ -184,6 +195,8 @@ class HashTable } /** + * Convert to array + * * @return \PhpOffice\PhpWord\IComparable[] */ public function toArray() diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php index 261f6afe..1a9e98e9 100644 --- a/src/PhpWord/IOFactory.php +++ b/src/PhpWord/IOFactory.php @@ -27,9 +27,14 @@ namespace PhpOffice\PhpWord; use PhpOffice\PhpWord\Exceptions\Exception; +/** + * IO factory + */ abstract class IOFactory { /** + * Create new writer + * * @param \PhpOffice\PhpWord\PhpWord $phpWord * @param string $name * @return \PhpOffice\PhpWord\Writer\IWriter @@ -46,6 +51,8 @@ abstract class IOFactory } /** + * Create new reader + * * @param string $name * @return \PhpOffice\PhpWord\Reader\IReader * @throws \PhpOffice\PhpWord\Exceptions\Exception diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php index f7954df3..5a91bb08 100755 --- a/src/PhpWord/Media.php +++ b/src/PhpWord/Media.php @@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord; use PhpOffice\PhpWord\Section\MemoryImage; +/** + * Media + */ class Media { /** diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 78002a9d..fb21f42c 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -31,6 +31,9 @@ use PhpOffice\PhpWord\Section; use PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Template; +/** + * PhpWord main class + */ class PhpWord { const DEFAULT_FONT_COLOR = '000000'; // HEX @@ -45,25 +48,35 @@ class PhpWord const DEFAULT_FONT_SIZE = 10; /** + * Document properties object + * * @var \PhpOffice\PhpWord\DocumentProperties */ private $_documentProperties; /** + * Default font name + * * @var string */ private $_defaultFontName; /** + * Default font size * @var int */ private $_defaultFontSize; /** + * Collection of sections + * * @var \PhpOffice\PhpWord\Section[] */ private $_sections = array(); + /** + * Create new + */ public function __construct() { $this->_documentProperties = new DocumentProperties(); @@ -72,6 +85,8 @@ class PhpWord } /** + * Get document properties object + * * @return \PhpOffice\PhpWord\DocumentProperties */ public function getDocumentProperties() @@ -80,6 +95,8 @@ class PhpWord } /** + * Set document properties object + * * @param \PhpOffice\PhpWord\DocumentProperties $documentProperties * @return \PhpOffice\PhpWord\PhpWord */ @@ -91,6 +108,8 @@ class PhpWord } /** + * Create new section + * * @param \PhpOffice\PhpWord\Section\Settings $settings * @return \PhpOffice\PhpWord\Section */ @@ -103,6 +122,8 @@ class PhpWord } /** + * Get default font name + * * @return string */ public function getDefaultFontName() @@ -111,6 +132,8 @@ class PhpWord } /** + * Set default font name + * * @param string $fontName */ public function setDefaultFontName($fontName) @@ -119,6 +142,8 @@ class PhpWord } /** + * Get default font size + * * @return string */ public function getDefaultFontSize() @@ -127,6 +152,8 @@ class PhpWord } /** + * Set default font size + * * @param int $fontSize */ public function setDefaultFontSize($fontSize) @@ -159,7 +186,8 @@ class PhpWord * Adds a font style definition to styles.xml * * @param $styleName string - * @param $styles array + * @param mixed $styleFont + * @param mixed $styleParagraph */ public function addFontStyle($styleName, $styleFont, $styleParagraph = null) { @@ -169,8 +197,9 @@ class PhpWord /** * Adds a table style definition to styles.xml * - * @param $styleName string - * @param $styles array + * @param string $styleName + * @param mixed $styleTable + * @param mixed $styleFirstRow */ public function addTableStyle($styleName, $styleTable, $styleFirstRow = null) { @@ -180,8 +209,9 @@ class PhpWord /** * Adds a heading style definition to styles.xml * - * @param $titleCount int - * @param $styles array + * @param int $titleCount + * @param mixed $styleFont + * @param mixed $styleParagraph */ public function addTitleStyle($titleCount, $styleFont, $styleParagraph = null) { @@ -191,8 +221,8 @@ class PhpWord /** * Adds a hyperlink style to styles.xml * - * @param $styleName string - * @param $styles array + * @param string $styleName + * @param mixed $styles */ public function addLinkStyle($styleName, $styles) { @@ -200,6 +230,8 @@ class PhpWord } /** + * Get all sections + * * @return \PhpOffice\PhpWord\Section[] */ public function getSections() @@ -208,6 +240,8 @@ class PhpWord } /** + * Load template by filename + * * @param string $filename Fully qualified filename. * @return \PhpOffice\PhpWord\Template * @throws \PhpOffice\PhpWord\Exceptions\Exception diff --git a/src/PhpWord/Reader/AbstractReader.php b/src/PhpWord/Reader/AbstractReader.php index af67337d..aec91825 100644 --- a/src/PhpWord/Reader/AbstractReader.php +++ b/src/PhpWord/Reader/AbstractReader.php @@ -28,6 +28,8 @@ namespace PhpOffice\PhpWord\Reader; use PhpOffice\PhpWord\Exceptions\Exception; /** + * Reader abstract class + * * @codeCoverageIgnore Abstract class */ abstract class AbstractReader implements IReader @@ -79,7 +81,7 @@ abstract class AbstractReader implements IReader protected function openFile($pFilename) { // Check if file exists - if (!file_exists($pFilename) || !is_readable($pFilename)) { + if (!\file_exists($pFilename) || !is_readable($pFilename)) { throw new Exception("Could not open " . $pFilename . " for reading! File does not exist."); } diff --git a/src/PhpWord/Reader/IReader.php b/src/PhpWord/Reader/IReader.php index f29d71d4..a6ee5b95 100644 --- a/src/PhpWord/Reader/IReader.php +++ b/src/PhpWord/Reader/IReader.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Reader; +/** + * Reader interface + */ interface IReader { /** diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php index 645ba56c..4eca69db 100644 --- a/src/PhpWord/Reader/Word2007.php +++ b/src/PhpWord/Reader/Word2007.php @@ -30,6 +30,9 @@ use PhpOffice\PhpWord\DocumentProperties; use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Shared\File; +/** + * Reader for Word2007 + */ class Word2007 extends AbstractReader implements IReader { /** @@ -42,7 +45,7 @@ class Word2007 extends AbstractReader implements IReader public function canRead($pFilename) { // Check if file exists - if (!file_exists($pFilename)) { + if (!\file_exists($pFilename)) { throw new Exception("Could not open {$pFilename} for reading! File does not exist."); } @@ -71,6 +74,8 @@ class Word2007 extends AbstractReader implements IReader } /** + * Get zip content + * * @param \ZipArchive $archive * @param string $fileName * @param bool $removeNamespace @@ -434,6 +439,8 @@ class Word2007 extends AbstractReader implements IReader } /** + * Return item of array + * * @param array $array * @param mixed $key * @return mixed|null diff --git a/src/PhpWord/Section.php b/src/PhpWord/Section.php index 2f7212ad..68154915 100644 --- a/src/PhpWord/Section.php +++ b/src/PhpWord/Section.php @@ -42,6 +42,9 @@ use PhpOffice\PhpWord\Section\TextRun; use PhpOffice\PhpWord\Section\Title; use PhpOffice\PhpWord\Shared\String; +/** + * Section + */ class Section { /** @@ -241,7 +244,7 @@ class Section } $iconSrc = __DIR__ . '/_staticDocParts/'; - if (!file_exists($iconSrc . '_' . $ext . '.png')) { + if (!\file_exists($iconSrc . '_' . $ext . '.png')) { $iconSrc = $iconSrc . '_default.png'; } else { $iconSrc .= '_' . $ext . '.png'; @@ -425,6 +428,8 @@ class Section } /** + * Get footer element + * * @return \PhpOffice\PhpWord\Section\Footer */ public function getFooter() diff --git a/src/PhpWord/Section/Footer.php b/src/PhpWord/Section/Footer.php index 13b097e6..a9800722 100755 --- a/src/PhpWord/Section/Footer.php +++ b/src/PhpWord/Section/Footer.php @@ -30,6 +30,9 @@ use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Section\Footer\PreserveText; use PhpOffice\PhpWord\Shared\String; +/** + * Footer element + */ class Footer { /** @@ -55,6 +58,8 @@ class Footer /** * Create a new Footer + * + * @param int $sectionCount */ public function __construct($sectionCount) { @@ -96,6 +101,7 @@ class Footer /** * Create a new TextRun * + * @param mixed $styleParagraph * @return \PhpOffice\PhpWord\Section\TextRun */ public function createTextRun($styleParagraph = null) diff --git a/src/PhpWord/Section/Footer/PreserveText.php b/src/PhpWord/Section/Footer/PreserveText.php index c83d38ec..91079d86 100644 --- a/src/PhpWord/Section/Footer/PreserveText.php +++ b/src/PhpWord/Section/Footer/PreserveText.php @@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section\Footer; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; +/** + * Preserve text/field element + */ class PreserveText { /** diff --git a/src/PhpWord/Section/Footnote.php b/src/PhpWord/Section/Footnote.php index 2a9eacaf..41976167 100644 --- a/src/PhpWord/Section/Footnote.php +++ b/src/PhpWord/Section/Footnote.php @@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Section; use PhpOffice\PhpWord\Style\Paragraph; +/** + * Footnote element + */ class Footnote { /** @@ -52,6 +55,8 @@ class Footnote /** * Create a new Footnote Element + * + * @param mixed $styleParagraph */ public function __construct($styleParagraph = null) { @@ -76,8 +81,8 @@ class Footnote /** * Add a Text Element * - * @var string $text - * @var mixed $styleFont + * @param string $text + * @param mixed $styleFont * @return \PhpOffice\PhpWord\Section\Text */ public function addText($text = null, $styleFont = null) @@ -118,6 +123,8 @@ class Footnote } /** + * Get paragraph style + * * @return \PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() diff --git a/src/PhpWord/Section/Header.php b/src/PhpWord/Section/Header.php index 9c357670..6f407934 100755 --- a/src/PhpWord/Section/Header.php +++ b/src/PhpWord/Section/Header.php @@ -30,6 +30,9 @@ use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Section\Footer\PreserveText; use PhpOffice\PhpWord\Shared\String; +/** + * Header element + */ class Header { /** @@ -84,6 +87,8 @@ class Header /** * Create a new Header + * + * @param int $sectionCount */ public function __construct($sectionCount) { @@ -125,6 +130,7 @@ class Header /** * Create a new TextRun * + * @param mixed $styleParagraph * @return \PhpOffice\PhpWord\Section\TextRun */ public function createTextRun($styleParagraph = null) diff --git a/src/PhpWord/Section/Image.php b/src/PhpWord/Section/Image.php index 2c041253..dfe38abd 100755 --- a/src/PhpWord/Section/Image.php +++ b/src/PhpWord/Section/Image.php @@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section; use PhpOffice\PhpWord\Exceptions\InvalidImageException; use PhpOffice\PhpWord\Exceptions\UnsupportedImageTypeException; +/** + * Image element + */ class Image { /** @@ -72,7 +75,7 @@ class Image { $supportedImageTypes = array(\IMAGETYPE_JPEG, \IMAGETYPE_GIF, \IMAGETYPE_PNG, \IMAGETYPE_BMP, \IMAGETYPE_TIFF_II, \IMAGETYPE_TIFF_MM); - if (!file_exists($src)) { + if (!\file_exists($src)) { throw new InvalidImageException; } diff --git a/src/PhpWord/Section/Link.php b/src/PhpWord/Section/Link.php index bc1b9e8e..f05c14fb 100644 --- a/src/PhpWord/Section/Link.php +++ b/src/PhpWord/Section/Link.php @@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; +/** + * Link element + */ class Link { /** diff --git a/src/PhpWord/Section/ListItem.php b/src/PhpWord/Section/ListItem.php index 8b8afc42..b4b25178 100644 --- a/src/PhpWord/Section/ListItem.php +++ b/src/PhpWord/Section/ListItem.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Section; +/** + * List item element + */ class ListItem { /** diff --git a/src/PhpWord/Section/MemoryImage.php b/src/PhpWord/Section/MemoryImage.php index 89e867ac..4fce71f0 100644 --- a/src/PhpWord/Section/MemoryImage.php +++ b/src/PhpWord/Section/MemoryImage.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Section; +/** + * Memory image element + */ class MemoryImage { /** diff --git a/src/PhpWord/Section/Object.php b/src/PhpWord/Section/Object.php index 3a678497..a8e705a0 100644 --- a/src/PhpWord/Section/Object.php +++ b/src/PhpWord/Section/Object.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Section; +/** + * Object element + */ class Object { /** @@ -74,7 +77,7 @@ class Object $_supportedObjectTypes = array('xls', 'doc', 'ppt'); $inf = pathinfo($src); - if (file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) { + if (\file_exists($src) && in_array($inf['extension'], $_supportedObjectTypes)) { $this->_src = $src; $this->_style = new \PhpOffice\PhpWord\Style\Image(); diff --git a/src/PhpWord/Section/PageBreak.php b/src/PhpWord/Section/PageBreak.php index e97d4b40..1aad4f26 100644 --- a/src/PhpWord/Section/PageBreak.php +++ b/src/PhpWord/Section/PageBreak.php @@ -25,8 +25,14 @@ namespace PhpOffice\PhpWord\Section; +/** + * Page break element + */ class PageBreak { + /** + * Create new page break + */ public function __construct() { } diff --git a/src/PhpWord/Section/Settings.php b/src/PhpWord/Section/Settings.php index 9e080e87..a41e9d24 100644 --- a/src/PhpWord/Section/Settings.php +++ b/src/PhpWord/Section/Settings.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Section; +/** + * Section settings + */ class Settings { /** diff --git a/src/PhpWord/Section/Table.php b/src/PhpWord/Section/Table.php index 4fda6ba5..000d6568 100644 --- a/src/PhpWord/Section/Table.php +++ b/src/PhpWord/Section/Table.php @@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Section; use PhpOffice\PhpWord\Section\Table\Row; +/** + * Table element + */ class Table { /** diff --git a/src/PhpWord/Section/Table/Cell.php b/src/PhpWord/Section/Table/Cell.php index dc435e86..46e9da4f 100755 --- a/src/PhpWord/Section/Table/Cell.php +++ b/src/PhpWord/Section/Table/Cell.php @@ -38,6 +38,9 @@ use PhpOffice\PhpWord\Section\TextBreak; use PhpOffice\PhpWord\Section\TextRun; use PhpOffice\PhpWord\Shared\String; +/** + * Table cell element + */ class Cell { /** @@ -109,7 +112,8 @@ class Cell * Add a Text Element * * @param string $text - * @param mixed $style + * @param mixed $styleFont + * @param mixed $styleParagraph * @return \PhpOffice\PhpWord\Section\Text */ public function addText($text, $styleFont = null, $styleParagraph = null) @@ -261,7 +265,7 @@ class Cell } $iconSrc = __DIR__ . '/../../_staticDocParts/'; - if (!file_exists($iconSrc . '_' . $ext . '.png')) { + if (!\file_exists($iconSrc . '_' . $ext . '.png')) { $iconSrc = $iconSrc . '_default.png'; } else { $iconSrc .= '_' . $ext . '.png'; @@ -308,6 +312,7 @@ class Cell /** * Create a new TextRun * + * @param mixed $styleParagraph * @return \PhpOffice\PhpWord\Section\TextRun */ public function createTextRun($styleParagraph = null) diff --git a/src/PhpWord/Section/Table/Row.php b/src/PhpWord/Section/Table/Row.php index b9092295..e2a59bc0 100644 --- a/src/PhpWord/Section/Table/Row.php +++ b/src/PhpWord/Section/Table/Row.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Section\Table; +/** + * Table row element + */ class Row { /** diff --git a/src/PhpWord/Section/Text.php b/src/PhpWord/Section/Text.php index 46edf34e..50d76758 100644 --- a/src/PhpWord/Section/Text.php +++ b/src/PhpWord/Section/Text.php @@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; +/** + * Text element + */ class Text { /** diff --git a/src/PhpWord/Section/TextBreak.php b/src/PhpWord/Section/TextBreak.php index 39934303..3ea06b55 100755 --- a/src/PhpWord/Section/TextBreak.php +++ b/src/PhpWord/Section/TextBreak.php @@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Section; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; +/** + * Text break element + */ class TextBreak { /** @@ -46,6 +49,9 @@ class TextBreak /** * Create a new TextBreak Element + * + * @param mixed $fontStyle + * @param mixed $paragraphStyle */ public function __construct($fontStyle = null, $paragraphStyle = null) { diff --git a/src/PhpWord/Section/TextRun.php b/src/PhpWord/Section/TextRun.php index 0320d30c..0fe25af2 100755 --- a/src/PhpWord/Section/TextRun.php +++ b/src/PhpWord/Section/TextRun.php @@ -30,6 +30,9 @@ use PhpOffice\PhpWord\Media; use PhpOffice\PhpWord\Shared\String; use PhpOffice\PhpWord\Style\Paragraph; +/** + * Textrun/paragraph element + */ class TextRun { /** @@ -49,6 +52,8 @@ class TextRun /** * Create a new TextRun Element + * + * @param mixed $styleParagraph */ public function __construct($styleParagraph = null) { @@ -73,8 +78,8 @@ class TextRun /** * Add a Text Element * - * @var string $text - * @var mixed $styleFont + * @param string $text + * @param mixed $styleFont * @return \PhpOffice\PhpWord\Section\Text */ public function addText($text = null, $styleFont = null) @@ -114,7 +119,7 @@ class TextRun * Add a Image Element * * @param string $imageSrc - * @param mixed $styleFont + * @param mixed $style * @return \PhpOffice\PhpWord\Section\Image */ public function addImage($imageSrc, $style = null) @@ -149,7 +154,7 @@ class TextRun /** * Create a new Footnote Element * - * @param string $text + * @param mixed $styleParagraph * @return \PhpOffice\PhpWord\Section\Footnote */ public function createFootnote($styleParagraph = null) diff --git a/src/PhpWord/Section/Title.php b/src/PhpWord/Section/Title.php index 9e71e463..f292cfa3 100644 --- a/src/PhpWord/Section/Title.php +++ b/src/PhpWord/Section/Title.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Section; +/** + * Title element + */ class Title { /** diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php index 1ab7ba12..e7da4251 100644 --- a/src/PhpWord/Settings.php +++ b/src/PhpWord/Settings.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord; +/** + * Settings + */ class Settings { /** diff --git a/src/PhpWord/Shared/Drawing.php b/src/PhpWord/Shared/Drawing.php index 16a363ac..5f742457 100644 --- a/src/PhpWord/Shared/Drawing.php +++ b/src/PhpWord/Shared/Drawing.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Shared; +/** + * Common drawing functions + */ class Drawing { /** diff --git a/src/PhpWord/Shared/File.php b/src/PhpWord/Shared/File.php index e7385241..90309a1b 100755 --- a/src/PhpWord/Shared/File.php +++ b/src/PhpWord/Shared/File.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Shared; +/** + * Common file functions + */ class File { /** @@ -33,10 +36,10 @@ class File * @param string $pFilename Filename * @return bool */ - public static function file_exists($pFilename) + public static function fileExists($pFilename) { // Regular file_exists - return file_exists($pFilename); + return \file_exists($pFilename); } /** diff --git a/src/PhpWord/Shared/Font.php b/src/PhpWord/Shared/Font.php index e3d6eb60..90bef1d1 100644 --- a/src/PhpWord/Shared/Font.php +++ b/src/PhpWord/Shared/Font.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Shared; +/** + * Common font functions + */ class Font { /** diff --git a/src/PhpWord/Shared/String.php b/src/PhpWord/Shared/String.php index 6344b580..eb4d60ea 100644 --- a/src/PhpWord/Shared/String.php +++ b/src/PhpWord/Shared/String.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Shared; +/** + * Common string functions + */ class String { /** diff --git a/src/PhpWord/Shared/XMLWriter.php b/src/PhpWord/Shared/XMLWriter.php index 901e5471..d9f392bf 100644 --- a/src/PhpWord/Shared/XMLWriter.php +++ b/src/PhpWord/Shared/XMLWriter.php @@ -32,6 +32,8 @@ if (!defined('DATE_W3C')) { } /** + * XMLWriter wrapper + * * @method bool startElement(string $name) * @method bool writeAttribute(string $name, string $value) * @method bool endElement() @@ -57,6 +59,8 @@ class XMLWriter private $_tempFileName = ''; /** + * Create new XMLWriter + * * @param int $pTemporaryStorage Temporary storage location * @param string $pTemporaryStorageFolder Temporary storage folder */ diff --git a/src/PhpWord/Shared/ZipStreamWrapper.php b/src/PhpWord/Shared/ZipStreamWrapper.php index a9339570..63c87986 100644 --- a/src/PhpWord/Shared/ZipStreamWrapper.php +++ b/src/PhpWord/Shared/ZipStreamWrapper.php @@ -28,6 +28,8 @@ namespace PhpOffice\PhpWord\Shared; use PhpOffice\PhpWord\Exceptions\Exception; /** + * Zip stream wrapper + * * @codeCoverageIgnore Legacy from PHPExcel */ class ZipStreamWrapper @@ -77,7 +79,7 @@ class ZipStreamWrapper * @param string $options * @param string $opened_path */ - public function stream_open($path, $mode, $options, &$opened_path) + public function streamOpen($path, $mode, $options, &$opened_path) { // Check for mode if ($mode{0} != 'r') { @@ -117,7 +119,7 @@ class ZipStreamWrapper /** * Stat stream */ - public function stream_stat() + public function streamStat() { return $this->_archive->statName($this->_fileNameInArchive); } @@ -127,7 +129,7 @@ class ZipStreamWrapper * * @param int $count */ - public function stream_read($count) + public function streamRead($count) { $ret = substr($this->_data, $this->_position, $count); $this->_position += strlen($ret); @@ -137,7 +139,7 @@ class ZipStreamWrapper /** * Tell stream */ - public function stream_tell() + public function streamTell() { return $this->_position; } @@ -145,7 +147,7 @@ class ZipStreamWrapper /** * EOF stream */ - public function stream_eof() + public function streamEof() { return $this->_position >= strlen($this->_data); } @@ -156,7 +158,7 @@ class ZipStreamWrapper * @param int $offset * @param mixed $whence */ - public function stream_seek($offset, $whence) + public function streamSeek($offset, $whence) { switch ($whence) { case \SEEK_SET: diff --git a/src/PhpWord/Style.php b/src/PhpWord/Style.php index 8758a767..d44a14eb 100755 --- a/src/PhpWord/Style.php +++ b/src/PhpWord/Style.php @@ -29,14 +29,21 @@ use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\TableFull; +/** + * Style + */ class Style { /** + * Style register + * * @var array */ private static $_styleElements = array(); /** + * Add paragraph style + * * @param string $styleName * @param array $styles */ @@ -56,6 +63,8 @@ class Style } /** + * Add font style + * * @param string $styleName * @param array $styleFont * @param array $styleParagraph @@ -75,6 +84,8 @@ class Style } /** + * Add link style + * * @param string $styleName * @param array $styles */ @@ -94,8 +105,11 @@ class Style } /** + * Add table style + * * @param string $styleName - * @param array $styles + * @param array $styleTable + * @param array $styleFirstRow */ public static function addTableStyle($styleName, $styleTable, $styleFirstRow = null) { @@ -107,7 +121,9 @@ class Style } /** - * @param string $styleName + * Add title style + * + * @param int $titleCount * @param array $styleFont * @param array $styleParagraph */ @@ -128,6 +144,8 @@ class Style } /** + * Set default paragraph style + * * @param array $styles Paragraph style definition */ public static function setDefaultParagraphStyle($styles) @@ -146,7 +164,9 @@ class Style } /** - * @param string + * Get style by name + * + * @param string $styleName */ public static function getStyle($styleName) { diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php index 2ae3cf8a..25f58845 100644 --- a/src/PhpWord/Style/Cell.php +++ b/src/PhpWord/Style/Cell.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Style; +/** + * Table cell style + */ class Cell { const TEXT_DIR_BTLR = 'btLr'; diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php index b5b98bc1..0a5b7408 100644 --- a/src/PhpWord/Style/Font.php +++ b/src/PhpWord/Style/Font.php @@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Exceptions\InvalidStyleException; +/** + * Font style + */ class Font { const UNDERLINE_NONE = 'none'; @@ -72,6 +75,8 @@ class Font private $_type; /** + * Paragraph style + * * @var \PhpOffice\PhpWord\Style\Paragraph */ private $_paragraphStyle; @@ -91,31 +96,43 @@ class Font private $_size = PhpWord::DEFAULT_FONT_SIZE; /** + * Bold + * * @var bool */ private $_bold = false; /** + * Italic + * * @var bool */ private $_italic = false; /** + * Superscript + * * @var bool */ private $_superScript = false; /** + * Subscript + * * @var bool */ private $_subScript = false; /** + * Undeline + * * @var string */ private $_underline = self::UNDERLINE_NONE; /** + * Strikethrough + * * @var bool */ private $_strikethrough = false; @@ -149,6 +166,8 @@ class Font private $_hint = PhpWord::DEFAULT_FONT_CONTENT_TYPE; /** + * Create new font style + * * @param string $type Type of font * @param array $paragraphStyle Paragraph styles definition */ @@ -188,6 +207,8 @@ class Font } /** + * Set style value + * * @param string $key * @param mixed $value */ @@ -251,6 +272,8 @@ class Font } /** + * Get bold + * * @return bool */ public function getBold() @@ -259,6 +282,8 @@ class Font } /** + * Set bold + * * @param bool $pValue * @return \PhpOffice\PhpWord\Style\Font */ @@ -272,6 +297,8 @@ class Font } /** + * Get italic + * * @return bool */ public function getItalic() @@ -280,6 +307,8 @@ class Font } /** + * Set italic + * * @param bool $pValue * @return \PhpOffice\PhpWord\Style\Font */ @@ -293,6 +322,8 @@ class Font } /** + * Get superscript + * * @return bool */ public function getSuperScript() @@ -301,6 +332,8 @@ class Font } /** + * Set superscript + * * @param bool $pValue * @return \PhpOffice\PhpWord\Style\Font */ @@ -315,6 +348,8 @@ class Font } /** + * Get subscript + * * @return bool */ public function getSubScript() @@ -323,6 +358,8 @@ class Font } /** + * Set subscript + * * @param bool $pValue * @return \PhpOffice\PhpWord\Style\Font */ @@ -337,6 +374,8 @@ class Font } /** + * Get underline + * * @return string */ public function getUnderline() @@ -345,6 +384,8 @@ class Font } /** + * Set underline + * * @param string $pValue * @return \PhpOffice\PhpWord\Style\Font */ @@ -358,6 +399,8 @@ class Font } /** + * Get strikethrough + * * @return bool */ public function getStrikethrough() @@ -366,6 +409,8 @@ class Font } /** + * Set strikethrough + * * @param bool $pValue * @return \PhpOffice\PhpWord\Style\Font */ @@ -389,6 +434,8 @@ class Font } /** + * Set font color + * * @param string $pValue * @return \PhpOffice\PhpWord\Style\Font */ @@ -424,6 +471,8 @@ class Font } /** + * Get style type + * * @return string */ public function getStyleType() @@ -432,6 +481,8 @@ class Font } /** + * Get paragraph style + * * @return \PhpOffice\PhpWord\Style\Paragraph */ public function getParagraphStyle() @@ -440,6 +491,8 @@ class Font } /** + * Set lineheight + * * @param int|float|string $lineHeight * @return $this * @throws \PhpOffice\PhpWord\Exceptions\InvalidStyleException diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php index 5db9446c..698e42a3 100644 --- a/src/PhpWord/Style/Image.php +++ b/src/PhpWord/Style/Image.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Style; +/** + * Image and memory image style + */ class Image { const WRAPPING_STYLE_INLINE = 'inline'; @@ -76,7 +79,7 @@ class Image private $_marginLeft; /** - * Constructor + * Create new image style */ public function __construct() { diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php index d0d6c750..8e09ac83 100644 --- a/src/PhpWord/Style/ListItem.php +++ b/src/PhpWord/Style/ListItem.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Style; +/** + * List item style + */ class ListItem { const TYPE_NUMBER = 7; diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php index b4d9006f..d6f4d4ef 100755 --- a/src/PhpWord/Style/Paragraph.php +++ b/src/PhpWord/Style/Paragraph.php @@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Exceptions\InvalidStyleException; +/** + * Paragraph style + */ class Paragraph { const LINE_HEIGHT = 240; @@ -130,6 +133,8 @@ class Paragraph private $_pageBreakBefore = false; /** + * Set style by array + * * @param array $style * @return $this */ @@ -316,11 +321,11 @@ class Paragraph return $this->_tabs; } - /* + /** * Set tabs * - * @param array $pValue - * @return \PhpOffice\PhpWord\Style\Paragraph + * @param array $pValue + * @return \PhpOffice\PhpWord\Style\Paragraph */ public function setTabs($pValue = null) { @@ -497,6 +502,8 @@ class Paragraph } /** + * Get line height + * * @return int|float */ public function getLineHeight() diff --git a/src/PhpWord/Style/Row.php b/src/PhpWord/Style/Row.php index e039ee5e..25c5a6e7 100644 --- a/src/PhpWord/Style/Row.php +++ b/src/PhpWord/Style/Row.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Style; +/** + * Table row style + */ class Row { /** diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php index dac60b40..b0e3e2e3 100644 --- a/src/PhpWord/Style/TOC.php +++ b/src/PhpWord/Style/TOC.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Style; +/** + * TOC style + */ class TOC { const TABLEADER_DOT = 'dot'; diff --git a/src/PhpWord/Style/Tab.php b/src/PhpWord/Style/Tab.php index d55e914a..25a88a39 100644 --- a/src/PhpWord/Style/Tab.php +++ b/src/PhpWord/Style/Tab.php @@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Shared\XMLWriter; +/** + * Tab style + */ class Tab { /** diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php index 15c766d2..0b4f33d2 100755 --- a/src/PhpWord/Style/Table.php +++ b/src/PhpWord/Style/Table.php @@ -25,13 +25,42 @@ namespace PhpOffice\PhpWord\Style; +/** + * Table style + */ class Table { - private $_cellMarginTop; - private $_cellMarginLeft; - private $_cellMarginRight; - private $_cellMarginBottom; + /** + * Cell margin top + * + * @var int + */ + private $_cellMarginTop = null; + /** + * Cell margin left + * + * @var int + */ + private $_cellMarginLeft = null; + + /** + * Cell margin right + * + * @var int + */ + private $_cellMarginRight = null; + + /** + * Cell margin bottom + * + * @var int + */ + private $_cellMarginBottom = null; + + /** + * Create new table style + */ public function __construct() { $this->_cellMarginTop = null; @@ -40,51 +69,115 @@ class Table $this->_cellMarginBottom = null; } + /** + * Set style value + * + * @param string $key + * @param mixed $value + */ public function setStyleValue($key, $value) { $this->$key = $value; } + /** + * Set cell margin top + * + * @param int $pValue + */ public function setCellMarginTop($pValue = null) { $this->_cellMarginTop = $pValue; } + /** + * Get cell margin top + * + * @return int + */ public function getCellMarginTop() { return $this->_cellMarginTop; } + /** + * Set cell margin left + * + * @param int $pValue + */ public function setCellMarginLeft($pValue = null) { $this->_cellMarginLeft = $pValue; } + /** + * Get cell margin left + * + * @return int + */ public function getCellMarginLeft() { return $this->_cellMarginLeft; } + /** + * Set cell margin right + * + * @param int $pValue + */ public function setCellMarginRight($pValue = null) { $this->_cellMarginRight = $pValue; } + /** + * Get cell margin right + * + * @return int + */ public function getCellMarginRight() { return $this->_cellMarginRight; } + /** + * Set cell margin bottom + * + * @param int $pValue + */ public function setCellMarginBottom($pValue = null) { $this->_cellMarginBottom = $pValue; } + /** + * Get cell margin bottom + * + * @return int + */ public function getCellMarginBottom() { return $this->_cellMarginBottom; } + /** + * Set TLRB cell margin + * + * @param int $pValue Margin in twips + */ + public function setCellMargin($pValue = null) + { + $this->_cellMarginTop = $pValue; + $this->_cellMarginLeft = $pValue; + $this->_cellMarginRight = $pValue; + $this->_cellMarginBottom = $pValue; + } + + /** + * Get cell margin + * + * @return array + */ public function getCellMargin() { return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); diff --git a/src/PhpWord/Style/TableFull.php b/src/PhpWord/Style/TableFull.php index f6d8114b..05286ea3 100755 --- a/src/PhpWord/Style/TableFull.php +++ b/src/PhpWord/Style/TableFull.php @@ -25,6 +25,9 @@ namespace PhpOffice\PhpWord\Style; +/** + * Table (full) style + */ class TableFull { /** @@ -35,90 +38,130 @@ class TableFull private $_firstRow = null; /** + * Cell margin top + * * @var int */ private $_cellMarginTop = null; /** + * Cell margin left + * * @var int */ private $_cellMarginLeft = null; /** + * Cell margin right + * * @var int */ private $_cellMarginRight = null; /** + * Cell margin bottom + * * @var int */ private $_cellMarginBottom = null; /** + * Background color + * * @var string */ private $_bgColor; /** + * Border size top + * * @var int */ private $_borderTopSize; /** - * @var string + * Border color + * + * @var string top */ private $_borderTopColor; /** + * Border size left + * * @var int */ private $_borderLeftSize; /** + * Border color left + * * @var string */ private $_borderLeftColor; /** + * Border size right + * * @var int */ private $_borderRightSize; /** + * Border color right + * * @var string */ private $_borderRightColor; /** + * Border size bottom + * * @var int */ private $_borderBottomSize; /** + * Border color bottom + * * @var string */ private $_borderBottomColor; /** + * Border size inside horizontal + * * @var int */ private $_borderInsideHSize; /** + * Border color inside horizontal + * * @var string */ private $_borderInsideHColor; /** + * Border size inside vertical + * * @var int */ private $_borderInsideVSize; /** + * Border color inside vertical + * * @var string */ private $_borderInsideVColor; + /** + * Create new table style + * + * @param mixed $styleTable + * @param mixed $styleFirstRow + */ public function __construct($styleTable = null, $styleFirstRow = null) { if (!is_null($styleFirstRow) && is_array($styleFirstRow)) { @@ -153,6 +196,8 @@ class TableFull } /** + * Set style value + * * @param string $key * @param mixed $value */ @@ -189,11 +234,22 @@ class TableFull return $this->_lastRow; } + /** + * Get background + * + * @return \PhpOffice\PhpWord\Style\TableFull + */ public function getBgColor() { return $this->_bgColor; } + /** + * Set background + * + * @param string $pValue + * @return \PhpOffice\PhpWord\Style\TableFull + */ public function setBgColor($pValue = null) { $this->_bgColor = $pValue; @@ -202,7 +258,7 @@ class TableFull /** * Set TLRBVH Border Size * - * @param int $pValue Border size in eighths of a point (1/8 point) + * @param int $pValue Border size in eighths of a point (1/8 point) */ public function setBorderSize($pValue = null) { @@ -233,6 +289,7 @@ class TableFull /** * Set TLRBVH Border Color + * @param string $pValue */ public function setBorderColor($pValue = null) { @@ -261,161 +318,321 @@ class TableFull return array($t, $l, $r, $b, $h, $v); } + /** + * Set border size top + * + * @param $pValue + */ public function setBorderTopSize($pValue = null) { $this->_borderTopSize = $pValue; } + /** + * Get border size top + * + * @return + */ public function getBorderTopSize() { return $this->_borderTopSize; } + /** + * Set border color top + * + * @param $pValue + */ public function setBorderTopColor($pValue = null) { $this->_borderTopColor = $pValue; } + /** + * Get border color top + * + * @return + */ public function getBorderTopColor() { return $this->_borderTopColor; } + /** + * Set border size left + * + * @param $pValue + */ public function setBorderLeftSize($pValue = null) { $this->_borderLeftSize = $pValue; } + /** + * Get border size left + * + * @return + */ public function getBorderLeftSize() { return $this->_borderLeftSize; } + /** + * Set border color left + * + * @param $pValue + */ public function setBorderLeftColor($pValue = null) { $this->_borderLeftColor = $pValue; } + /** + * Get border color left + * + * @return + */ public function getBorderLeftColor() { return $this->_borderLeftColor; } + /** + * Set border size right + * + * @param $pValue + */ public function setBorderRightSize($pValue = null) { $this->_borderRightSize = $pValue; } + /** + * Get border size right + * + * @return + */ public function getBorderRightSize() { return $this->_borderRightSize; } + /** + * Set border color right + * + * @param $pValue + */ public function setBorderRightColor($pValue = null) { $this->_borderRightColor = $pValue; } + /** + * Get border color right + * + * @return + */ public function getBorderRightColor() { return $this->_borderRightColor; } + /** + * Set border size bottom + * + * @param $pValue + */ public function setBorderBottomSize($pValue = null) { $this->_borderBottomSize = $pValue; } + /** + * Get border size bottom + * + * @return + */ public function getBorderBottomSize() { return $this->_borderBottomSize; } + /** + * Set border color bottom + * + * @param $pValue + */ public function setBorderBottomColor($pValue = null) { $this->_borderBottomColor = $pValue; } + /** + * Get border color bottom + * + * @return + */ public function getBorderBottomColor() { return $this->_borderBottomColor; } + /** + * Set border color inside horizontal + * + * @param $pValue + */ public function setBorderInsideHColor($pValue = null) { $this->_borderInsideHColor = $pValue; } + /** + * Get border color inside horizontal + * + * @return + */ public function getBorderInsideHColor() { return (isset($this->_borderInsideHColor)) ? $this->_borderInsideHColor : null; } + /** + * Set border color inside vertical + * + * @param $pValue + */ public function setBorderInsideVColor($pValue = null) { $this->_borderInsideVColor = $pValue; } + /** + * Get border color inside vertical + * + * @return + */ public function getBorderInsideVColor() { return (isset($this->_borderInsideVColor)) ? $this->_borderInsideVColor : null; } + /** + * Set border size inside horizontal + * + * @param $pValue + */ public function setBorderInsideHSize($pValue = null) { $this->_borderInsideHSize = $pValue; } + /** + * Get border size inside horizontal + * + * @return + */ public function getBorderInsideHSize() { return (isset($this->_borderInsideHSize)) ? $this->_borderInsideHSize : null; } + /** + * Set border size inside vertical + * + * @param $pValue + */ public function setBorderInsideVSize($pValue = null) { $this->_borderInsideVSize = $pValue; } + /** + * Get border size inside vertical + * + * @return + */ public function getBorderInsideVSize() { return (isset($this->_borderInsideVSize)) ? $this->_borderInsideVSize : null; } + /** + * Set cell margin top + * + * @param int $pValue + */ public function setCellMarginTop($pValue = null) { $this->_cellMarginTop = $pValue; } + /** + * Get cell margin top + * + * @return int + */ public function getCellMarginTop() { return $this->_cellMarginTop; } + /** + * Set cell margin left + * + * @param int $pValue + */ public function setCellMarginLeft($pValue = null) { $this->_cellMarginLeft = $pValue; } + /** + * Get cell margin left + * + * @return int + */ public function getCellMarginLeft() { return $this->_cellMarginLeft; } + /** + * Set cell margin right + * + * @param int $pValue + */ public function setCellMarginRight($pValue = null) { $this->_cellMarginRight = $pValue; } + /** + * Get cell margin right + * + * @return int + */ public function getCellMarginRight() { return $this->_cellMarginRight; } + /** + * Set cell margin bottom + * + * @param int $pValue + */ public function setCellMarginBottom($pValue = null) { $this->_cellMarginBottom = $pValue; } + /** + * Get cell margin bottom + * + * @return int + */ public function getCellMarginBottom() { return $this->_cellMarginBottom; @@ -424,7 +641,7 @@ class TableFull /** * Set TLRB cell margin * - * @param int $pValue Margin in twips + * @param int $pValue Margin in twips */ public function setCellMargin($pValue = null) { @@ -434,6 +651,11 @@ class TableFull $this->_cellMarginBottom = $pValue; } + /** + * Get cell margin + * + * @return array + */ public function getCellMargin() { return array($this->_cellMarginTop, $this->_cellMarginLeft, $this->_cellMarginRight, $this->_cellMarginBottom); diff --git a/src/PhpWord/Style/Tabs.php b/src/PhpWord/Style/Tabs.php index f836532f..fd763abf 100755 --- a/src/PhpWord/Style/Tabs.php +++ b/src/PhpWord/Style/Tabs.php @@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Style; use PhpOffice\PhpWord\Shared\XMLWriter; +/** + * Tabs style + */ class Tabs { /** @@ -37,6 +40,7 @@ class Tabs private $_tabs; /** + * Create new tab collection style * * @param array $tabs */ @@ -46,6 +50,8 @@ class Tabs } /** + * Return XML + * * @param \PhpOffice\PhpWord\Shared\XMLWriter &$xmlWriter */ public function toXml(XMLWriter &$xmlWriter = null) diff --git a/src/PhpWord/TOC.php b/src/PhpWord/TOC.php index d4cffead..1cf277d0 100644 --- a/src/PhpWord/TOC.php +++ b/src/PhpWord/TOC.php @@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord; use PhpOffice\PhpWord\Style\Font; +/** + * Table of contents + */ class TOC { /** diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php index b779b91d..9d9cc604 100644 --- a/src/PhpWord/Template.php +++ b/src/PhpWord/Template.php @@ -28,19 +28,28 @@ namespace PhpOffice\PhpWord; use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Shared\String; +/** + * Template + */ class Template { /** + * ZipArchive object + * * @var \ZipArchive */ private $_objZip; /** + * Temporary file name + * * @var string */ private $_tempFileName; /** + * Document XML + * * @var string */ private $_documentXML; @@ -249,6 +258,8 @@ class Template } /** + * Save XML to temporary file + * * @return string * @throws \PhpOffice\PhpWord\Exceptions\Exception */ @@ -265,13 +276,15 @@ class Template } /** + * Save XML to defined name + * * @param string $strFilename */ public function saveAs($strFilename) { $tempFilename = $this->save(); - if (file_exists($strFilename)) { + if (\file_exists($strFilename)) { unlink($strFilename); } diff --git a/src/PhpWord/Writer/IWriter.php b/src/PhpWord/Writer/IWriter.php index 6f124d29..41326b66 100755 --- a/src/PhpWord/Writer/IWriter.php +++ b/src/PhpWord/Writer/IWriter.php @@ -25,12 +25,15 @@ namespace PhpOffice\PhpWord\Writer; +/** + * Writer interface + */ interface IWriter { /** * Save PhpWord to file * - * @param string $pFileName + * @param string $pFilename */ public function save($pFilename = null); } diff --git a/src/PhpWord/Writer/ODText.php b/src/PhpWord/Writer/ODText.php index 3d41e594..1561a75c 100755 --- a/src/PhpWord/Writer/ODText.php +++ b/src/PhpWord/Writer/ODText.php @@ -34,14 +34,21 @@ use PhpOffice\PhpWord\Writer\ODText\Meta; use PhpOffice\PhpWord\Writer\ODText\Mimetype; use PhpOffice\PhpWord\Writer\ODText\Styles; +/** + * ODText writer + */ class ODText implements IWriter { /** + * PhpWord object + * * @var \PhpOffice\PhpWord\PhpWord */ private $_document; /** + * Individual writers + * * @var \PhpOffice\PhpWord\Writer\ODText\WriterPart[] */ private $_writerParts; @@ -61,11 +68,14 @@ class ODText implements IWriter private $_useDiskCaching = false; /** + * Disk caching directory + * * @var string */ private $_diskCachingDirectory; /** + * Create new ODText writer * @param \PhpOffice\PhpWord\PhpWord $phpWord */ public function __construct(PhpWord $phpWord = null) @@ -96,7 +106,7 @@ class ODText implements IWriter /** * Save PhpWord to file * - * @param string $pFileName + * @param string $pFilename * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function save($pFilename = null) @@ -193,6 +203,8 @@ class ODText implements IWriter } /** + * Get PhpWord object + * * @return \PhpOffice\PhpWord\PhpWord * @throws \PhpOffice\PhpWord\Exceptions\Exception */ @@ -206,6 +218,8 @@ class ODText implements IWriter } /** + * Set PhpWord object + * * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return \PhpOffice\PhpWord\Writer\ODText */ @@ -226,6 +240,8 @@ class ODText implements IWriter } /** + * Get writer part + * * @param string $pPartName Writer part name * @return \PhpOffice\PhpWord\Writer\ODText\WriterPart */ @@ -272,6 +288,8 @@ class ODText implements IWriter } /** + * Get disk caching directory + * * @return string */ public function getDiskCachingDirectory() diff --git a/src/PhpWord/Writer/ODText/Content.php b/src/PhpWord/Writer/ODText/Content.php index 8c725fa0..0b2c4ae7 100644 --- a/src/PhpWord/Writer/ODText/Content.php +++ b/src/PhpWord/Writer/ODText/Content.php @@ -44,6 +44,9 @@ use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\TOC; +/** + * ODText content part writer + */ class Content extends WriterPart { /** @@ -376,6 +379,8 @@ class Content extends WriterPart /** * Write TextBreak + * + * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter */ protected function _writeTextBreak(XMLWriter $xmlWriter = null) { @@ -385,10 +390,22 @@ class Content extends WriterPart } // @codeCoverageIgnoreStart + /** + * Write end section + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section $section + */ private function _writeEndSection(XMLWriter $xmlWriter = null, Section $section = null) { } + /** + * Write section + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section $section + */ private function _writeSection(XMLWriter $xmlWriter = null, Section $section = null) { } diff --git a/src/PhpWord/Writer/ODText/Manifest.php b/src/PhpWord/Writer/ODText/Manifest.php index ddc5cd95..a7071810 100755 --- a/src/PhpWord/Writer/ODText/Manifest.php +++ b/src/PhpWord/Writer/ODText/Manifest.php @@ -30,6 +30,9 @@ use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\File; use PhpOffice\PhpWord\Shared\XMLWriter; +/** + * ODText manifest part writer + */ class Manifest extends WriterPart { /** @@ -120,7 +123,7 @@ class Manifest extends WriterPart */ private function _getImageMimeType($pFile = '') { - if (File::file_exists($pFile)) { + if (File::fileExists($pFile)) { $image = getimagesize($pFile); return image_type_to_mime_type($image[2]); } else { diff --git a/src/PhpWord/Writer/ODText/Meta.php b/src/PhpWord/Writer/ODText/Meta.php index 16814cb3..dc74daa2 100644 --- a/src/PhpWord/Writer/ODText/Meta.php +++ b/src/PhpWord/Writer/ODText/Meta.php @@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Writer\ODText; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; +/** + * ODText meta part writer + */ class Meta extends WriterPart { /** diff --git a/src/PhpWord/Writer/ODText/Mimetype.php b/src/PhpWord/Writer/ODText/Mimetype.php index 77eb0a5a..7247c7ea 100644 --- a/src/PhpWord/Writer/ODText/Mimetype.php +++ b/src/PhpWord/Writer/ODText/Mimetype.php @@ -27,6 +27,9 @@ namespace PhpOffice\PhpWord\Writer\ODText; use PhpOffice\PhpWord\PhpWord; +/** + * ODText mimetype part writer + */ class Mimetype extends WriterPart { /** diff --git a/src/PhpWord/Writer/ODText/Styles.php b/src/PhpWord/Writer/ODText/Styles.php index e5a53172..0a45aa68 100644 --- a/src/PhpWord/Writer/ODText/Styles.php +++ b/src/PhpWord/Writer/ODText/Styles.php @@ -32,6 +32,9 @@ use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\TableFull; +/** + * ODText styloes part writer + */ class Styles extends WriterPart { /** diff --git a/src/PhpWord/Writer/ODText/WriterPart.php b/src/PhpWord/Writer/ODText/WriterPart.php index 4c1de3c2..de853aca 100644 --- a/src/PhpWord/Writer/ODText/WriterPart.php +++ b/src/PhpWord/Writer/ODText/WriterPart.php @@ -28,6 +28,9 @@ namespace PhpOffice\PhpWord\Writer\ODText; use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Writer\IWriter; +/** + * ODText writer part abstract + */ abstract class WriterPart { /** diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index 1d6a2d95..5bf2c9be 100755 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -45,6 +45,9 @@ use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\TOC; +/** + * RTF writer + */ class RTF implements IWriter { /** @@ -61,11 +64,29 @@ class RTF implements IWriter */ private $_drawingHashTable; + /** + * Color register + * + * @var array + */ private $_colorTable; + + /** + * Font register + * + * @var array + */ private $_fontTable; + + /** + * Last paragraph style + * + * @var mixed + */ private $_lastParagraphStyle; /** + * Create new RTF writer * @param \PhpOffice\PhpWord\PhpWord $phpWord */ public function __construct(PhpWord $phpWord = null) @@ -80,7 +101,7 @@ class RTF implements IWriter /** * Save PhpWord to file * - * @param string $pFileName + * @param string $pFilename * @throws \PhpOffice\PhpWord\Exceptions\Exception */ public function save($pFilename = null) @@ -113,6 +134,8 @@ class RTF implements IWriter } /** + * Get PhpWord object + * * @return \PhpOffice\PhpWord\PhpWord * @throws \PhpOffice\PhpWord\Exceptions\Exception */ @@ -126,6 +149,8 @@ class RTF implements IWriter } /** + * Set PhpWord object + * * @param \PhpOffice\PhpWord\PhpWord $phpWord * @return \PhpOffice\PhpWord\Writer\RTF */ @@ -145,6 +170,11 @@ class RTF implements IWriter return $this->_drawingHashTable; } + /** + * Get all data + * + * @return string + */ private function getData() { // PhpWord object : $this->_document @@ -198,6 +228,11 @@ class RTF implements IWriter return $sRTFContent; } + /** + * Get all fonts + * + * @return array + */ private function getDataFont() { $phpWord = $this->_document; @@ -248,6 +283,11 @@ class RTF implements IWriter return $arrFonts; } + /** + * Get all colors + * + * @return array + */ private function getDataColor() { $phpWord = $this->_document; @@ -304,6 +344,11 @@ class RTF implements IWriter return $arrColors; } + /** + * Get content data + * + * @return string + */ private function getDataContent() { $phpWord = $this->_document; @@ -350,6 +395,12 @@ class RTF implements IWriter return $sRTFBody; } + /** + * Get text element content + * + * @param boolean $withoutP + * @return string + */ private function getDataContentText(Text $text, $withoutP = false) { $sRTFText = ''; @@ -438,6 +489,11 @@ class RTF implements IWriter return $sRTFText; } + /** + * Get textrun content + * + * @return string + */ private function getDataContentTextRun(TextRun $textrun) { $sRTFText = ''; @@ -456,6 +512,11 @@ class RTF implements IWriter return $sRTFText; } + /** + * Get text break content + * + * @return string + */ private function getDataContentTextBreak() { $this->_lastParagraphStyle = ''; @@ -464,7 +525,7 @@ class RTF implements IWriter } /** - * Write unsupported element + * Get unsupported element content * * @param string $element */ diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php index 82f14eca..0e120aa2 100755 --- a/src/PhpWord/Writer/Word2007.php +++ b/src/PhpWord/Writer/Word2007.php @@ -40,15 +40,58 @@ use PhpOffice\PhpWord\Writer\Word2007\Header; use PhpOffice\PhpWord\Writer\Word2007\Rels; use PhpOffice\PhpWord\Writer\Word2007\Styles; +/** + * Word2007 writer + */ class Word2007 implements IWriter { + /** + * PhpWord object + * + * @var PhpOffice\PhpWord\PhpWord + */ private $_document; + + /** + * Individual writers + * + * @var PhpOffice\PhpWord\Writer\Word2007\WriterPart + */ private $_writerParts; + + /** + * Disk caching directory + * + * @var string + */ private $_diskCachingDirectory; + + /** + * Use disk caching + * + * @var boolean + */ private $_useDiskCaching = false; + + /** + * Types of images + * + * @var array + */ private $_imageTypes = array(); + + /** + * Types of objects + * + * @var array + */ private $_objectTypes = array(); + /** + * Create new Word2007 writer + * + * @param PhpOffice\PhpWord\PhpWord + */ public function __construct(PhpWord $phpWord = null) { $this->_document = $phpWord; @@ -71,6 +114,11 @@ class Word2007 implements IWriter } } + /** + * Save document by name + * + * @param string $pFilename + */ public function save($pFilename = null) { if (!is_null($this->_document)) { @@ -212,6 +260,8 @@ class Word2007 implements IWriter } /** + * Check content types + * * @param string $src */ private function checkContentTypes($src) @@ -251,6 +301,12 @@ class Word2007 implements IWriter } } + /** + * Get writer part + * + * @param string $pPartName Writer part name + * @return \PhpOffice\PhpWord\Writer\ODText\WriterPart + */ public function getWriterPart($pPartName = '') { if ($pPartName != '' && isset($this->_writerParts[strtolower($pPartName)])) { @@ -260,11 +316,22 @@ class Word2007 implements IWriter } } + /** + * Get use disk caching status + * + * @return boolean + */ public function getUseDiskCaching() { return $this->_useDiskCaching; } + /** + * Set use disk caching status + * + * @param boolean $pValue + * @param string $pDirectory + */ public function setUseDiskCaching($pValue = false, $pDirectory = null) { $this->_useDiskCaching = $pValue; @@ -281,6 +348,8 @@ class Word2007 implements IWriter } /** + * Get disk caching directory + * * @return string */ public function getDiskCachingDirectory() @@ -288,6 +357,12 @@ class Word2007 implements IWriter return $this->_diskCachingDirectory; } + /** + * Check content types + * + * @param mixed $objZip + * @param mixed $element + */ private function _addFileToPackage($objZip, $element) { if (isset($element['isMemImage']) && $element['isMemImage']) { diff --git a/src/PhpWord/Writer/Word2007/Base.php b/src/PhpWord/Writer/Word2007/Base.php index a18d57ea..a79ffa70 100644 --- a/src/PhpWord/Writer/Word2007/Base.php +++ b/src/PhpWord/Writer/Word2007/Base.php @@ -44,8 +44,20 @@ use PhpOffice\PhpWord\Style\Cell; use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; +/** + * Word2007 base part writer + * + * Write common parts of document.xml, headerx.xml, and footerx.xml + */ class Base extends WriterPart { + /** + * Write text element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\Text $text + * @param boolean $withoutP + */ protected function _writeText(XMLWriter $xmlWriter, Text $text, $withoutP = false) { $styleFont = $text->getFontStyle(); @@ -96,6 +108,12 @@ class Base extends WriterPart } } + /** + * Write textrun element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section $section + */ protected function _writeTextRun(XMLWriter $xmlWriter, TextRun $textrun) { $elements = $textrun->getElements(); @@ -135,10 +153,11 @@ class Base extends WriterPart } /** + * Write paragraph style + * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Style\Paragraph $style * @param bool $withoutPPR - * @return void */ protected function _writeParagraphStyle( XMLWriter $xmlWriter, @@ -236,6 +255,13 @@ class Base extends WriterPart } } + /** + * Write link element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\Link $link + * @param boolean $withoutP + */ protected function _writeLink(XMLWriter $xmlWriter, Link $link, $withoutP = false) { $rID = $link->getRelationId(); @@ -292,6 +318,12 @@ class Base extends WriterPart } } + /** + * Write preserve text element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\TextRun $textrun + */ protected function _writePreserveText(XMLWriter $xmlWriter, PreserveText $textrun) { $styleFont = $textrun->getFontStyle(); @@ -384,6 +416,12 @@ class Base extends WriterPart $xmlWriter->endElement(); // p } + /** + * Write footnote reference element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section $section + */ protected function _writeTextStyle(XMLWriter $xmlWriter, Font $style) { $font = $style->getName(); @@ -473,6 +511,8 @@ class Base extends WriterPart } /** + * Write text break element + * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param \PhpOffice\PhpWord\Section\TextBreak $element */ @@ -519,6 +559,12 @@ class Base extends WriterPart } } + /** + * Write footnote reference element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\Table $table + */ protected function _writeTable(XMLWriter $xmlWriter, Table $table) { $_rows = $table->getRows(); @@ -628,6 +674,12 @@ class Base extends WriterPart } } + /** + * Write table style + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Style\Table $style + */ protected function _writeTableStyle( XMLWriter $xmlWriter, \PhpOffice\PhpWord\Style\Table $style = null @@ -675,6 +727,12 @@ class Base extends WriterPart } } + /** + * Write footnote reference element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Style\Cell $style + */ protected function _writeCellStyle(XMLWriter $xmlWriter, Cell $style = null) { $bgColor = $style->getBgColor(); @@ -779,8 +837,11 @@ class Base extends WriterPart } /** + * Write image element + * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter - * @param \PhpOffice\PhpWord\Section\Image|\PhpOffice\PhpWord\Section\MemoryImage $image + * @param mixed $image + * @param boolean $withoutP */ protected function _writeImage(XMLWriter $xmlWriter, $image, $withoutP = false) { @@ -859,6 +920,12 @@ class Base extends WriterPart } } + /** + * Write footnote reference element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param mixed $image + */ protected function _writeWatermark(XMLWriter $xmlWriter, $image) { $rId = $image->getRelationId(); @@ -903,6 +970,12 @@ class Base extends WriterPart $xmlWriter->endElement(); } + /** + * Write title element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\Title $title + */ protected function _writeTitle(XMLWriter $xmlWriter, Title $title) { $text = htmlspecialchars($title->getText()); @@ -945,6 +1018,12 @@ class Base extends WriterPart $xmlWriter->endElement(); } + /** + * Write footnote element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\Footnote $footnote + */ protected function _writeFootnote(XMLWriter $xmlWriter, Footnote $footnote) { $xmlWriter->startElement('w:footnote'); @@ -980,6 +1059,13 @@ class Base extends WriterPart $xmlWriter->endElement(); // w:footnote } + /** + * Write footnote reference element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\Footnote $footnote + * @param boolean $withoutP + */ protected function _writeFootnoteReference(XMLWriter $xmlWriter, Footnote $footnote, $withoutP = false) { if (!$withoutP) { diff --git a/src/PhpWord/Writer/Word2007/ContentTypes.php b/src/PhpWord/Writer/Word2007/ContentTypes.php index be74594b..2f6ab4e1 100755 --- a/src/PhpWord/Writer/Word2007/ContentTypes.php +++ b/src/PhpWord/Writer/Word2007/ContentTypes.php @@ -29,8 +29,18 @@ use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Shared\File; use PhpOffice\PhpWord\Shared\XMLWriter; +/** + * Word2007 contenttypes part writer + */ class ContentTypes extends WriterPart { + /** + * Write [Content_Types].xml + * @param array $_imageTypes + * @param array $_objectTypes + * @param int $_cHdrs + * @param array $footers + */ public function writeContentTypes($_imageTypes, $_objectTypes, $_cHdrs, $footers) { // Create XML writer @@ -179,7 +189,7 @@ class ContentTypes extends WriterPart */ private function _getImageMimeType($pFile = '') { - if (File::file_exists($pFile)) { + if (File::fileExists($pFile)) { $image = getimagesize($pFile); return image_type_to_mime_type($image[2]); } else { @@ -188,6 +198,8 @@ class ContentTypes extends WriterPart } /** + * Write Default XML element + * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer * @param string $pPartname Part name * @param string $pContentType Content type @@ -207,6 +219,8 @@ class ContentTypes extends WriterPart } /** + * Write Override XML element + * * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter * @param string $pPartname Part name * @param string $pContentType Content type diff --git a/src/PhpWord/Writer/Word2007/DocProps.php b/src/PhpWord/Writer/Word2007/DocProps.php index bbfc6523..93ebe27e 100644 --- a/src/PhpWord/Writer/Word2007/DocProps.php +++ b/src/PhpWord/Writer/Word2007/DocProps.php @@ -28,8 +28,14 @@ namespace PhpOffice\PhpWord\Writer\Word2007; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; +/** + * Word2007 contenttypes part writer + */ class DocProps extends WriterPart { + /** + * Write docProps/app.xml + */ public function writeDocPropsApp(PhpWord $phpWord = null) { // Create XML writer @@ -122,6 +128,11 @@ class DocProps extends WriterPart } + /** + * Write docProps/core.xml + * + * @param PhpOffice\PhpWord\PhpWord $phpWord + */ public function writeDocPropsCore(PhpWord $phpWord = null) { // Create XML writer diff --git a/src/PhpWord/Writer/Word2007/Document.php b/src/PhpWord/Writer/Word2007/Document.php index 09710ba6..a598ccb0 100644 --- a/src/PhpWord/Writer/Word2007/Document.php +++ b/src/PhpWord/Writer/Word2007/Document.php @@ -44,8 +44,16 @@ use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\TOC; +/** + * Word2007 document part writer + */ class Document extends Base { + /** + * Write word/document.xml + * + * @param PhpOffice\PhpWord\PhpWord $phpWord + */ public function writeDocument(PhpWord $phpWord = null) { // Create XML writer @@ -128,6 +136,12 @@ class Document extends Base return $xmlWriter->getData(); } + /** + * Write begin section + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section $section + */ private function _writeSection(XMLWriter $xmlWriter, Section $section) { $xmlWriter->startElement('w:p'); @@ -137,6 +151,12 @@ class Document extends Base $xmlWriter->endElement(); } + /** + * Write end section + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section $section + */ private function _writeEndSection(XMLWriter $xmlWriter, Section $section) { $settings = $section->getSettings(); @@ -270,6 +290,11 @@ class Document extends Base $xmlWriter->endElement(); } + /** + * Write page break element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + */ private function _writePageBreak(XMLWriter $xmlWriter) { $xmlWriter->startElement('w:p'); @@ -281,6 +306,12 @@ class Document extends Base $xmlWriter->endElement(); } + /** + * Write list item element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\ListItem $listItem + */ public function _writeListItem(XMLWriter $xmlWriter, ListItem $listItem) { $textObject = $listItem->getTextObject(); @@ -320,6 +351,12 @@ class Document extends Base $xmlWriter->endElement(); } + /** + * Write object element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Section\Object $object + */ protected function _writeObject(XMLWriter $xmlWriter, Object $object) { $rIdObject = $object->getRelationId(); @@ -379,6 +416,11 @@ class Document extends Base $xmlWriter->endElement(); // w:p } + /** + * Write TOC element + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + */ private function _writeTOC(XMLWriter $xmlWriter) { $titles = TOC::getTitles(); diff --git a/src/PhpWord/Writer/Word2007/DocumentRels.php b/src/PhpWord/Writer/Word2007/DocumentRels.php index 79b7bfba..889df50c 100755 --- a/src/PhpWord/Writer/Word2007/DocumentRels.php +++ b/src/PhpWord/Writer/Word2007/DocumentRels.php @@ -28,8 +28,16 @@ namespace PhpOffice\PhpWord\Writer\Word2007; use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Shared\XMLWriter; +/** + * Word2007 document rels part writer + */ class DocumentRels extends WriterPart { + /** + * Write word/_rels/document.xml.rels + * + * @param array $_relsCollection + */ public function writeDocumentRels($_relsCollection) { // Create XML writer @@ -118,6 +126,11 @@ class DocumentRels extends WriterPart return $xmlWriter->getData(); } + /** + * Write header footer rels + * + * @param array $_relsCollection + */ public function writeHeaderFooterRels($_relsCollection) { // Create XML writer @@ -156,6 +169,15 @@ class DocumentRels extends WriterPart return $xmlWriter->getData(); } + /** + * Write individual rels entry + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param int $pId Relationship ID + * @param string $pType Relationship type + * @param string $pTarget Relationship target + * @param string $pTargetMode Relationship target mode + */ private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') { if ($pType != '' && $pTarget != '') { diff --git a/src/PhpWord/Writer/Word2007/Footer.php b/src/PhpWord/Writer/Word2007/Footer.php index e10a7eff..2a780af7 100644 --- a/src/PhpWord/Writer/Word2007/Footer.php +++ b/src/PhpWord/Writer/Word2007/Footer.php @@ -34,8 +34,16 @@ use PhpOffice\PhpWord\Section\TextBreak; use PhpOffice\PhpWord\Section\TextRun; use PhpOffice\PhpWord\Shared\XMLWriter; +/** + * Word2007 footer part writer + */ class Footer extends Base { + /** + * Write word/footnotes.xml + * + * @param PhpOffice\PhpWord\Section\Footer $footer + */ public function writeFooter(\PhpOffice\PhpWord\Section\Footer $footer) { // Create XML writer diff --git a/src/PhpWord/Writer/Word2007/Footnotes.php b/src/PhpWord/Writer/Word2007/Footnotes.php index fa048c46..560988a7 100644 --- a/src/PhpWord/Writer/Word2007/Footnotes.php +++ b/src/PhpWord/Writer/Word2007/Footnotes.php @@ -28,8 +28,16 @@ namespace PhpOffice\PhpWord\Writer\Word2007; use PhpOffice\PhpWord\Section\Footnote; use PhpOffice\PhpWord\Shared\XMLWriter; +/** + * Word2007 footnotes part writer + */ class Footnotes extends Base { + /** + * Write word/footnotes.xml + * + * @param array $allFootnotesCollection + */ public function writeFootnotes($allFootnotesCollection) { // Create XML writer diff --git a/src/PhpWord/Writer/Word2007/FootnotesRels.php b/src/PhpWord/Writer/Word2007/FootnotesRels.php index 7f76c3cd..1316cddf 100644 --- a/src/PhpWord/Writer/Word2007/FootnotesRels.php +++ b/src/PhpWord/Writer/Word2007/FootnotesRels.php @@ -28,8 +28,16 @@ namespace PhpOffice\PhpWord\Writer\Word2007; use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Shared\XMLWriter; +/** + * Word2007 footnotes rel part writer + */ class FootnotesRels extends WriterPart { + /** + * Write word/_rels/footnotes.xml.rels + * + * @param mixed $_relsCollection + */ public function writeFootnotesRels($_relsCollection) { // Create XML writer @@ -63,6 +71,15 @@ class FootnotesRels extends WriterPart return $xmlWriter->getData(); } + /** + * Write individual rels entry + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param int $pId Relationship ID + * @param string $pType Relationship type + * @param string $pTarget Relationship target + * @param string $pTargetMode Relationship target mode + */ private function _writeRelationship(XMLWriter $xmlWriter = null, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') { if ($pType != '' && $pTarget != '') { diff --git a/src/PhpWord/Writer/Word2007/Header.php b/src/PhpWord/Writer/Word2007/Header.php index b5695f88..5dd73723 100644 --- a/src/PhpWord/Writer/Word2007/Header.php +++ b/src/PhpWord/Writer/Word2007/Header.php @@ -34,8 +34,16 @@ use PhpOffice\PhpWord\Section\TextBreak; use PhpOffice\PhpWord\Section\TextRun; use PhpOffice\PhpWord\Shared\XMLWriter; +/** + * Word2007 header part writer + */ class Header extends Base { + /** + * Write word/headerx.xml + * + * @param PhpOffice\PhpWord\Section\Header $header + */ public function writeHeader(\PhpOffice\PhpWord\Section\Header $header) { // Create XML writer diff --git a/src/PhpWord/Writer/Word2007/Rels.php b/src/PhpWord/Writer/Word2007/Rels.php index 63e8c848..ed82db78 100755 --- a/src/PhpWord/Writer/Word2007/Rels.php +++ b/src/PhpWord/Writer/Word2007/Rels.php @@ -29,8 +29,16 @@ use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\PhpWord; use PhpOffice\PhpWord\Shared\XMLWriter; +/** + * Word2007 rels part writer + */ class Rels extends WriterPart { + /** + * Write _rels/.rels + * + * @param PhpOffice\PhpWord\PhpWord $phpWord + */ public function writeRelationships(PhpWord $phpWord = null) { // Create XML writer diff --git a/src/PhpWord/Writer/Word2007/Styles.php b/src/PhpWord/Writer/Word2007/Styles.php index ff45c9a1..e43ed277 100644 --- a/src/PhpWord/Writer/Word2007/Styles.php +++ b/src/PhpWord/Writer/Word2007/Styles.php @@ -32,10 +32,23 @@ use PhpOffice\PhpWord\Style\Font; use PhpOffice\PhpWord\Style\Paragraph; use PhpOffice\PhpWord\Style\TableFull; +/** + * Word2007 styles part writer + */ class Styles extends Base { + /** + * PhpWord object + * + * @var PhpWord + */ private $_document; + /** + * Write word/styles.xml + * + * @param PhpOffice\PhpWord\PhpWord $phpWord + */ public function writeStyles(PhpWord $phpWord = null) { // Create XML writer @@ -184,6 +197,12 @@ class Styles extends Base return $xmlWriter->getData(); } + /** + * Write table style + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param PhpOffice\PhpWord\Style\TableFull $style + */ private function _writeFullTableStyle(XMLWriter $xmlWriter, TableFull $style) { @@ -304,6 +323,13 @@ class Styles extends Base } } + /** + * Write first row style + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + * @param string $type + * @param PhpOffice\PhpWord\Style\TableFull $style + */ private function _writeRowStyle(XMLWriter $xmlWriter, $type, TableFull $style) { $brdSz = $style->getBorderSize(); @@ -365,6 +391,11 @@ class Styles extends Base } + /** + * Write document defaults + * + * @param PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter + */ private function _writeDocDefaults(XMLWriter $xmlWriter) { $fontName = $this->_document->getDefaultFontName(); diff --git a/src/PhpWord/Writer/Word2007/WriterPart.php b/src/PhpWord/Writer/Word2007/WriterPart.php index d147996f..1d56669e 100755 --- a/src/PhpWord/Writer/Word2007/WriterPart.php +++ b/src/PhpWord/Writer/Word2007/WriterPart.php @@ -28,15 +28,33 @@ namespace PhpOffice\PhpWord\Writer\Word2007; use PhpOffice\PhpWord\Exceptions\Exception; use PhpOffice\PhpWord\Writer\IWriter; +/** + * Word2007 writer part abstract class + */ abstract class WriterPart { + /** + * Parent writer + * + * @var IWriter + */ private $_parentWriter; + /** + * Set parent writer + * + * @param IWriter $pWriter + */ public function setParentWriter(IWriter $pWriter = null) { $this->_parentWriter = $pWriter; } + /** + * Get parent writer + * + * @return IWriter + */ public function getParentWriter() { if (!is_null($this->_parentWriter)) { diff --git a/test/PhpWord/Tests/Shared/FileTest.php b/test/PhpWord/Tests/Shared/FileTest.php index 97cdf375..83764748 100644 --- a/test/PhpWord/Tests/Shared/FileTest.php +++ b/test/PhpWord/Tests/Shared/FileTest.php @@ -16,7 +16,7 @@ class FileTest extends \PHPUnit_Framework_TestCase { $dir = __DIR__ . "/../_files/templates"; chdir($dir); - $this->assertTrue(File::file_exists('blank.docx')); + $this->assertTrue(File::fileExists('blank.docx')); } /** * Test file_exists() @@ -25,7 +25,7 @@ class FileTest extends \PHPUnit_Framework_TestCase { $dir = __DIR__ . "/../_files/templates"; chdir($dir); - $this->assertFalse(File::file_exists('404.docx')); + $this->assertFalse(File::fileExists('404.docx')); } /** diff --git a/test/PhpWord/Tests/TemplateTest.php b/test/PhpWord/Tests/TemplateTest.php index ec11d30b..f096e69d 100644 --- a/test/PhpWord/Tests/TemplateTest.php +++ b/test/PhpWord/Tests/TemplateTest.php @@ -132,7 +132,7 @@ final class TemplateTest extends \PHPUnit_Framework_TestCase $document->cloneRow('userId', 1); $document->setValue('userId#1', 'Test'); $document->saveAs($docName); - $docFound = file_exists($docName); + $docFound = \file_exists($docName); unlink($docName); $this->assertEquals($expectedVar, $actualVar); diff --git a/test/PhpWord/Tests/Writer/ODTextTest.php b/test/PhpWord/Tests/Writer/ODTextTest.php index 5881a2b5..030312e0 100644 --- a/test/PhpWord/Tests/Writer/ODTextTest.php +++ b/test/PhpWord/Tests/Writer/ODTextTest.php @@ -74,7 +74,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase $writer = new ODText($phpWord); $writer->save($file); - $this->assertTrue(file_exists($file)); + $this->assertTrue(\file_exists($file)); unlink($file); } diff --git a/test/PhpWord/Tests/Writer/RTFTest.php b/test/PhpWord/Tests/Writer/RTFTest.php index 436a4954..1c460a36 100644 --- a/test/PhpWord/Tests/Writer/RTFTest.php +++ b/test/PhpWord/Tests/Writer/RTFTest.php @@ -88,7 +88,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase $writer = new RTF($phpWord); $writer->save($file); - $this->assertTrue(file_exists($file)); + $this->assertTrue(\file_exists($file)); unlink($file); } diff --git a/test/PhpWord/Tests/Writer/Word2007Test.php b/test/PhpWord/Tests/Writer/Word2007Test.php index 7f866e65..d6189557 100644 --- a/test/PhpWord/Tests/Writer/Word2007Test.php +++ b/test/PhpWord/Tests/Writer/Word2007Test.php @@ -66,7 +66,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase $writer = new Word2007($phpWord); $file = __DIR__ . "/../_files/temp.docx"; $writer->save($file); - $this->assertTrue(file_exists($file)); + $this->assertTrue(\file_exists($file)); unlink($file); } diff --git a/test/PhpWord/Tests/_includes/TestHelperDOCX.php b/test/PhpWord/Tests/_includes/TestHelperDOCX.php index 969f6c65..97f84ac2 100644 --- a/test/PhpWord/Tests/_includes/TestHelperDOCX.php +++ b/test/PhpWord/Tests/_includes/TestHelperDOCX.php @@ -36,7 +36,7 @@ class TestHelperDOCX public static function clear() { - if (file_exists(self::$file)) { + if (\file_exists(self::$file)) { unlink(self::$file); } if (is_dir(sys_get_temp_dir() . '/PhpWord_Unit_Test/')) { @@ -69,4 +69,4 @@ class TestHelperDOCX { return self::$file; } -} \ No newline at end of file +} diff --git a/test/PhpWord/Tests/_includes/XmlDocument.php b/test/PhpWord/Tests/_includes/XmlDocument.php index 5f84c997..e868df5f 100644 --- a/test/PhpWord/Tests/_includes/XmlDocument.php +++ b/test/PhpWord/Tests/_includes/XmlDocument.php @@ -110,4 +110,4 @@ class XmlDocument $nodeList = $this->getNodeList($path, $file); return !($nodeList->length == 0); } -} \ No newline at end of file +} diff --git a/test/bootstrap.php b/test/bootstrap.php index 172cf9e8..d3351272 100755 --- a/test/bootstrap.php +++ b/test/bootstrap.php @@ -8,11 +8,11 @@ if (!defined('PHPWORD_TESTS_BASE_DIR')) { $vendor = realpath(__DIR__ . '/../vendor'); -if (file_exists($vendor . "/autoload.php")) { +if (\file_exists($vendor . "/autoload.php")) { require $vendor . "/autoload.php"; } else { $vendor = realpath(__DIR__ . '/../../../'); - if (file_exists($vendor . "/autoload.php")) { + if (\file_exists($vendor . "/autoload.php")) { require $vendor . "/autoload.php"; } else { throw new Exception("Unable to load dependencies"); @@ -26,11 +26,11 @@ spl_autoload_register(function ($class) { $class = str_replace('\\', DIRECTORY_SEPARATOR, $class); $class = 'PhpWord' . DIRECTORY_SEPARATOR . 'Tests' . DIRECTORY_SEPARATOR . '_includes' . substr($class, strlen($prefix)); $file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php'; - if (file_exists($file)) { + if (\file_exists($file)) { require_once $file; } } }); require_once __DIR__ . "/../src/PhpWord/Autoloader.php"; -PhpOffice\PhpWord\Autoloader::register(); \ No newline at end of file +PhpOffice\PhpWord\Autoloader::register();