diff --git a/README.md b/README.md index 95d5947e..8470aa90 100755 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ In this case, you will have to register the autoloader. ```php require_once 'path/to/PhpWord/src/PhpWord/Autoloader.php'; -PhpOffice\PhpWord\Autoloader::register(); +\PhpOffice\PhpWord\Autoloader::register(); ``` ## Basic usage diff --git a/docs/general.rst b/docs/general.rst index e1545a04..c267d87d 100644 --- a/docs/general.rst +++ b/docs/general.rst @@ -13,7 +13,7 @@ folder `__. .. code-block:: php require_once 'src/PhpWord/Autoloader.php'; - PhpOffice\PhpWord\Autoloader::register(); + \PhpOffice\PhpWord\Autoloader::register(); $phpWord = new \PhpOffice\PhpWord\PhpWord(); @@ -73,7 +73,7 @@ during development to make the resulting XML file easier to read. .. code-block:: php - PhpOffice\PhpWord\Settings::setCompatibility(false); + \PhpOffice\PhpWord\Settings::setCompatibility(false); Zip class ~~~~~~~~~ @@ -87,7 +87,7 @@ included with PHPWord. .. code-block:: php - PhpOffice\PhpWord\Settings::setZipClass(PhpOffice\PhpWord\Settings::PCLZIP); + \PhpOffice\PhpWord\Settings::setZipClass(\PhpOffice\PhpWord\Settings::PCLZIP); Default font ------------ diff --git a/docs/setup.rst b/docs/setup.rst index c773756f..3c01eb94 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -53,7 +53,7 @@ invoke ``Autoloader::register``. .. code-block:: php require_once '/path/to/src/PhpWord/Autoloader.php'; - PhpOffice\PhpWord\Autoloader::register(); + \PhpOffice\PhpWord\Autoloader::register(); Using samples ------------- diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php index 4405eaeb..02b78bd7 100755 --- a/samples/Sample_01_SimpleText.php +++ b/samples/Sample_01_SimpleText.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , " Create new PhpWord object" , \EOL; +echo date('H:i:s') , " Create new PhpWord object" , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->addFontStyle('rStyle', array('bold' => true, 'italic' => true, 'size' => 16)); $phpWord->addParagraphStyle('pStyle', array('align' => 'center', 'spaceAfter' => 100)); @@ -48,7 +48,7 @@ $section->addImage('resources/_earth.jpg', array('width'=>18, 'height'=>18)); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_02_TabStops.php b/samples/Sample_02_TabStops.php index 01dc7617..dbed59a3 100755 --- a/samples/Sample_02_TabStops.php +++ b/samples/Sample_02_TabStops.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , \EOL; +echo date('H:i:s') , ' Create new PhpWord object' , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Ads styles @@ -28,15 +28,15 @@ $phpWord->addParagraphStyle('centerTab', array( $section = $phpWord->addSection(); // Add listitem elements -$section->addText("Multiple Tabs:\tOne\tTwo\tThree", NULL, 'multipleTab'); -$section->addText("Left Aligned\tRight Aligned", NULL, 'rightTab'); -$section->addText("\tCenter Aligned", NULL, 'centerTab'); +$section->addText("Multiple Tabs:\tOne\tTwo\tThree", null, 'multipleTab'); +$section->addText("Left Aligned\tRight Aligned", null, 'rightTab'); +$section->addText("\tCenter Aligned", null, 'centerTab'); // Save file $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_03_Sections.php b/samples/Sample_03_Sections.php index 7289fef0..4953b6a6 100755 --- a/samples/Sample_03_Sections.php +++ b/samples/Sample_03_Sections.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , \EOL; +echo date('H:i:s') , ' Create new PhpWord object' , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // New portrait section @@ -29,7 +29,7 @@ $section->addFooter()->addText('Footer'); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_04_Textrun.php b/samples/Sample_04_Textrun.php index 6c13a84f..354eadfd 100644 --- a/samples/Sample_04_Textrun.php +++ b/samples/Sample_04_Textrun.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , \EOL; +echo date('H:i:s') , ' Create new PhpWord object' , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Ads styles @@ -37,7 +37,7 @@ $textrun->addText(' Here is some more text. '); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_05_Multicolumn.php b/samples/Sample_05_Multicolumn.php index 4d81766e..478a8dd0 100644 --- a/samples/Sample_05_Multicolumn.php +++ b/samples/Sample_05_Multicolumn.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , " Create new PhpWord object" , \EOL; +echo date('H:i:s') , " Create new PhpWord object" , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $filler = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' . 'Nulla fermentum, tortor id adipiscing adipiscing, tortor turpis commodo. ' . @@ -39,7 +39,7 @@ $section->addText('Normal paragraph again.'); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_06_Footnote.php b/samples/Sample_06_Footnote.php index 270573d9..75120088 100755 --- a/samples/Sample_06_Footnote.php +++ b/samples/Sample_06_Footnote.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , " Create new PhpWord object" , \EOL; +echo date('H:i:s') , " Create new PhpWord object" , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); \PhpOffice\PhpWord\Settings::setCompatibility(false); @@ -41,7 +41,7 @@ $footnote->addText('The reference for this is wrapped in its own line'); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_07_TemplateCloneRow.php b/samples/Sample_07_TemplateCloneRow.php index 789d22f0..3049466d 100755 --- a/samples/Sample_07_TemplateCloneRow.php +++ b/samples/Sample_07_TemplateCloneRow.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s') , " Create new PhpWord object" , \EOL; +echo date('H:i:s') , " Create new PhpWord object" , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $document = $phpWord->loadTemplate('resources/Sample_07_TemplateCloneRow.docx'); @@ -56,7 +56,7 @@ $document->setValue('userName#3', 'Ray'); $document->setValue('userPhone#3', '+1 428 889 775'); $name = 'Sample_07_TemplateCloneRow.docx'; -echo date('H:i:s'), " Write to Word2007 format", \EOL; +echo date('H:i:s'), " Write to Word2007 format", EOL; $document->saveAs($name); rename($name, "results/{$name}"); diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php index 4b184cfd..bf1400a0 100644 --- a/samples/Sample_08_ParagraphPagination.php +++ b/samples/Sample_08_ParagraphPagination.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s') , " Create new PhpWord object" , \EOL; +echo date('H:i:s') , " Create new PhpWord object" , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $phpWord->setDefaultParagraphStyle(array( 'align' => 'both', @@ -49,7 +49,7 @@ $section->addText('Paragraph with pageBreakBefore = true (default: false). ' . $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php index d841092c..5af73fb6 100644 --- a/samples/Sample_09_Tables.php +++ b/samples/Sample_09_Tables.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , \EOL; +echo date('H:i:s') , ' Create new PhpWord object' , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $header = array('size' => 16, 'bold' => true); @@ -88,7 +88,7 @@ $table->addCell(null, $cellRowContinue); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_10_EastAsianFontStyle.php b/samples/Sample_10_EastAsianFontStyle.php index d4ea2c4a..39f449c3 100644 --- a/samples/Sample_10_EastAsianFontStyle.php +++ b/samples/Sample_10_EastAsianFontStyle.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word Document -echo date('H:i:s') , ' Create new PhpWord object' , \EOL; +echo date('H:i:s') , ' Create new PhpWord object' , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); $header = array('size' => 16, 'bold' => true); @@ -13,7 +13,7 @@ $section->addText('中文楷体样式测试',array('name' => '楷体', 'size' => $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_11_ReadWord2007.php b/samples/Sample_11_ReadWord2007.php index b2420a53..e5112e2e 100644 --- a/samples/Sample_11_ReadWord2007.php +++ b/samples/Sample_11_ReadWord2007.php @@ -4,13 +4,13 @@ include_once 'Sample_Header.php'; // Read contents $name = basename(__FILE__, '.php'); $source = "resources/{$name}.docx"; -echo date('H:i:s'), " Reading contents from `{$source}`", \EOL; +echo date('H:i:s'), " Reading contents from `{$source}`", EOL; $phpWord = \PhpOffice\PhpWord\IOFactory::load($source); // (Re)write contents $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_12_HeaderFooter.php b/samples/Sample_12_HeaderFooter.php index a30358f2..15309041 100644 --- a/samples/Sample_12_HeaderFooter.php +++ b/samples/Sample_12_HeaderFooter.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s') , " Create new PhpWord object" , \EOL; +echo date('H:i:s') , " Create new PhpWord object" , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // New portrait section @@ -64,7 +64,7 @@ $section2->addText('Some text...'); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php index 405f653b..4ef325b8 100644 --- a/samples/Sample_13_Images.php +++ b/samples/Sample_13_Images.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", \EOL; +echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -24,7 +24,7 @@ $section->addImage($source); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_14_ListItem.php b/samples/Sample_14_ListItem.php index a7dc48ff..4cd9edea 100644 --- a/samples/Sample_14_ListItem.php +++ b/samples/Sample_14_ListItem.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", \EOL; +echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -48,7 +48,7 @@ $section->addListItem('List Item 7', 0, 'myOwnStyle', $listStyle, 'P-Style'); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_15_Link.php b/samples/Sample_15_Link.php index a2e4f9e1..c4435ac0 100644 --- a/samples/Sample_15_Link.php +++ b/samples/Sample_15_Link.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", \EOL; +echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -22,7 +22,7 @@ $section->addLink('http://www.yahoo.com', null, 'myOwnLinkStyle'); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_16_Object.php b/samples/Sample_16_Object.php index ec2dbce4..cb8de6db 100644 --- a/samples/Sample_16_Object.php +++ b/samples/Sample_16_Object.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", \EOL; +echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -17,7 +17,7 @@ $section->addObject('resources/_sheet.xls'); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_17_TitleTOC.php b/samples/Sample_17_TitleTOC.php index 87c379b2..15de531b 100644 --- a/samples/Sample_17_TitleTOC.php +++ b/samples/Sample_17_TitleTOC.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", \EOL; +echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -66,14 +66,14 @@ $section->addText('Text'); $section->addTitle('Subtitle 3.1.2', 3); $section->addText('Text'); -echo date('H:i:s'), " Note: Please refresh TOC manually.", \EOL; +echo date('H:i:s'), " Note: Please refresh TOC manually.", EOL; // End code // Save file $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_18_Watermark.php b/samples/Sample_18_Watermark.php index 96fe5c99..d0ea786a 100644 --- a/samples/Sample_18_Watermark.php +++ b/samples/Sample_18_Watermark.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", \EOL; +echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -18,7 +18,7 @@ $section->addText('The header reference to the current section includes a waterm $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_19_TextBreak.php b/samples/Sample_19_TextBreak.php index b594bebd..d7e11ea4 100644 --- a/samples/Sample_19_TextBreak.php +++ b/samples/Sample_19_TextBreak.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", \EOL; +echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); // Begin code @@ -31,7 +31,7 @@ $section->addText('Done.'); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_20_BGColor.php b/samples/Sample_20_BGColor.php index ed6ec320..fec40859 100644 --- a/samples/Sample_20_BGColor.php +++ b/samples/Sample_20_BGColor.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", \EOL; +echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); @@ -14,7 +14,7 @@ $section->addText("Compatible with font colors", array("color"=>"0000ff", "bgCol $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_21_TableRowRules.php b/samples/Sample_21_TableRowRules.php index 6f3575cd..10ad156d 100644 --- a/samples/Sample_21_TableRowRules.php +++ b/samples/Sample_21_TableRowRules.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", \EOL; +echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); @@ -31,7 +31,7 @@ $section->addText("So: $"."table2->addRow(3750, array('exactHeight'=>true));"); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_22_CheckBox.php b/samples/Sample_22_CheckBox.php index 3c2b64e5..89827388 100644 --- a/samples/Sample_22_CheckBox.php +++ b/samples/Sample_22_CheckBox.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s'), " Create new PhpWord object", \EOL; +echo date('H:i:s'), " Create new PhpWord object", EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $section = $phpWord->addSection(); @@ -18,7 +18,7 @@ $cell->addCheckBox('chkBox2', 'Checkbox 2'); $name = basename(__FILE__, '.php'); $writers = array('Word2007' => 'docx', 'ODText' => 'odt', 'RTF' => 'rtf'); foreach ($writers as $writer => $extension) { - echo date('H:i:s'), " Write to {$writer} format", \EOL; + echo date('H:i:s'), " Write to {$writer} format", EOL; $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $writer); $xmlWriter->save("{$name}.{$extension}"); rename("{$name}.{$extension}", "results/{$name}.{$extension}"); diff --git a/samples/Sample_23_TemplateBlock.php b/samples/Sample_23_TemplateBlock.php index 168070e0..bbde5a72 100644 --- a/samples/Sample_23_TemplateBlock.php +++ b/samples/Sample_23_TemplateBlock.php @@ -2,7 +2,7 @@ include_once 'Sample_Header.php'; // New Word document -echo date('H:i:s') , " Create new PhpWord object" , \EOL; +echo date('H:i:s') , " Create new PhpWord object" , EOL; $phpWord = new \PhpOffice\PhpWord\PhpWord(); $document = $phpWord->loadTemplate('resources/Sample_23_TemplateBlock.docx'); diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php index b61e415a..c6431c03 100644 --- a/samples/Sample_Header.php +++ b/samples/Sample_Header.php @@ -9,7 +9,7 @@ define('SCRIPT_FILENAME', basename($_SERVER['SCRIPT_FILENAME'], '.php')); define('IS_INDEX', SCRIPT_FILENAME == 'index'); require_once '../src/PhpWord/Autoloader.php'; -PhpOffice\PhpWord\Autoloader::register(); +\PhpOffice\PhpWord\Autoloader::register(); // Return to the caller script when runs by CLI if (CLI) { diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php index 92e93f1f..942ae224 100755 --- a/src/PhpWord/Element/Image.php +++ b/src/PhpWord/Element/Image.php @@ -89,7 +89,7 @@ class Image extends AbstractElement if (stripos(strrev($source), strrev('.php')) === 0) { $this->isMemImage = true; } else { - $this->isMemImage = (filter_var($source, \FILTER_VALIDATE_URL) !== false); + $this->isMemImage = (filter_var($source, FILTER_VALIDATE_URL) !== false); } // Check supported types @@ -105,9 +105,9 @@ class Image extends AbstractElement } } else { $supportedTypes = array( - \IMAGETYPE_JPEG, \IMAGETYPE_GIF, - \IMAGETYPE_PNG, \IMAGETYPE_BMP, - \IMAGETYPE_TIFF_II, \IMAGETYPE_TIFF_MM + IMAGETYPE_JPEG, IMAGETYPE_GIF, + IMAGETYPE_PNG, IMAGETYPE_BMP, + IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM ); if (!file_exists($source)) { throw new InvalidImageException(); @@ -124,7 +124,7 @@ class Image extends AbstractElement if (!in_array($this->imageType, $supportedTypes)) { throw new UnsupportedImageTypeException(); } - $this->imageType = \image_type_to_mime_type($this->imageType); + $this->imageType = image_type_to_mime_type($this->imageType); } // Set private properties diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php index 49a0ca8a..fc373fbc 100644 --- a/src/PhpWord/Element/Object.php +++ b/src/PhpWord/Element/Object.php @@ -48,7 +48,7 @@ class Object extends AbstractElement $supportedTypes = array('xls', 'doc', 'ppt', 'xlsx', 'docx', 'pptx'); $inf = pathinfo($src); - if (\file_exists($src) && in_array($inf['extension'], $supportedTypes)) { + if (file_exists($src) && in_array($inf['extension'], $supportedTypes)) { $this->source = $src; $this->style = $this->setStyle(new ImageStyle(), $style, true); return $this; diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php index 76e860fe..12a00b0c 100644 --- a/src/PhpWord/Element/PreserveText.php +++ b/src/PhpWord/Element/PreserveText.php @@ -52,7 +52,7 @@ class PreserveText extends AbstractElement $this->fontStyle = $this->setStyle(new Font('text'), $styleFont); $this->paragraphStyle = $this->setStyle(new Paragraph(), $styleParagraph); - $matches = preg_split('/({.*?})/', $text, null, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY); + $matches = preg_split('/({.*?})/', $text, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); if (isset($matches[0])) { $this->text = $matches; } diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php index 29b6472f..c9bf4b63 100644 --- a/src/PhpWord/PhpWord.php +++ b/src/PhpWord/PhpWord.php @@ -100,7 +100,7 @@ class PhpWord */ public function addSection($settings = null) { - $section = new Section(\count($this->sections) + 1, $settings); + $section = new Section(count($this->sections) + 1, $settings); $this->sections[] = $section; return $section; diff --git a/src/PhpWord/Style/Tab.php b/src/PhpWord/Style/Tab.php index c28d8923..e9c044f1 100644 --- a/src/PhpWord/Style/Tab.php +++ b/src/PhpWord/Style/Tab.php @@ -75,7 +75,7 @@ class Tab extends AbstractStyle * * @param string $val Defaults to 'clear' if value is not possible. * @param int $position Must be an integer; otherwise defaults to 0. - * @param string $leader Defaults to NULL if value is not possible. + * @param string $leader Defaults to null if value is not possible. */ public function __construct($val = null, $position = 0, $leader = null) { @@ -85,7 +85,7 @@ class Tab extends AbstractStyle // Default to 0 if the position is non-numeric $this->position = (is_numeric($position)) ? intval($position) : 0; - // Default to NULL if no tab leader + // Default to null if no tab leader $this->leader = (self::isLeaderType($leader)) ? $leader : null; } diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php index 2505a76d..a1ff4bc6 100755 --- a/src/PhpWord/Writer/RTF.php +++ b/src/PhpWord/Writer/RTF.php @@ -101,22 +101,22 @@ class RTF extends AbstractWriter implements WriterInterface $sRTFContent .= '\deff0'; // Set the default tab size (720 twips) $sRTFContent .= '\deftab720'; - $sRTFContent .= \PHP_EOL; + $sRTFContent .= PHP_EOL; // Set the font tbl group $sRTFContent .= '{\fonttbl'; foreach ($this->fontTable as $idx => $font) { $sRTFContent .= '{\f' . $idx . '\fnil\fcharset0 ' . $font . ';}'; } - $sRTFContent .= '}' . \PHP_EOL; + $sRTFContent .= '}' . PHP_EOL; // Set the color tbl group $sRTFContent .= '{\colortbl '; foreach ($this->colorTable as $idx => $color) { $arrColor = Drawing::htmlToRGB($color); $sRTFContent .= ';\red' . $arrColor[0] . '\green' . $arrColor[1] . '\blue' . $arrColor[2] . ''; } - $sRTFContent .= ';}' . \PHP_EOL; + $sRTFContent .= ';}' . PHP_EOL; // Set the generator - $sRTFContent .= '{\*\generator PhpWord;}' . \PHP_EOL; + $sRTFContent .= '{\*\generator PhpWord;}' . PHP_EOL; // Set the view mode of the document $sRTFContent .= '\viewkind4'; // Set the numberof bytes that follows a unicode character @@ -131,7 +131,7 @@ class RTF extends AbstractWriter implements WriterInterface $sRTFContent .= '\kerning1'; // Set the font size in half-points $sRTFContent .= '\fs' . (PhpWord::DEFAULT_FONT_SIZE * 2); - $sRTFContent .= \PHP_EOL; + $sRTFContent .= PHP_EOL; // Body $sRTFContent .= $this->getDataContent(); @@ -392,7 +392,7 @@ class RTF extends AbstractWriter implements WriterInterface } if (!$withoutP) { - $sRTFText .= '\par' . \PHP_EOL; + $sRTFText .= '\par' . PHP_EOL; } return $sRTFText; } @@ -407,15 +407,15 @@ class RTF extends AbstractWriter implements WriterInterface $sRTFText = ''; $elements = $textrun->getElements(); if (count($elements) > 0) { - $sRTFText .= '\pard\nowidctlpar' . \PHP_EOL; + $sRTFText .= '\pard\nowidctlpar' . PHP_EOL; foreach ($elements as $element) { if ($element instanceof Text) { $sRTFText .= '{'; $sRTFText .= $this->getDataContentText($element, true); - $sRTFText .= '}' . \PHP_EOL; + $sRTFText .= '}' . PHP_EOL; } } - $sRTFText .= '\par' . \PHP_EOL; + $sRTFText .= '\par' . PHP_EOL; } return $sRTFText; } @@ -429,7 +429,7 @@ class RTF extends AbstractWriter implements WriterInterface { $this->lastParagraphStyle = ''; - return '\par' . \PHP_EOL; + return '\par' . PHP_EOL; } /** @@ -440,9 +440,9 @@ class RTF extends AbstractWriter implements WriterInterface private function getDataContentUnsupportedElement($element) { $sRTFText = ''; - $sRTFText .= '\pard\nowidctlpar' . \PHP_EOL; + $sRTFText .= '\pard\nowidctlpar' . PHP_EOL; $sRTFText .= "{$element}"; - $sRTFText .= '\par' . \PHP_EOL; + $sRTFText .= '\par' . PHP_EOL; return $sRTFText; } diff --git a/tests/PhpWord/Tests/AutoloaderTest.php b/tests/PhpWord/Tests/AutoloaderTest.php index ac2f4a78..2a021aeb 100644 --- a/tests/PhpWord/Tests/AutoloaderTest.php +++ b/tests/PhpWord/Tests/AutoloaderTest.php @@ -26,7 +26,7 @@ class AutoloaderTest extends \PHPUnit_Framework_TestCase Autoloader::register(); $this->assertContains( array('PhpOffice\\PhpWord\\Autoloader', 'autoload'), - \spl_autoload_functions() + spl_autoload_functions() ); } @@ -35,19 +35,19 @@ class AutoloaderTest extends \PHPUnit_Framework_TestCase */ public function testAutoload() { - $declared = \get_declared_classes(); - $declaredCount = \count($declared); + $declared = get_declared_classes(); + $declaredCount = count($declared); Autoloader::autoload('Foo'); $this->assertEquals( $declaredCount, - \count(get_declared_classes()), + count(get_declared_classes()), 'PhpOffice\\PhpWord\\Autoloader::autoload() is trying to load ' . 'classes outside of the PhpOffice\\PhpWord namespace' ); // TODO change this class to the main PhpWord class when it is namespaced Autoloader::autoload('PhpOffice\\PhpWord\\Exception\\InvalidStyleException'); $this->assertTrue( - \in_array('PhpOffice\\PhpWord\\Exception\\InvalidStyleException', \get_declared_classes()), + in_array('PhpOffice\\PhpWord\\Exception\\InvalidStyleException', get_declared_classes()), 'PhpOffice\\PhpWord\\Autoloader::autoload() failed to autoload the ' . 'PhpOffice\\PhpWord\\Exception\\InvalidStyleException class' ); diff --git a/tests/PhpWord/Tests/PhpWordTest.php b/tests/PhpWord/Tests/PhpWordTest.php index efef7053..8de6f808 100644 --- a/tests/PhpWord/Tests/PhpWordTest.php +++ b/tests/PhpWord/Tests/PhpWordTest.php @@ -53,7 +53,7 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $this->assertEquals(new Section(1), $phpWord->addSection()); $phpWord->addSection(); - $this->assertEquals(2, \count($phpWord->getSections())); + $this->assertEquals(2, count($phpWord->getSections())); } /** @@ -144,9 +144,9 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase */ public function testLoadTemplateException() { - $templateFqfn = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'PhpWord', 'Tests', '_files', 'templates', 'blanks.docx') + $templateFqfn = join( + DIRECTORY_SEPARATOR, + array(PHPWORD_TESTS_BASE_DIR, 'PhpWord', 'Tests', '_files', 'templates', 'blanks.docx') ); $phpWord = new PhpWord(); $phpWord->loadTemplate($templateFqfn); diff --git a/tests/PhpWord/Tests/Writer/ODTextTest.php b/tests/PhpWord/Tests/Writer/ODTextTest.php index e113c373..fad3a6c0 100644 --- a/tests/PhpWord/Tests/Writer/ODTextTest.php +++ b/tests/PhpWord/Tests/Writer/ODTextTest.php @@ -128,9 +128,9 @@ class ODTextTest extends \PHPUnit_Framework_TestCase public function testSetGetUseDiskCaching() { $object = new ODText(); - $object->setUseDiskCaching(true, \PHPWORD_TESTS_BASE_DIR); + $object->setUseDiskCaching(true, PHPWORD_TESTS_BASE_DIR); $this->assertTrue($object->getUseDiskCaching()); - $this->assertEquals(\PHPWORD_TESTS_BASE_DIR, $object->getDiskCachingDirectory()); + $this->assertEquals(PHPWORD_TESTS_BASE_DIR, $object->getDiskCachingDirectory()); } /** @@ -140,9 +140,9 @@ class ODTextTest extends \PHPUnit_Framework_TestCase */ public function testSetUseDiskCachingException() { - $dir = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'foo') + $dir = join( + DIRECTORY_SEPARATOR, + array(PHPWORD_TESTS_BASE_DIR, 'foo') ); $object = new ODText(); diff --git a/tests/PhpWord/Tests/Writer/Word2007Test.php b/tests/PhpWord/Tests/Writer/Word2007Test.php index fe80adb0..38c2e6e7 100644 --- a/tests/PhpWord/Tests/Writer/Word2007Test.php +++ b/tests/PhpWord/Tests/Writer/Word2007Test.php @@ -169,7 +169,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase $phpWord = new PhpWord(); $section = $phpWord->addSection(); $object = new Word2007($phpWord); - $object->setUseDiskCaching(true, \PHPWORD_TESTS_BASE_DIR); + $object->setUseDiskCaching(true, PHPWORD_TESTS_BASE_DIR); $writer = new Word2007($phpWord); $writer->save('php://output'); @@ -183,9 +183,9 @@ class Word2007Test extends \PHPUnit_Framework_TestCase */ public function testSetUseDiskCachingException() { - $dir = \join( - \DIRECTORY_SEPARATOR, - array(\PHPWORD_TESTS_BASE_DIR, 'foo') + $dir = join( + DIRECTORY_SEPARATOR, + array(PHPWORD_TESTS_BASE_DIR, 'foo') ); $object = new Word2007(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 9ccbd596..eb23221e 100755 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -16,11 +16,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"); @@ -35,11 +35,11 @@ spl_autoload_register(function ($class) { $class = join(DIRECTORY_SEPARATOR, array('PhpWord', 'Tests', '_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(); +\PhpOffice\PhpWord\Autoloader::register();