diff --git a/.gitignore b/.gitignore
index 66e64406..42f03ebe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,4 @@ vendor
phpword.ini
/.buildpath
/.project
+/.php_cs.cache
diff --git a/.php_cs.dist b/.php_cs.dist
new file mode 100644
index 00000000..895ed80f
--- /dev/null
+++ b/.php_cs.dist
@@ -0,0 +1,146 @@
+notName('pclzip.lib.php')
+ ->notName('OLERead.php')
+ ->in('samples')
+ ->in('src')
+ ->in('tests');
+
+return PhpCsFixer\Config::create()
+ ->setRiskyAllowed(true)
+ ->setFinder($finder)
+ ->setRules(array(
+ 'array_syntax' => array('syntax' => 'long'),
+ 'binary_operator_spaces' => array('align_double_arrow' => true),
+ 'blank_line_after_namespace' => true,
+ 'blank_line_after_opening_tag' => false,
+ 'blank_line_before_return' => true,
+ 'braces' => true,
+ 'cast_spaces' => true,
+ 'class_definition' => true,
+ 'class_keyword_remove' => false, // ::class keyword gives us beter support in IDE
+ 'combine_consecutive_unsets' => true,
+ 'concat_space' => array('spacing' => 'one'),
+ 'declare_equal_normalize' => true,
+ 'declare_strict_types' => false, // Too early to adopt strict types
+ 'dir_constant' => true,
+ 'elseif' => true,
+ 'encoding' => true,
+ 'ereg_to_preg' => true,
+ 'full_opening_tag' => true,
+ 'function_declaration' => true,
+ 'function_typehint_space' => true,
+ 'general_phpdoc_annotation_remove' => false, // No use for that
+ 'hash_to_slash_comment' => true,
+ 'header_comment' => false, // We don't use common header in all our files
+ 'heredoc_to_nowdoc' => false, // Not sure about this one
+ 'is_null' => false, // Risky
+ 'include' => true,
+ 'indentation_type' => true,
+ 'line_ending' => true,
+ 'linebreak_after_opening_tag' => true,
+ 'lowercase_cast' => true,
+ 'lowercase_constants' => true,
+ 'lowercase_keywords' => true,
+ 'mb_str_functions' => false, // No, too dangerous to change that
+ 'method_argument_space' => true,
+ 'method_separation' => true,
+ 'modernize_types_casting' => true,
+ 'native_function_casing' => true,
+ 'native_function_invocation'=> false, // This is risky and seems to be micro-optimization that make code uglier so not worth it, at least for now
+ 'new_with_braces' => true,
+ 'no_alias_functions' => true,
+ 'no_blank_lines_after_class_opening' => true,
+ 'no_blank_lines_after_phpdoc' => true,
+ 'no_blank_lines_before_namespace' => false, // we want 1 blank line before namespace
+ 'no_closing_tag' => true,
+ 'no_empty_comment' => true,
+ 'no_empty_phpdoc' => true,
+ 'no_empty_statement' => true,
+ 'no_extra_consecutive_blank_lines' => array('break', 'continue', 'extra', 'return', 'throw', 'use', 'useTrait', 'curly_brace_block', 'parenthesis_brace_block', 'square_brace_block'),
+ 'no_leading_import_slash' => true,
+ 'no_leading_namespace_whitespace' => true,
+ 'no_mixed_echo_print' => true,
+ 'no_multiline_whitespace_around_double_arrow' => true,
+ 'no_multiline_whitespace_before_semicolons' => true,
+ 'no_php4_constructor' => true,
+ 'no_short_bool_cast' => true,
+ 'no_short_echo_tag' => true,
+ 'no_singleline_whitespace_before_semicolons' => true,
+ 'no_spaces_after_function_name' => true,
+ 'no_spaces_around_offset' => true,
+ 'no_spaces_inside_parenthesis' => true,
+ 'no_trailing_comma_in_list_call' => true,
+ 'no_trailing_comma_in_singleline_array' => true,
+ 'no_trailing_whitespace' => true,
+ 'no_trailing_whitespace_in_comment' => true,
+ 'no_unneeded_control_parentheses' => true,
+ 'no_unreachable_default_argument_value' => true,
+ 'no_unused_imports' => true,
+ 'no_useless_else' => true,
+ 'no_useless_return' => true,
+ 'no_whitespace_before_comma_in_array' => true,
+ 'no_whitespace_in_blank_line' => true,
+ 'normalize_index_brace' => true,
+ 'not_operator_with_space' => false, // No we prefer to keep '!' without spaces
+ 'not_operator_with_successor_space' => false, // idem
+ 'object_operator_without_whitespace' => true,
+ 'ordered_class_elements' => false, // We prefer to keep some freedom
+ 'ordered_imports' => true,
+ 'php_unit_construct' => true,
+ 'php_unit_dedicate_assert' => true,
+ 'php_unit_fqcn_annotation' => true,
+ 'php_unit_strict' => false, // We sometime actually need assertEquals
+ 'phpdoc_add_missing_param_annotation' => true,
+ 'phpdoc_align' => false, // Waste of time
+ 'phpdoc_annotation_without_dot' => true,
+ 'phpdoc_indent' => true,
+ 'phpdoc_inline_tag' => true,
+ 'phpdoc_no_access' => true,
+ 'phpdoc_no_alias_tag' => true,
+ 'phpdoc_no_empty_return' => true,
+ 'phpdoc_no_package' => true,
+ 'phpdoc_no_useless_inheritdoc' => true,
+ 'phpdoc_order' => true,
+ 'phpdoc_return_self_reference' => true,
+ 'phpdoc_scalar' => true,
+ 'phpdoc_separation' => false,
+ 'phpdoc_single_line_var_spacing' => true,
+ 'phpdoc_summary' => false,
+ 'phpdoc_to_comment' => true,
+ 'phpdoc_trim' => true,
+ 'phpdoc_types' => true,
+ 'phpdoc_var_without_name' => true,
+ 'pow_to_exponentiation' => false,
+ 'pre_increment' => false,
+ 'protected_to_private' => true,
+ 'psr0' => true,
+ 'psr4' => true,
+ 'random_api_migration' => false, // This breaks our unit tests
+ 'return_type_declaration' => true,
+ 'self_accessor' => true,
+ 'semicolon_after_instruction' => false, // Buggy in `samples/index.php`
+ 'short_scalar_cast' => true,
+ 'silenced_deprecation_error' => true,
+ 'simplified_null_return' => false, // While technically correct we prefer to be explicit when returning null
+ 'single_blank_line_at_eof' => true,
+ 'single_blank_line_before_namespace' => true,
+ 'single_class_element_per_statement' => true,
+ 'single_import_per_statement' => true,
+ 'single_line_after_imports' => true,
+ 'single_quote' => true,
+ 'space_after_semicolon' => true,
+ 'standardize_not_equals' => true,
+ 'strict_comparison' => false, // No, too dangerous to change that
+ 'strict_param' => false, // No, too dangerous to change that
+ 'switch_case_semicolon_to_colon' => true,
+ 'switch_case_space' => true,
+ 'ternary_operator_spaces' => true,
+ 'ternary_to_null_coalescing' => false, // Cannot use that with PHP 5.6
+ 'trailing_comma_in_multiline_array' => true,
+ 'trim_array_spaces' => false,
+ 'unary_operator_spaces' => true,
+ 'visibility_required' => true,
+ 'whitespace_after_comma_in_array' => true,
+ ));
diff --git a/.travis.yml b/.travis.yml
index 3508dca3..0ec84081 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,12 +8,21 @@ php:
- 5.5
- 5.6
- 7.0
-## - hhvm
+ - 7.1
matrix:
+ include:
+ - php: 5.6
+ env: COVERAGE=1
allow_failures:
- php: 7.0
-## - php: hhvm
+ - php: 7.1
+
+cache:
+ directories:
+ - vendor
+ - $HOME/.composer/cache
+ - .php-cs.cache
env:
global:
@@ -25,6 +34,8 @@ before_install:
- sudo apt-get install -y graphviz
before_script:
+ ## Deactivate xdebug if we don't do code coverage
+ - if [ -z "$COVERAGE" ]; then phpenv config-rm xdebug.ini ; fi
## Composer
- composer self-update
- composer install --prefer-source
@@ -34,19 +45,20 @@ before_script:
script:
## PHP_CodeSniffer
- - ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
+ - if [ -z "$COVERAGE" ]; then ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip ; fi
+ ## PHP-CS-Fixer
+ - if [ -n "$COVERAGE" ]; then ./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run ; fi
## PHP Mess Detector
- - ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
+ - if [ -z "$COVERAGE" ]; then ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php ; fi
## PHPUnit
- - ./vendor/bin/phpunit -c ./ --coverage-text --coverage-html ./build/coverage
+ - ./vendor/bin/phpunit -c ./ $(if [ -n "$COVERAGE" ]; then echo --coverage-text; else echo --no-coverage; fi)
## PHPLOC
- - ./vendor/bin/phploc src/
+ - if [ -z "$COVERAGE" ]; then ./vendor/bin/phploc src/ ; fi
## PHPDocumentor
- - ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig"
+ - if [ -z "$COVERAGE" ]; then ./vendor/bin/phpdoc -q -d ./src -t ./build/docs --ignore "*/src/PhpWord/Shared/*/*" --template="responsive-twig" ; fi
after_script:
## PHPDocumentor
- bash .travis_shell_after_success.sh
## Scrutinizer
- - wget https://scrutinizer-ci.com/ocular.phar
- - php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml
+ - if [ -n "$COVERAGE" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover build/logs/clover.xml ; fi
diff --git a/.travis_shell_after_success.sh b/.travis_shell_after_success.sh
index 35c7a338..12728526 100644
--- a/.travis_shell_after_success.sh
+++ b/.travis_shell_after_success.sh
@@ -5,7 +5,7 @@ echo "TRAVIS_REPO_SLUG: $TRAVIS_REPO_SLUG"
echo "TRAVIS_PHP_VERSION: $TRAVIS_PHP_VERSION"
echo "TRAVIS_PULL_REQUEST: $TRAVIS_PULL_REQUEST"
-if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_PHP_VERSION" == "5.5" ]; then
+if [ "$TRAVIS_REPO_SLUG" == "PHPOffice/PHPWord" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_PHP_VERSION" == "5.6" ]; then
echo -e "Publishing PHPDoc...\n"
diff --git a/bootstrap.php b/bootstrap.php
index 11939fee..362e8b74 100644
--- a/bootstrap.php
+++ b/bootstrap.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. test bootstrap
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/composer.json b/composer.json
index 9cc03123..ab8b6aa6 100644
--- a/composer.json
+++ b/composer.json
@@ -39,12 +39,14 @@
"phpoffice/common": "^0.2"
},
"require-dev": {
- "phpunit/phpunit": "3.7.*",
+ "phpunit/phpunit": "4.8.*",
"phpdocumentor/phpdocumentor":"2.*",
- "squizlabs/php_codesniffer": "1.*",
+ "twig/twig":"1.27",
+ "squizlabs/php_codesniffer": "^2.7",
+ "friendsofphp/php-cs-fixer": "^2.0",
"phpmd/phpmd": "2.*",
"phploc/phploc": "2.*",
- "dompdf/dompdf":"0.6.*",
+ "dompdf/dompdf":"0.8.*",
"tecnickcom/tcpdf": "6.*",
"mpdf/mpdf": "5.*"
},
diff --git a/docs/elements.rst b/docs/elements.rst
index a35eb654..848e3f98 100644
--- a/docs/elements.rst
+++ b/docs/elements.rst
@@ -135,12 +135,12 @@ Text breaks are empty new lines. To add text breaks, use the following syntax. A
Page breaks
~~~~~~~~~~~
-There are two ways to insert a page breaks, using the ``addPageBreak``
+There are two ways to insert a page break, using the ``addPageBreak``
method or using the ``pageBreakBefore`` style of paragraph.
-:: code-block:: php
+.. code-block:: php
- \\$section->addPageBreak();
+ $section->addPageBreak();
Lists
-----
diff --git a/run_tests.sh b/run_tests.sh
new file mode 100755
index 00000000..6b81d69c
--- /dev/null
+++ b/run_tests.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+## PHP_CodeSniffer
+./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip
+
+## PHP-CS-Fixer
+./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run
+
+## PHP Mess Detector
+./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php
+
+## PHPUnit
+./vendor/bin/phpunit -c ./ --no-coverage
+
diff --git a/samples/Sample_01_SimpleText.php b/samples/Sample_01_SimpleText.php
index fae6c210..5a3393b3 100644
--- a/samples/Sample_01_SimpleText.php
+++ b/samples/Sample_01_SimpleText.php
@@ -1,6 +1,6 @@
addParagraphStyle(
new \PhpOffice\PhpWord\Style\Tab('left', 1550),
new \PhpOffice\PhpWord\Style\Tab('center', 3200),
new \PhpOffice\PhpWord\Style\Tab('right', 5300),
- )
+ ),
)
);
diff --git a/samples/Sample_07_TemplateCloneRow.php b/samples/Sample_07_TemplateCloneRow.php
index 22a68537..e845362c 100644
--- a/samples/Sample_07_TemplateCloneRow.php
+++ b/samples/Sample_07_TemplateCloneRow.php
@@ -1,62 +1,62 @@
-setValue('weekday', date('l')); // On section/content
-$templateProcessor->setValue('time', date('H:i')); // On footer
-$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
-
-// Simple table
-$templateProcessor->cloneRow('rowValue', 10);
-
-$templateProcessor->setValue('rowValue#1', 'Sun');
-$templateProcessor->setValue('rowValue#2', 'Mercury');
-$templateProcessor->setValue('rowValue#3', 'Venus');
-$templateProcessor->setValue('rowValue#4', 'Earth');
-$templateProcessor->setValue('rowValue#5', 'Mars');
-$templateProcessor->setValue('rowValue#6', 'Jupiter');
-$templateProcessor->setValue('rowValue#7', 'Saturn');
-$templateProcessor->setValue('rowValue#8', 'Uranus');
-$templateProcessor->setValue('rowValue#9', 'Neptun');
-$templateProcessor->setValue('rowValue#10', 'Pluto');
-
-$templateProcessor->setValue('rowNumber#1', '1');
-$templateProcessor->setValue('rowNumber#2', '2');
-$templateProcessor->setValue('rowNumber#3', '3');
-$templateProcessor->setValue('rowNumber#4', '4');
-$templateProcessor->setValue('rowNumber#5', '5');
-$templateProcessor->setValue('rowNumber#6', '6');
-$templateProcessor->setValue('rowNumber#7', '7');
-$templateProcessor->setValue('rowNumber#8', '8');
-$templateProcessor->setValue('rowNumber#9', '9');
-$templateProcessor->setValue('rowNumber#10', '10');
-
-// Table with a spanned cell
-$templateProcessor->cloneRow('userId', 3);
-
-$templateProcessor->setValue('userId#1', '1');
-$templateProcessor->setValue('userFirstName#1', 'James');
-$templateProcessor->setValue('userName#1', 'Taylor');
-$templateProcessor->setValue('userPhone#1', '+1 428 889 773');
-
-$templateProcessor->setValue('userId#2', '2');
-$templateProcessor->setValue('userFirstName#2', 'Robert');
-$templateProcessor->setValue('userName#2', 'Bell');
-$templateProcessor->setValue('userPhone#2', '+1 428 889 774');
-
-$templateProcessor->setValue('userId#3', '3');
-$templateProcessor->setValue('userFirstName#3', 'Michael');
-$templateProcessor->setValue('userName#3', 'Ray');
-$templateProcessor->setValue('userPhone#3', '+1 428 889 775');
-
-echo date('H:i:s'), ' Saving the result document...', EOL;
-$templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx');
-
-echo getEndingNotes(array('Word2007' => 'docx'));
-if (!CLI) {
- include_once 'Sample_Footer.php';
-}
+setValue('weekday', date('l')); // On section/content
+$templateProcessor->setValue('time', date('H:i')); // On footer
+$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
+
+// Simple table
+$templateProcessor->cloneRow('rowValue', 10);
+
+$templateProcessor->setValue('rowValue#1', 'Sun');
+$templateProcessor->setValue('rowValue#2', 'Mercury');
+$templateProcessor->setValue('rowValue#3', 'Venus');
+$templateProcessor->setValue('rowValue#4', 'Earth');
+$templateProcessor->setValue('rowValue#5', 'Mars');
+$templateProcessor->setValue('rowValue#6', 'Jupiter');
+$templateProcessor->setValue('rowValue#7', 'Saturn');
+$templateProcessor->setValue('rowValue#8', 'Uranus');
+$templateProcessor->setValue('rowValue#9', 'Neptun');
+$templateProcessor->setValue('rowValue#10', 'Pluto');
+
+$templateProcessor->setValue('rowNumber#1', '1');
+$templateProcessor->setValue('rowNumber#2', '2');
+$templateProcessor->setValue('rowNumber#3', '3');
+$templateProcessor->setValue('rowNumber#4', '4');
+$templateProcessor->setValue('rowNumber#5', '5');
+$templateProcessor->setValue('rowNumber#6', '6');
+$templateProcessor->setValue('rowNumber#7', '7');
+$templateProcessor->setValue('rowNumber#8', '8');
+$templateProcessor->setValue('rowNumber#9', '9');
+$templateProcessor->setValue('rowNumber#10', '10');
+
+// Table with a spanned cell
+$templateProcessor->cloneRow('userId', 3);
+
+$templateProcessor->setValue('userId#1', '1');
+$templateProcessor->setValue('userFirstName#1', 'James');
+$templateProcessor->setValue('userName#1', 'Taylor');
+$templateProcessor->setValue('userPhone#1', '+1 428 889 773');
+
+$templateProcessor->setValue('userId#2', '2');
+$templateProcessor->setValue('userFirstName#2', 'Robert');
+$templateProcessor->setValue('userName#2', 'Bell');
+$templateProcessor->setValue('userPhone#2', '+1 428 889 774');
+
+$templateProcessor->setValue('userId#3', '3');
+$templateProcessor->setValue('userFirstName#3', 'Michael');
+$templateProcessor->setValue('userName#3', 'Ray');
+$templateProcessor->setValue('userPhone#3', '+1 428 889 775');
+
+echo date('H:i:s'), ' Saving the result document...', EOL;
+$templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx');
+
+echo getEndingNotes(array('Word2007' => 'docx'));
+if (!CLI) {
+ include_once 'Sample_Footer.php';
+}
diff --git a/samples/Sample_08_ParagraphPagination.php b/samples/Sample_08_ParagraphPagination.php
index f91b1c56..3c21b138 100644
--- a/samples/Sample_08_ParagraphPagination.php
+++ b/samples/Sample_08_ParagraphPagination.php
@@ -19,7 +19,7 @@ $section->addText(
'Below are the samples on how to control your paragraph '
. 'pagination. See "Line and Page Break" tab on paragraph properties '
. 'window to see the attribute set by these controls.',
- array('bold' => true),
+ array('bold' => true),
array('space' => array('before' => 360, 'after' => 480))
);
diff --git a/samples/Sample_09_Tables.php b/samples/Sample_09_Tables.php
index e3edc605..c4be7c9e 100644
--- a/samples/Sample_09_Tables.php
+++ b/samples/Sample_09_Tables.php
@@ -46,11 +46,11 @@ for ($i = 1; $i <= 8; $i++) {
$table->addCell(2000)->addText("Cell {$i}");
$table->addCell(2000)->addText("Cell {$i}");
$table->addCell(2000)->addText("Cell {$i}");
- $text = (0== $i % 2) ? 'X' : '';
+ $text = (0 == $i % 2) ? 'X' : '';
$table->addCell(500)->addText($text);
}
-/**
+/*
* 3. colspan (gridSpan) and rowspan (vMerge)
* ---------------------
* | | B | |
@@ -93,7 +93,7 @@ $table->addCell(2000, $cellVCentered)->addText('C', null, $cellHCentered);
$table->addCell(2000, $cellVCentered)->addText('D', null, $cellHCentered);
$table->addCell(null, $cellRowContinue);
-/**
+/*
* 4. colspan (gridSpan) and rowspan (vMerge)
* ---------------------
* | | B | 1 |
@@ -104,6 +104,7 @@ $table->addCell(null, $cellRowContinue);
* ---------------------
* @see https://github.com/PHPOffice/PHPWord/issues/806
*/
+
$section->addPageBreak();
$section->addText('Table with colspan and rowspan', $header);
@@ -114,12 +115,12 @@ $table = $section->addTable('Colspan Rowspan');
$row = $table->addRow();
$row->addCell(null, array('vMerge' => 'restart'))->addText('A');
-$row->addCell(null, array('gridSpan' => 2, 'vMerge' => 'restart',))->addText('B');
+$row->addCell(null, array('gridSpan' => 2, 'vMerge' => 'restart'))->addText('B');
$row->addCell()->addText('1');
$row = $table->addRow();
$row->addCell(null, array('vMerge' => 'continue'));
-$row->addCell(null, array('vMerge' => 'continue','gridSpan' => 2,));
+$row->addCell(null, array('vMerge' => 'continue', 'gridSpan' => 2));
$row->addCell()->addText('2');
$row = $table->addRow();
$row->addCell(null, array('vMerge' => 'continue'));
diff --git a/samples/Sample_13_Images.php b/samples/Sample_13_Images.php
index 1e6943db..6c7033b0 100644
--- a/samples/Sample_13_Images.php
+++ b/samples/Sample_13_Images.php
@@ -23,7 +23,7 @@ $section->addImage($source);
// Image from string
$source = 'resources/_mars.jpg';
$fileContent = file_get_contents($source);
-$section->addText("Image from string");
+$section->addText('Image from string');
$section->addImage($fileContent);
//Wrapping style
diff --git a/samples/Sample_37_Comments.php b/samples/Sample_37_Comments.php
index 670e914b..5c0e8abc 100644
--- a/samples/Sample_37_Comments.php
+++ b/samples/Sample_37_Comments.php
@@ -47,7 +47,7 @@ $image->setCommentRangeStart($commentOnImage);
$section->addTextBreak(2);
// We can also do things the other way round, link the comment to the element
-$anotherText = $section->addText("another text");
+$anotherText = $section->addText('another text');
$comment1 = new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials');
$comment1->addText('Test', array('bold' => true));
@@ -55,7 +55,6 @@ $comment1->setStartElement($anotherText);
$comment1->setEndElement($anotherText);
$phpWord->addComment($comment1);
-
// Save file
echo write($phpWord, basename(__FILE__, '.php'), $writers);
if (!CLI) {
diff --git a/samples/Sample_Header.php b/samples/Sample_Header.php
index 90bdf4fa..1d6b14a1 100644
--- a/samples/Sample_Header.php
+++ b/samples/Sample_Header.php
@@ -89,8 +89,8 @@ function getEndingNotes($writers)
// Do not show execution time for index
if (!IS_INDEX) {
- $result .= date('H:i:s') . " Done writing file(s)" . EOL;
- $result .= date('H:i:s') . " Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB" . EOL;
+ $result .= date('H:i:s') . ' Done writing file(s)' . EOL;
+ $result .= date('H:i:s') . ' Peak memory usage: ' . (memory_get_peak_usage(true) / 1024 / 1024) . ' MB' . EOL;
}
// Return
diff --git a/samples/index.php b/samples/index.php
index a65d8fd9..3dbc09ff 100644
--- a/samples/index.php
+++ b/samples/index.php
@@ -13,7 +13,7 @@ $requirements = array(
'xsl' => array('PHP extension XSL (optional)', extension_loaded('xsl')),
);
if (!CLI) {
-?>
+ ?>
Welcome to PHPWord, a library written in pure PHP that provides a set of classes to write to and read from different document file formats, i.e. Office Open XML (.docx), Open Document Format (.odt), and Rich Text Format (.rtf).
@@ -25,14 +25,14 @@ if (!CLI) {
Requirement check:";
- echo "
";
+ echo 'Requirement check:
';
+ echo '';
foreach ($requirements as $key => $value) {
list($label, $result) = $value;
$status = $result ? 'passed' : 'failed';
echo "- {$label} ... {$status}
";
}
- echo "
";
+ echo '
';
include_once 'Sample_Footer.php';
} else {
echo 'Requirement check:' . PHP_EOL;
diff --git a/src/PhpWord/Collection/AbstractCollection.php b/src/PhpWord/Collection/AbstractCollection.php
index beff290e..61709a50 100644
--- a/src/PhpWord/Collection/AbstractCollection.php
+++ b/src/PhpWord/Collection/AbstractCollection.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -51,9 +51,9 @@ abstract class AbstractCollection
{
if (array_key_exists($index, $this->items)) {
return $this->items[$index];
- } else {
- return null;
}
+
+ return null;
}
/**
@@ -61,7 +61,6 @@ abstract class AbstractCollection
*
* @param int $index
* @param mixed $item
- * @return void
*/
public function setItem($index, $item)
{
diff --git a/src/PhpWord/Collection/Bookmarks.php b/src/PhpWord/Collection/Bookmarks.php
index b263cda7..7210fb03 100644
--- a/src/PhpWord/Collection/Bookmarks.php
+++ b/src/PhpWord/Collection/Bookmarks.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Collection/Charts.php b/src/PhpWord/Collection/Charts.php
index 01f3f72e..56d92c94 100644
--- a/src/PhpWord/Collection/Charts.php
+++ b/src/PhpWord/Collection/Charts.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Collection/Comments.php b/src/PhpWord/Collection/Comments.php
index e0383814..f2fe82d9 100644
--- a/src/PhpWord/Collection/Comments.php
+++ b/src/PhpWord/Collection/Comments.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Collection/Endnotes.php b/src/PhpWord/Collection/Endnotes.php
index 083142ed..52a56d31 100644
--- a/src/PhpWord/Collection/Endnotes.php
+++ b/src/PhpWord/Collection/Endnotes.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Collection/Footnotes.php b/src/PhpWord/Collection/Footnotes.php
index 0c094a53..63989f53 100644
--- a/src/PhpWord/Collection/Footnotes.php
+++ b/src/PhpWord/Collection/Footnotes.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Collection/Titles.php b/src/PhpWord/Collection/Titles.php
index 80e2d9d7..9e4f12cd 100644
--- a/src/PhpWord/Collection/Titles.php
+++ b/src/PhpWord/Collection/Titles.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/ComplexType/FootnoteProperties.php b/src/PhpWord/ComplexType/FootnoteProperties.php
index 0c1fb40e..8cb3a869 100644
--- a/src/PhpWord/ComplexType/FootnoteProperties.php
+++ b/src/PhpWord/ComplexType/FootnoteProperties.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\ComplexType;
use PhpOffice\PhpWord\SimpleType\NumberFormat;
@@ -25,7 +26,6 @@ use PhpOffice\PhpWord\SimpleType\NumberFormat;
*/
final class FootnoteProperties
{
-
const RESTART_NUMBER_CONTINUOUS = 'continuous';
const RESTART_NUMBER_EACH_SECTION = 'eachSect';
const RESTART_NUMBER_EACH_PAGE = 'eachPage';
@@ -52,7 +52,7 @@ final class FootnoteProperties
/**
* Footnote and Endnote Numbering Starting Value
*
- * @var double
+ * @var float
*/
private $numStart;
@@ -86,14 +86,15 @@ final class FootnoteProperties
self::POSITION_PAGE_BOTTOM,
self::POSITION_BENEATH_TEXT,
self::POSITION_SECTION_END,
- self::POSITION_DOC_END
+ self::POSITION_DOC_END,
);
if (in_array($pos, $position)) {
$this->pos = $pos;
} else {
- throw new \InvalidArgumentException("Invalid value, on of " . implode(', ', $position) . " possible");
+ throw new \InvalidArgumentException('Invalid value, on of ' . implode(', ', $position) . ' possible');
}
+
return $this;
}
@@ -117,13 +118,14 @@ final class FootnoteProperties
{
NumberFormat::validate($numFmt);
$this->numFmt = $numFmt;
+
return $this;
}
/**
* Get the Footnote Numbering Format
*
- * @return double
+ * @return float
*/
public function getNumStart()
{
@@ -133,12 +135,13 @@ final class FootnoteProperties
/**
* Set the Footnote Numbering Format
*
- * @param double $numStart
+ * @param float $numStart
* @return self
*/
public function setNumStart($numStart)
{
$this->numStart = $numStart;
+
return $this;
}
@@ -164,14 +167,15 @@ final class FootnoteProperties
$restartNumbers = array(
self::RESTART_NUMBER_CONTINUOUS,
self::RESTART_NUMBER_EACH_SECTION,
- self::RESTART_NUMBER_EACH_PAGE
+ self::RESTART_NUMBER_EACH_PAGE,
);
if (in_array($numRestart, $restartNumbers)) {
- $this->numRestart= $numRestart;
+ $this->numRestart = $numRestart;
} else {
- throw new \InvalidArgumentException("Invalid value, on of " . implode(', ', $restartNumbers) . " possible");
+ throw new \InvalidArgumentException('Invalid value, on of ' . implode(', ', $restartNumbers) . ' possible');
}
+
return $this;
}
}
diff --git a/src/PhpWord/ComplexType/ProofState.php b/src/PhpWord/ComplexType/ProofState.php
index daa705dd..6a915da1 100644
--- a/src/PhpWord/ComplexType/ProofState.php
+++ b/src/PhpWord/ComplexType/ProofState.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\ComplexType;
/**
@@ -23,7 +24,6 @@ namespace PhpOffice\PhpWord\ComplexType;
*/
final class ProofState
{
-
/**
* Check Completed
*/
@@ -60,8 +60,9 @@ final class ProofState
if ($spelling == self::CLEAN || $spelling == self::DIRTY) {
$this->spelling = $spelling;
} else {
- throw new \InvalidArgumentException("Invalid value, dirty or clean possible");
+ throw new \InvalidArgumentException('Invalid value, dirty or clean possible');
}
+
return $this;
}
@@ -87,8 +88,9 @@ final class ProofState
if ($grammar == self::CLEAN || $grammar == self::DIRTY) {
$this->grammar = $grammar;
} else {
- throw new \InvalidArgumentException("Invalid value, dirty or clean possible");
+ throw new \InvalidArgumentException('Invalid value, dirty or clean possible');
}
+
return $this;
}
diff --git a/src/PhpWord/ComplexType/TrackChangesView.php b/src/PhpWord/ComplexType/TrackChangesView.php
index 9c8948ae..3fc16298 100644
--- a/src/PhpWord/ComplexType/TrackChangesView.php
+++ b/src/PhpWord/ComplexType/TrackChangesView.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\ComplexType;
/**
@@ -23,46 +24,45 @@ namespace PhpOffice\PhpWord\ComplexType;
*/
final class TrackChangesView
{
-
/**
* Display Visual Indicator Of Markup Area
*
- * @var boolean
+ * @var bool
*/
private $markup;
/**
* Display Comments
*
- * @var boolean
+ * @var bool
*/
private $comments;
/**
* Display Content Revisions
*
- * @var boolean
+ * @var bool
*/
private $insDel;
/**
* Display Formatting Revisions
*
- * @var boolean
+ * @var bool
*/
private $formatting;
/**
* Display Ink Annotations
*
- * @var boolean
+ * @var bool
*/
private $inkAnnotations;
/**
* Get Display Visual Indicator Of Markup Area
*
- * @return boolean True if markup is shown
+ * @return bool True if markup is shown
*/
public function hasMarkup()
{
@@ -72,7 +72,7 @@ final class TrackChangesView
/**
* Set Display Visual Indicator Of Markup Area
*
- * @param boolean $markup
+ * @param bool $markup
* Set to true to show markup
*/
public function setMarkup($markup)
@@ -83,7 +83,7 @@ final class TrackChangesView
/**
* Get Display Comments
*
- * @return boolean True if comments are shown
+ * @return bool True if comments are shown
*/
public function hasComments()
{
@@ -93,7 +93,7 @@ final class TrackChangesView
/**
* Set Display Comments
*
- * @param boolean $comments
+ * @param bool $comments
* Set to true to show comments
*/
public function setComments($comments)
@@ -104,7 +104,7 @@ final class TrackChangesView
/**
* Get Display Content Revisions
*
- * @return boolean True if content revisions are shown
+ * @return bool True if content revisions are shown
*/
public function hasInsDel()
{
@@ -114,7 +114,7 @@ final class TrackChangesView
/**
* Set Display Content Revisions
*
- * @param boolean $insDel
+ * @param bool $insDel
* Set to true to show content revisions
*/
public function setInsDel($insDel)
@@ -125,7 +125,7 @@ final class TrackChangesView
/**
* Get Display Formatting Revisions
*
- * @return boolean True if formatting revisions are shown
+ * @return bool True if formatting revisions are shown
*/
public function hasFormatting()
{
@@ -135,7 +135,7 @@ final class TrackChangesView
/**
* Set Display Formatting Revisions
*
- * @param boolean|null $formatting
+ * @param bool|null $formatting
* Set to true to show formatting revisions
*/
public function setFormatting($formatting = null)
@@ -146,7 +146,7 @@ final class TrackChangesView
/**
* Get Display Ink Annotations
*
- * @return boolean True if ink annotations are shown
+ * @return bool True if ink annotations are shown
*/
public function hasInkAnnotations()
{
@@ -156,7 +156,7 @@ final class TrackChangesView
/**
* Set Display Ink Annotations
*
- * @param boolean $inkAnnotations
+ * @param bool $inkAnnotations
* Set to true to show ink annotations
*/
public function setInkAnnotations($inkAnnotations)
diff --git a/src/PhpWord/Element/AbstractContainer.php b/src/PhpWord/Element/AbstractContainer.php
index d5b4cc62..75153499 100644
--- a/src/PhpWord/Element/AbstractContainer.php
+++ b/src/PhpWord/Element/AbstractContainer.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,7 +37,7 @@ namespace PhpOffice\PhpWord\Element;
* @method PageBreak addPageBreak()
* @method Table addTable(mixed $style = null)
* @method Image addImage(string $source, mixed $style = null, bool $isWatermark = false)
- * @method Object addObject(string $source, mixed $style = null)
+ * @method \PhpOffice\PhpWord\Element\Object addObject(string $source, mixed $style = null)
* @method TextBox addTextBox(mixed $style = null)
* @method Field addField(string $type = null, array $properties = array(), array $options = array(), mixed $text = null)
* @method Line addLine(mixed $lineStyle = null)
@@ -83,7 +83,7 @@ abstract class AbstractContainer extends AbstractElement
'ListItem', 'ListItemRun', 'Table', 'Image', 'Object',
'Footnote', 'Endnote', 'CheckBox', 'TextBox', 'Field',
'Line', 'Shape', 'Title', 'TOC', 'PageBreak',
- 'Chart', 'FormField', 'SDT', 'Comment'
+ 'Chart', 'FormField', 'SDT', 'Comment',
);
$functions = array();
foreach ($elements as $element) {
@@ -105,9 +105,8 @@ abstract class AbstractContainer extends AbstractElement
for ($i = 1; $i <= $count; $i++) {
$this->addElement($element, $fontStyle, $paragraphStyle);
}
-
- // All other elements
} else {
+ // All other elements
array_unshift($args, $element); // Prepend element name to the beginning of args array
return call_user_func_array(array($this, 'addElement'), $args);
}
@@ -181,9 +180,8 @@ abstract class AbstractContainer extends AbstractElement
*
* @param string $method
*
- * @return bool
- *
* @throws \BadMethodCallException
+ * @return bool
*/
private function checkValidity($method)
{
diff --git a/src/PhpWord/Element/AbstractElement.php b/src/PhpWord/Element/AbstractElement.php
index 4ff4978a..81e18528 100644
--- a/src/PhpWord/Element/AbstractElement.php
+++ b/src/PhpWord/Element/AbstractElement.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -73,7 +73,7 @@ abstract class AbstractElement
/**
* Unique Id for element
*
- * @var int
+ * @var string
*/
protected $elementId;
@@ -142,7 +142,6 @@ abstract class AbstractElement
* Set PhpWord as reference.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
- * @return void
*/
public function setPhpWord(PhpWord $phpWord = null)
{
@@ -164,7 +163,6 @@ abstract class AbstractElement
*
* @param string $docPart
* @param int $docPartId
- * @return void
*/
public function setDocPart($docPart, $docPartId = 1)
{
@@ -221,7 +219,6 @@ abstract class AbstractElement
* Set element index.
*
* @param int $value
- * @return void
*/
public function setElementIndex($value)
{
@@ -231,7 +228,7 @@ abstract class AbstractElement
/**
* Get element unique ID
*
- * @return integer
+ * @return int
*/
public function getElementId()
{
@@ -240,8 +237,6 @@ abstract class AbstractElement
/**
* Set element unique ID from 6 first digit of md5.
- *
- * @return void
*/
public function setElementId()
{
@@ -262,7 +257,6 @@ abstract class AbstractElement
* Set relation Id.
*
* @param int $value
- * @return void
*/
public function setRelationId($value)
{
@@ -297,9 +291,9 @@ abstract class AbstractElement
public function setCommentRangeStart(Comment $value)
{
if ($this instanceof Comment) {
- throw new \InvalidArgumentException("Cannot set a Comment on a Comment");
+ throw new \InvalidArgumentException('Cannot set a Comment on a Comment');
}
- $this->commentRangeStart= $value;
+ $this->commentRangeStart = $value;
$this->commentRangeStart->setStartElement($this);
}
@@ -317,14 +311,13 @@ abstract class AbstractElement
* Set comment end
*
* @param Comment $value
- * @return void
*/
public function setCommentRangeEnd(Comment $value)
{
if ($this instanceof Comment) {
- throw new \InvalidArgumentException("Cannot set a Comment on a Comment");
+ throw new \InvalidArgumentException('Cannot set a Comment on a Comment');
}
- $this->commentRangeEnd= $value;
+ $this->commentRangeEnd = $value;
$this->commentRangeEnd->setEndElement($this);
}
@@ -334,7 +327,6 @@ abstract class AbstractElement
* Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)
*
* @param \PhpOffice\PhpWord\Element\AbstractElement $container
- * @return void
*/
public function setParentContainer(AbstractElement $container)
{
@@ -363,8 +355,6 @@ abstract class AbstractElement
*
* - Image element needs to be passed to Media object
* - Icon needs to be set for Object element
- *
- * @return void
*/
private function setMediaRelation()
{
@@ -391,8 +381,6 @@ abstract class AbstractElement
/**
* Set relation Id for elements that will be registered in the Collection subnamespaces.
- *
- * @return void
*/
private function setCollectionRelation()
{
@@ -411,7 +399,7 @@ abstract class AbstractElement
*/
public function isInSection()
{
- return ($this->docPart == 'Section');
+ return $this->docPart == 'Section';
}
/**
@@ -441,9 +429,8 @@ abstract class AbstractElement
* @param array $enum
* @param mixed $default
*
- * @return mixed
- *
* @throws \InvalidArgumentException
+ * @return mixed
*
* @todo Merge with the same method in AbstractStyle
*/
diff --git a/src/PhpWord/Element/Bookmark.php b/src/PhpWord/Element/Bookmark.php
index 4df06afb..2eceb5ed 100644
--- a/src/PhpWord/Element/Bookmark.php
+++ b/src/PhpWord/Element/Bookmark.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Cell.php b/src/PhpWord/Element/Cell.php
index 28e517fd..b5250cd6 100644
--- a/src/PhpWord/Element/Cell.php
+++ b/src/PhpWord/Element/Cell.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Chart.php b/src/PhpWord/Element/Chart.php
index f98c1d74..c340da40 100644
--- a/src/PhpWord/Element/Chart.php
+++ b/src/PhpWord/Element/Chart.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -83,7 +83,6 @@ class Chart extends AbstractElement
* Set type.
*
* @param string $value
- * @return void
*/
public function setType($value)
{
@@ -96,7 +95,6 @@ class Chart extends AbstractElement
*
* @param array $categories
* @param array $values
- * @return void
*/
public function addSeries($categories, $values)
{
diff --git a/src/PhpWord/Element/CheckBox.php b/src/PhpWord/Element/CheckBox.php
index b049c7f1..e0a94fdf 100644
--- a/src/PhpWord/Element/CheckBox.php
+++ b/src/PhpWord/Element/CheckBox.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Comment.php b/src/PhpWord/Element/Comment.php
index 5e0ebe63..a8f39748 100644
--- a/src/PhpWord/Element/Comment.php
+++ b/src/PhpWord/Element/Comment.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Endnote.php b/src/PhpWord/Element/Endnote.php
index 2d8e4731..6565c039 100644
--- a/src/PhpWord/Element/Endnote.php
+++ b/src/PhpWord/Element/Endnote.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Field.php b/src/PhpWord/Element/Field.php
index 380d7a92..726938b5 100644
--- a/src/PhpWord/Element/Field.php
+++ b/src/PhpWord/Element/Field.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,7 +21,7 @@ namespace PhpOffice\PhpWord\Element;
* Field element
*
* @since 0.11.0
- * @link http://www.schemacentral.com/sc/ooxml/t-w_CT_SimpleField.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-w_CT_SimpleField.html
*/
class Field extends AbstractElement
{
@@ -32,36 +32,36 @@ class Field extends AbstractElement
* @var array
*/
protected $fieldsArray = array(
- 'PAGE'=>array(
- 'properties'=>array(
+ 'PAGE' => array(
+ 'properties' => array(
'format' => array('Arabic', 'ArabicDash', 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN'),
),
- 'options'=>array('PreserveFormat')
+ 'options' => array('PreserveFormat'),
),
- 'NUMPAGES'=>array(
- 'properties'=>array(
+ 'NUMPAGES' => array(
+ 'properties' => array(
'format' => array('Arabic', 'ArabicDash', 'CardText', 'DollarText', 'Ordinal', 'OrdText',
- 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper'),
- 'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%')
+ 'alphabetic', 'ALPHABETIC', 'roman', 'ROMAN', 'Caps', 'FirstCap', 'Lower', 'Upper', ),
+ 'numformat' => array('0', '0,00', '#.##0', '#.##0,00', '€ #.##0,00(€ #.##0,00)', '0%', '0,00%'),
),
- 'options'=>array('PreserveFormat')
+ 'options' => array('PreserveFormat'),
),
- 'DATE'=>array(
- 'properties'=> array(
- 'dateformat' =>array('d-M-yyyy', 'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-M-yy', 'yyyy-MM-dd',
+ 'DATE' => array(
+ 'properties' => array(
+ 'dateformat' => array('d-M-yyyy', 'dddd d MMMM yyyy', 'd MMMM yyyy', 'd-M-yy', 'yyyy-MM-dd',
'd-MMM-yy', 'd/M/yyyy', 'd MMM. yy', 'd/M/yy', 'MMM-yy', 'd-M-yyy H:mm', 'd-M-yyyy H:mm:ss',
- 'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss')
+ 'h:mm am/pm', 'h:mm:ss am/pm', 'HH:mm', 'HH:mm:ss', ),
),
- 'options'=>array('PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat')
+ 'options' => array('PreserveFormat', 'LunarCalendar', 'SakaEraCalendar', 'LastUsedFormat'),
),
- 'XE'=>array(
+ 'XE' => array(
'properties' => array(),
- 'options' => array('Bold', 'Italic')
+ 'options' => array('Bold', 'Italic'),
),
- 'INDEX'=>array(
+ 'INDEX' => array(
'properties' => array(),
- 'options' => array('PreserveFormat')
- )
+ 'options' => array('PreserveFormat'),
+ ),
);
/**
@@ -113,9 +113,8 @@ class Field extends AbstractElement
*
* @param string $type
*
- * @return string
- *
* @throws \InvalidArgumentException
+ * @return string
*/
public function setType($type = null)
{
@@ -126,6 +125,7 @@ class Field extends AbstractElement
throw new \InvalidArgumentException("Invalid type '$type'");
}
}
+
return $this->type;
}
@@ -144,9 +144,8 @@ class Field extends AbstractElement
*
* @param array $properties
*
- * @return self
- *
* @throws \InvalidArgumentException
+ * @return self
*/
public function setProperties($properties = array())
{
@@ -158,6 +157,7 @@ class Field extends AbstractElement
}
$this->properties = array_merge($this->properties, $properties);
}
+
return $this->properties;
}
@@ -176,9 +176,8 @@ class Field extends AbstractElement
*
* @param array $options
*
- * @return self
- *
* @throws \InvalidArgumentException
+ * @return self
*/
public function setOptions($options = array())
{
@@ -190,6 +189,7 @@ class Field extends AbstractElement
}
$this->options = array_merge($this->options, $options);
}
+
return $this->options;
}
@@ -208,9 +208,8 @@ class Field extends AbstractElement
*
* @param string | TextRun $text
*
- * @return string | TextRun
- *
* @throws \InvalidArgumentException
+ * @return string | TextRun
*/
public function setText($text)
{
@@ -218,9 +217,10 @@ class Field extends AbstractElement
if (is_string($text) || $text instanceof TextRun) {
$this->text = $text;
} else {
- throw new \InvalidArgumentException("Invalid text");
+ throw new \InvalidArgumentException('Invalid text');
}
}
+
return $this->text;
}
diff --git a/src/PhpWord/Element/Footer.php b/src/PhpWord/Element/Footer.php
index b3196f3f..08ff525a 100644
--- a/src/PhpWord/Element/Footer.php
+++ b/src/PhpWord/Element/Footer.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,11 +26,11 @@ class Footer extends AbstractContainer
* Header/footer types constants
*
* @var string
- * @link http://www.datypic.com/sc/ooxml/t-w_ST_HdrFtr.html Header or Footer Type
+ * @see http://www.datypic.com/sc/ooxml/t-w_ST_HdrFtr.html Header or Footer Type
*/
- const AUTO = 'default'; // default and odd pages
+ const AUTO = 'default'; // default and odd pages
const FIRST = 'first';
- const EVEN = 'even';
+ const EVEN = 'even';
/**
* @var string Container type
@@ -64,7 +64,6 @@ class Footer extends AbstractContainer
* @since 0.10.0
*
* @param string $value
- * @return void
*/
public function setType($value = self::AUTO)
{
diff --git a/src/PhpWord/Element/Footnote.php b/src/PhpWord/Element/Footnote.php
index 73350bb7..9acdc4c3 100644
--- a/src/PhpWord/Element/Footnote.php
+++ b/src/PhpWord/Element/Footnote.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/FormField.php b/src/PhpWord/Element/FormField.php
index 414714a8..1e3e182c 100644
--- a/src/PhpWord/Element/FormField.php
+++ b/src/PhpWord/Element/FormField.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,7 +21,7 @@ namespace PhpOffice\PhpWord\Element;
* Form field element
*
* @since 0.12.0
- * @link http://www.datypic.com/sc/ooxml/t-w_CT_FFData.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_CT_FFData.html
*/
class FormField extends Text
{
diff --git a/src/PhpWord/Element/Header.php b/src/PhpWord/Element/Header.php
index d4afdb86..ee820877 100644
--- a/src/PhpWord/Element/Header.php
+++ b/src/PhpWord/Element/Header.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Image.php b/src/PhpWord/Element/Image.php
index 1c8c520d..c9620b6b 100644
--- a/src/PhpWord/Element/Image.php
+++ b/src/PhpWord/Element/Image.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -61,7 +61,7 @@ class Image extends AbstractElement
/**
* Is watermark
*
- * @var boolean
+ * @var bool
*/
private $watermark;
@@ -96,7 +96,7 @@ class Image extends AbstractElement
/**
* Is memory image
*
- * @var boolean
+ * @var bool
*/
private $memoryImage;
@@ -110,7 +110,7 @@ class Image extends AbstractElement
/**
* Image media index
*
- * @var integer
+ * @var int
*/
private $mediaIndex;
@@ -126,7 +126,7 @@ class Image extends AbstractElement
*
* @param string $source
* @param mixed $style
- * @param boolean $watermark
+ * @param bool $watermark
*
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
@@ -183,7 +183,7 @@ class Image extends AbstractElement
/**
* Get is watermark
*
- * @return boolean
+ * @return bool
*/
public function isWatermark()
{
@@ -193,7 +193,7 @@ class Image extends AbstractElement
/**
* Set is watermark
*
- * @param boolean $value
+ * @param bool $value
*/
public function setIsWatermark($value)
{
@@ -243,7 +243,7 @@ class Image extends AbstractElement
/**
* Get is memory image
*
- * @return boolean
+ * @return bool
*/
public function isMemImage()
{
@@ -264,7 +264,6 @@ class Image extends AbstractElement
* Set target file name.
*
* @param string $value
- * @return void
*/
public function setTarget($value)
{
@@ -274,7 +273,7 @@ class Image extends AbstractElement
/**
* Get media index
*
- * @return integer
+ * @return int
*/
public function getMediaIndex()
{
@@ -284,8 +283,7 @@ class Image extends AbstractElement
/**
* Set media index.
*
- * @param integer $value
- * @return void
+ * @param int $value
*/
public function setMediaIndex($value)
{
@@ -368,8 +366,6 @@ class Image extends AbstractElement
/**
* Check memory image, supported type, image functions, and proportional width/height.
*
- * @return void
- *
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
*/
@@ -380,7 +376,7 @@ class Image extends AbstractElement
// Check image data
if ($this->sourceType == self::SOURCE_ARCHIVE) {
$imageData = $this->getArchiveImageSize($this->source);
- } else if ($this->sourceType == self::SOURCE_STRING) {
+ } elseif ($this->sourceType == self::SOURCE_STRING) {
$imageData = $this->getStringImageSize($this->source);
} else {
$imageData = @getimagesize($this->source);
@@ -407,8 +403,6 @@ class Image extends AbstractElement
/**
* Set source type.
- *
- * @return void
*/
private function setSourceType()
{
@@ -443,9 +437,9 @@ class Image extends AbstractElement
*
* @param string $source
*
- * @return array|null
- *
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
+ *
+ * @return array|null
*/
private function getArchiveImageSize($source)
{
@@ -483,19 +477,19 @@ class Image extends AbstractElement
*/
private function getStringImageSize($source)
{
+ $result = false;
if (!function_exists('getimagesizefromstring')) {
- $uri = 'data://application/octet-stream;base64,' . base64_encode($source);
- return @getimagesize($uri);
+ $uri = 'data://application/octet-stream;base64,' . base64_encode($source);
+ $result = @getimagesize($uri);
} else {
- return @getimagesizefromstring($source);
+ $result = @getimagesizefromstring($source);
}
- return false;
+
+ return $result;
}
/**
* Set image functions and extensions.
- *
- * @return void
*/
private function setFunctions()
{
@@ -530,9 +524,8 @@ class Image extends AbstractElement
/**
* Set proportional width/height if one dimension not available.
*
- * @param integer $actualWidth
- * @param integer $actualHeight
- * @return void
+ * @param int $actualWidth
+ * @param int $actualHeight
*/
private function setProportionalSize($actualWidth, $actualHeight)
{
diff --git a/src/PhpWord/Element/Line.php b/src/PhpWord/Element/Line.php
index 3e94a3a6..eba66473 100644
--- a/src/PhpWord/Element/Line.php
+++ b/src/PhpWord/Element/Line.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Link.php b/src/PhpWord/Element/Link.php
index 6641b46d..4637120a 100644
--- a/src/PhpWord/Element/Link.php
+++ b/src/PhpWord/Element/Link.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -75,6 +75,7 @@ class Link extends AbstractElement
* @param string $text
* @param mixed $fontStyle
* @param mixed $paragraphStyle
+ * @param bool $internal
*/
public function __construct($source, $text = null, $fontStyle = null, $paragraphStyle = null, $internal = false)
{
diff --git a/src/PhpWord/Element/ListItem.php b/src/PhpWord/Element/ListItem.php
index 25ace090..7f665b1b 100644
--- a/src/PhpWord/Element/ListItem.php
+++ b/src/PhpWord/Element/ListItem.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/ListItemRun.php b/src/PhpWord/Element/ListItemRun.php
index 53440db6..5286f662 100644
--- a/src/PhpWord/Element/ListItemRun.php
+++ b/src/PhpWord/Element/ListItemRun.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
-* @link https://github.com/PHPOffice/PHPWord
-* @copyright 2010-2016 PHPWord contributors
+* @see https://github.com/PHPOffice/PHPWord
+* @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -74,10 +74,10 @@ class ListItemRun extends TextRun
return $this->style;
}
- /**
+ /**
* Get ListItem depth.
- *
- * @return int
+ *
+ * @return int
*/
public function getDepth()
{
diff --git a/src/PhpWord/Element/Object.php b/src/PhpWord/Element/Object.php
index 7285030c..8fe83224 100644
--- a/src/PhpWord/Element/Object.php
+++ b/src/PhpWord/Element/Object.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -84,9 +84,9 @@ class Object extends AbstractElement
$this->icon = realpath(__DIR__ . "/../resources/{$ext}.png");
return $this;
- } else {
- throw new InvalidObjectException();
}
+
+ throw new InvalidObjectException();
}
/**
@@ -133,7 +133,6 @@ class Object extends AbstractElement
* Set Image Relation ID.
*
* @param int $rId
- * @return void
*/
public function setImageRelationId($rId)
{
diff --git a/src/PhpWord/Element/PageBreak.php b/src/PhpWord/Element/PageBreak.php
index d9d4bc64..e41e807b 100644
--- a/src/PhpWord/Element/PageBreak.php
+++ b/src/PhpWord/Element/PageBreak.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/PreserveText.php b/src/PhpWord/Element/PreserveText.php
index 813c1396..ad20d7a3 100644
--- a/src/PhpWord/Element/PreserveText.php
+++ b/src/PhpWord/Element/PreserveText.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -47,7 +47,6 @@ class PreserveText extends AbstractElement
*/
private $paragraphStyle;
-
/**
* Create a new Preserve Text Element
*
diff --git a/src/PhpWord/Element/Row.php b/src/PhpWord/Element/Row.php
index 05fde7e4..2e89b354 100644
--- a/src/PhpWord/Element/Row.php
+++ b/src/PhpWord/Element/Row.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/SDT.php b/src/PhpWord/Element/SDT.php
index b0c68b0f..88ee7238 100644
--- a/src/PhpWord/Element/SDT.php
+++ b/src/PhpWord/Element/SDT.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Section.php b/src/PhpWord/Element/Section.php
index e9beffcf..ffc98435 100644
--- a/src/PhpWord/Element/Section.php
+++ b/src/PhpWord/Element/Section.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -73,7 +73,6 @@ class Section extends AbstractContainer
* Set section style.
*
* @param array $style
- * @return void
*/
public function setStyle($style = null)
{
@@ -172,7 +171,7 @@ class Section extends AbstractContainer
* If any of the Header instances have a type of Header::FIRST then this method returns true.
* False otherwise.
*
- * @return boolean
+ * @return bool
*/
public function hasDifferentFirstPage()
{
@@ -186,6 +185,7 @@ class Section extends AbstractContainer
return true;
}
}
+
return false;
}
@@ -195,11 +195,11 @@ class Section extends AbstractContainer
* @since 0.10.0
*
* @param string $type
- * @param boolean $header
- *
- * @return Header|Footer
+ * @param bool $header
*
* @throws \Exception
+ *
+ * @return Header|Footer
*/
private function addHeaderFooter($type = Header::AUTO, $header = true)
{
@@ -215,10 +215,10 @@ class Section extends AbstractContainer
$container->setPhpWord($this->phpWord);
$collection[$index] = $container;
+
return $container;
- } else {
- throw new \Exception('Invalid header/footer type.');
}
+ throw new \Exception('Invalid header/footer type.');
}
/**
@@ -290,8 +290,8 @@ class Section extends AbstractContainer
{
if (empty($this->footers)) {
return null;
- } else {
- return $this->footers[1];
}
+
+ return $this->footers[1];
}
}
diff --git a/src/PhpWord/Element/Shape.php b/src/PhpWord/Element/Shape.php
index 4717afb8..b553a4ac 100644
--- a/src/PhpWord/Element/Shape.php
+++ b/src/PhpWord/Element/Shape.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/TOC.php b/src/PhpWord/Element/TOC.php
index d3ab2be1..e3ca0a08 100644
--- a/src/PhpWord/Element/TOC.php
+++ b/src/PhpWord/Element/TOC.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -54,14 +54,13 @@ class TOC extends AbstractElement
*/
private $maxDepth = 9;
-
/**
* Create a new Table-of-Contents Element
*
* @param mixed $fontStyle
* @param array $tocStyle
- * @param integer $minDepth
- * @param integer $maxDepth
+ * @param int $minDepth
+ * @param int $maxDepth
*/
public function __construct($fontStyle = null, $tocStyle = null, $minDepth = 1, $maxDepth = 9)
{
@@ -132,7 +131,6 @@ class TOC extends AbstractElement
* Set max depth.
*
* @param int $value
- * @return void
*/
public function setMaxDepth($value)
{
@@ -153,7 +151,6 @@ class TOC extends AbstractElement
* Set min depth.
*
* @param int $value
- * @return void
*/
public function setMinDepth($value)
{
diff --git a/src/PhpWord/Element/Table.php b/src/PhpWord/Element/Table.php
index 357af37a..3a045031 100644
--- a/src/PhpWord/Element/Table.php
+++ b/src/PhpWord/Element/Table.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -121,7 +121,6 @@ class Table extends AbstractElement
* Set table width.
*
* @param int $width
- * @return void
*/
public function setWidth($width)
{
diff --git a/src/PhpWord/Element/Text.php b/src/PhpWord/Element/Text.php
index 0de9cdea..4de12176 100644
--- a/src/PhpWord/Element/Text.php
+++ b/src/PhpWord/Element/Text.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -105,12 +105,12 @@ class Text extends AbstractElement
public function setParagraphStyle($style = null)
{
if (is_array($style)) {
- $this->paragraphStyle = new Paragraph;
+ $this->paragraphStyle = new Paragraph();
$this->paragraphStyle->setStyleByArray($style);
} elseif ($style instanceof Paragraph) {
$this->paragraphStyle = $style;
} elseif (null === $style) {
- $this->paragraphStyle = new Paragraph;
+ $this->paragraphStyle = new Paragraph();
} else {
$this->paragraphStyle = $style;
}
diff --git a/src/PhpWord/Element/TextBox.php b/src/PhpWord/Element/TextBox.php
index 4a1e5131..8058d0c9 100644
--- a/src/PhpWord/Element/TextBox.php
+++ b/src/PhpWord/Element/TextBox.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/TextBreak.php b/src/PhpWord/Element/TextBreak.php
index 893fa875..4cf65f35 100644
--- a/src/PhpWord/Element/TextBreak.php
+++ b/src/PhpWord/Element/TextBreak.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -74,6 +74,7 @@ class TextBreak extends AbstractElement
$this->fontStyle = $style;
$this->setParagraphStyle($paragraphStyle);
}
+
return $this->fontStyle;
}
@@ -96,13 +97,14 @@ class TextBreak extends AbstractElement
public function setParagraphStyle($style = null)
{
if (is_array($style)) {
- $this->paragraphStyle = new Paragraph;
+ $this->paragraphStyle = new Paragraph();
$this->paragraphStyle->setStyleByArray($style);
} elseif ($style instanceof Paragraph) {
$this->paragraphStyle = $style;
} else {
$this->paragraphStyle = $style;
}
+
return $this->paragraphStyle;
}
diff --git a/src/PhpWord/Element/TextRun.php b/src/PhpWord/Element/TextRun.php
index c2ce4f99..d8a898b4 100644
--- a/src/PhpWord/Element/TextRun.php
+++ b/src/PhpWord/Element/TextRun.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Element/Title.php b/src/PhpWord/Element/Title.php
index eabb1feb..808af55e 100644
--- a/src/PhpWord/Element/Title.php
+++ b/src/PhpWord/Element/Title.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -83,7 +83,7 @@ class Title extends AbstractElement
/**
* Get depth
*
- * @return integer
+ * @return int
*/
public function getDepth()
{
diff --git a/src/PhpWord/Element/TrackChange.php b/src/PhpWord/Element/TrackChange.php
index 1df7148d..11cc763a 100644
--- a/src/PhpWord/Element/TrackChange.php
+++ b/src/PhpWord/Element/TrackChange.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -49,9 +49,9 @@ class TrackChange extends AbstractContainer
*/
public function __construct($author, \DateTime $date)
{
-
$this->author = $author;
$this->date = $date;
+
return $this;
}
diff --git a/src/PhpWord/Escaper/AbstractEscaper.php b/src/PhpWord/Escaper/AbstractEscaper.php
index 8ce4e301..8207e2c6 100644
--- a/src/PhpWord/Escaper/AbstractEscaper.php
+++ b/src/PhpWord/Escaper/AbstractEscaper.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Escaper/EscaperInterface.php b/src/PhpWord/Escaper/EscaperInterface.php
index 71cf36b4..1ef35c1b 100644
--- a/src/PhpWord/Escaper/EscaperInterface.php
+++ b/src/PhpWord/Escaper/EscaperInterface.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Escaper/RegExp.php b/src/PhpWord/Escaper/RegExp.php
index dfcfb1e1..2f4e12ec 100644
--- a/src/PhpWord/Escaper/RegExp.php
+++ b/src/PhpWord/Escaper/RegExp.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Escaper/Rtf.php b/src/PhpWord/Escaper/Rtf.php
index ec24c0af..35f91ada 100644
--- a/src/PhpWord/Escaper/Rtf.php
+++ b/src/PhpWord/Escaper/Rtf.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,9 +28,9 @@ class Rtf extends AbstractEscaper
{
if (20 > $code || $code >= 80) {
return '{\u' . $code . '}';
- } else {
- return chr($code);
}
+
+ return chr($code);
}
protected function escapeMultibyteCharacter($code)
@@ -40,6 +40,7 @@ class Rtf extends AbstractEscaper
/**
* @see http://www.randomchaos.com/documents/?source=php_and_unicode
+ * @param string $input
*/
protected function escapeSingleValue($input)
{
@@ -57,9 +58,9 @@ class Rtf extends AbstractEscaper
if (0 == count($bytes)) {
if ($asciiCode < 224) {
$numberOfBytes = 2;
- } else if ($asciiCode < 240) {
+ } elseif ($asciiCode < 240) {
$numberOfBytes = 3;
- } else if ($asciiCode < 248) {
+ } elseif ($asciiCode < 248) {
$numberOfBytes = 4;
}
}
diff --git a/src/PhpWord/Escaper/Xml.php b/src/PhpWord/Escaper/Xml.php
index 3a0981aa..81cedaa9 100644
--- a/src/PhpWord/Escaper/Xml.php
+++ b/src/PhpWord/Escaper/Xml.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Exception/CopyFileException.php b/src/PhpWord/Exception/CopyFileException.php
index c172657f..a5c1da6a 100644
--- a/src/PhpWord/Exception/CopyFileException.php
+++ b/src/PhpWord/Exception/CopyFileException.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -23,10 +23,10 @@ namespace PhpOffice\PhpWord\Exception;
final class CopyFileException extends Exception
{
/**
- * @param string $source The fully qualified source file name.
- * @param string $destination The fully qualified destination file name.
- * @param integer $code The user defined exception code.
- * @param \Exception $previous The previous exception used for the exception chaining.
+ * @param string $source The fully qualified source file name
+ * @param string $destination The fully qualified destination file name
+ * @param int $code The user defined exception code
+ * @param \Exception $previous The previous exception used for the exception chaining
*/
final public function __construct($source, $destination, $code = 0, \Exception $previous = null)
{
diff --git a/src/PhpWord/Exception/CreateTemporaryFileException.php b/src/PhpWord/Exception/CreateTemporaryFileException.php
index 67d969ba..fafc8dac 100644
--- a/src/PhpWord/Exception/CreateTemporaryFileException.php
+++ b/src/PhpWord/Exception/CreateTemporaryFileException.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -23,8 +23,8 @@ namespace PhpOffice\PhpWord\Exception;
final class CreateTemporaryFileException extends Exception
{
/**
- * @param integer $code The user defined exception code.
- * @param \Exception $previous The previous exception used for the exception chaining.
+ * @param int $code The user defined exception code
+ * @param \Exception $previous The previous exception used for the exception chaining
*/
final public function __construct($code = 0, \Exception $previous = null)
{
diff --git a/src/PhpWord/Exception/Exception.php b/src/PhpWord/Exception/Exception.php
index a9c49f7f..b94ed1be 100644
--- a/src/PhpWord/Exception/Exception.php
+++ b/src/PhpWord/Exception/Exception.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Exception/InvalidImageException.php b/src/PhpWord/Exception/InvalidImageException.php
index 21c885ee..0a7b8fed 100644
--- a/src/PhpWord/Exception/InvalidImageException.php
+++ b/src/PhpWord/Exception/InvalidImageException.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Exception/InvalidObjectException.php b/src/PhpWord/Exception/InvalidObjectException.php
index ad564d47..54015506 100644
--- a/src/PhpWord/Exception/InvalidObjectException.php
+++ b/src/PhpWord/Exception/InvalidObjectException.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Exception/InvalidStyleException.php b/src/PhpWord/Exception/InvalidStyleException.php
index 44980842..e697f6cf 100644
--- a/src/PhpWord/Exception/InvalidStyleException.php
+++ b/src/PhpWord/Exception/InvalidStyleException.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Exception/UnsupportedImageTypeException.php b/src/PhpWord/Exception/UnsupportedImageTypeException.php
index 1b09bc8f..73b41d04 100644
--- a/src/PhpWord/Exception/UnsupportedImageTypeException.php
+++ b/src/PhpWord/Exception/UnsupportedImageTypeException.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/IOFactory.php b/src/PhpWord/IOFactory.php
index c868841a..eed1f163 100644
--- a/src/PhpWord/IOFactory.php
+++ b/src/PhpWord/IOFactory.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -29,9 +29,9 @@ abstract class IOFactory
* @param PhpWord $phpWord
* @param string $name
*
- * @return WriterInterface
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ *
+ * @return WriterInterface
*/
public static function createWriter(PhpWord $phpWord, $name = 'Word2007')
{
@@ -49,9 +49,9 @@ abstract class IOFactory
*
* @param string $name
*
- * @return ReaderInterface
- *
* @throws Exception
+ *
+ * @return ReaderInterface
*/
public static function createReader($name = 'Word2007')
{
@@ -65,19 +65,19 @@ abstract class IOFactory
* @param string $name
* @param \PhpOffice\PhpWord\PhpWord $phpWord
*
- * @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ *
+ * @return \PhpOffice\PhpWord\Writer\WriterInterface|\PhpOffice\PhpWord\Reader\ReaderInterface
*/
private static function createObject($type, $name, $phpWord = null)
{
$class = "PhpOffice\\PhpWord\\{$type}\\{$name}";
if (class_exists($class) && self::isConcreteClass($class)) {
return new $class($phpWord);
- } else {
- throw new Exception("\"{$name}\" is not a valid {$type}.");
}
+ throw new Exception("\"{$name}\" is not a valid {$type}.");
}
+
/**
* Loads PhpWord from file
*
@@ -89,8 +89,10 @@ abstract class IOFactory
{
/** @var \PhpOffice\PhpWord\Reader\ReaderInterface $reader */
$reader = self::createReader($readerName);
+
return $reader->load($filename);
}
+
/**
* Check if it's a concrete class (not abstract nor interface)
*
@@ -100,6 +102,7 @@ abstract class IOFactory
private static function isConcreteClass($class)
{
$reflection = new \ReflectionClass($class);
+
return !$reflection->isAbstract() && !$reflection->isInterface();
}
}
diff --git a/src/PhpWord/Media.php b/src/PhpWord/Media.php
index df337854..d9879010 100644
--- a/src/PhpWord/Media.php
+++ b/src/PhpWord/Media.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -43,9 +43,9 @@ class Media
* @param string $source
* @param \PhpOffice\PhpWord\Element\Image $image
*
- * @return integer
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ *
+ * @return int
*/
public static function addElement($container, $mediaType, $source, Image $image = null)
{
@@ -83,12 +83,10 @@ class Media
$image->setTarget($target);
$image->setMediaIndex($mediaTypeCount);
break;
-
// Objects
case 'object':
$target = "{$container}_oleObject{$mediaTypeCount}.bin";
break;
-
// Links
case 'link':
$target = $source;
@@ -100,15 +98,17 @@ class Media
$mediaData['type'] = $mediaType;
$mediaData['rID'] = $rId;
self::$elements[$container][$mediaId] = $mediaData;
+
return $rId;
- } else {
- $mediaData = self::$elements[$container][$mediaId];
- if (!is_null($image)) {
- $image->setTarget($mediaData['target']);
- $image->setMediaIndex($mediaData['mediaIndex']);
- }
- return $mediaData['rID'];
}
+
+ $mediaData = self::$elements[$container][$mediaId];
+ if (!is_null($image)) {
+ $image->setTarget($mediaData['target']);
+ $image->setMediaIndex($mediaData['mediaIndex']);
+ }
+
+ return $mediaData['rID'];
}
/**
@@ -116,7 +116,7 @@ class Media
*
* @param string $container section|headerx|footerx|footnote|endnote
* @param string $mediaType image|object|link
- * @return integer
+ * @return int
* @since 0.10.0
*/
public static function countElements($container, $mediaType = null)
@@ -157,13 +157,15 @@ class Media
$elements[$key] = $val;
}
}
+
return $elements;
- } else {
- if (!isset(self::$elements[$container])) {
- return $elements;
- }
- return self::getElementsByType($container, $type);
}
+
+ if (!isset(self::$elements[$container])) {
+ return $elements;
+ }
+
+ return self::getElementsByType($container, $type);
}
/**
@@ -208,7 +210,7 @@ class Media
* @param string $type
* @param \PhpOffice\PhpWord\Element\Image $image
*
- * @return integer
+ * @return int
*
* @codeCoverageIgnore
*/
@@ -224,7 +226,7 @@ class Media
*
* @param string $linkSrc
*
- * @return integer
+ * @return int
*
* @codeCoverageIgnore
*/
@@ -256,7 +258,7 @@ class Media
*
* @param string $key
*
- * @return integer
+ * @return int
*
* @codeCoverageIgnore
*/
@@ -270,11 +272,11 @@ class Media
*
* @deprecated 0.10.0
*
- * @param integer $headerCount
+ * @param int $headerCount
* @param string $src
* @param \PhpOffice\PhpWord\Element\Image $image
*
- * @return integer
+ * @return int
*
* @codeCoverageIgnore
*/
@@ -290,7 +292,7 @@ class Media
*
* @param string $key
*
- * @return integer
+ * @return int
*
* @codeCoverageIgnore
*/
@@ -318,11 +320,11 @@ class Media
*
* @deprecated 0.10.0
*
- * @param integer $footerCount
+ * @param int $footerCount
* @param string $src
* @param \PhpOffice\PhpWord\Element\Image $image
*
- * @return integer
+ * @return int
*
* @codeCoverageIgnore
*/
@@ -338,7 +340,7 @@ class Media
*
* @param string $key
*
- * @return integer
+ * @return int
*
* @codeCoverageIgnore
*/
diff --git a/src/PhpWord/Metadata/Compatibility.php b/src/PhpWord/Metadata/Compatibility.php
index eb93274d..69f6f98a 100644
--- a/src/PhpWord/Metadata/Compatibility.php
+++ b/src/PhpWord/Metadata/Compatibility.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,7 +21,7 @@ namespace PhpOffice\PhpWord\Metadata;
* Compatibility setting class
*
* @since 0.12.0
- * @link http://www.datypic.com/sc/ooxml/t-w_CT_Compat.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_CT_Compat.html
*/
class Compatibility
{
@@ -33,7 +33,7 @@ class Compatibility
* 15 = 2013
*
* @var int
- * @link http://msdn.microsoft.com/en-us/library/dd909048%28v=office.12%29.aspx
+ * @see http://msdn.microsoft.com/en-us/library/dd909048%28v=office.12%29.aspx
*/
private $ooxmlVersion = 12;
diff --git a/src/PhpWord/Metadata/DocInfo.php b/src/PhpWord/Metadata/DocInfo.php
index 63a7d515..0508dcd0 100644
--- a/src/PhpWord/Metadata/DocInfo.php
+++ b/src/PhpWord/Metadata/DocInfo.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -119,17 +119,17 @@ class DocInfo
*/
public function __construct()
{
- $this->creator = '';
+ $this->creator = '';
$this->lastModifiedBy = $this->creator;
- $this->created = time();
- $this->modified = time();
- $this->title = '';
- $this->subject = '';
- $this->description = '';
- $this->keywords = '';
- $this->category = '';
- $this->company = '';
- $this->manager = '';
+ $this->created = time();
+ $this->modified = time();
+ $this->title = '';
+ $this->subject = '';
+ $this->description = '';
+ $this->keywords = '';
+ $this->category = '';
+ $this->company = '';
+ $this->manager = '';
}
/**
@@ -399,7 +399,7 @@ class DocInfo
* Check if a Custom Property is defined
*
* @param string $propertyName
- * @return boolean
+ * @return bool
*/
public function isCustomPropertySet($propertyName)
{
@@ -416,9 +416,9 @@ class DocInfo
{
if ($this->isCustomPropertySet($propertyName)) {
return $this->customProperties[$propertyName]['value'];
- } else {
- return null;
}
+
+ return null;
}
/**
@@ -431,9 +431,9 @@ class DocInfo
{
if ($this->isCustomPropertySet($propertyName)) {
return $this->customProperties[$propertyName]['type'];
- } else {
- return null;
}
+
+ return null;
}
/**
@@ -456,7 +456,7 @@ class DocInfo
self::PROPERTY_TYPE_FLOAT,
self::PROPERTY_TYPE_STRING,
self::PROPERTY_TYPE_DATE,
- self::PROPERTY_TYPE_BOOLEAN
+ self::PROPERTY_TYPE_BOOLEAN,
);
if (($propertyType === null) || (!in_array($propertyType, $propertyTypes))) {
if ($propertyValue === null) {
@@ -474,8 +474,9 @@ class DocInfo
$this->customProperties[$propertyName] = array(
'value' => $propertyValue,
- 'type' => $propertyType
+ 'type' => $propertyType,
);
+
return $this;
}
diff --git a/src/PhpWord/Metadata/Protection.php b/src/PhpWord/Metadata/Protection.php
index 0e2ee7c1..ef5063f8 100644
--- a/src/PhpWord/Metadata/Protection.php
+++ b/src/PhpWord/Metadata/Protection.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,7 +21,7 @@ namespace PhpOffice\PhpWord\Metadata;
* Document protection class
*
* @since 0.12.0
- * @link http://www.datypic.com/sc/ooxml/t-w_CT_DocProtect.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_CT_DocProtect.html
* @todo Password!
*/
class Protection
@@ -30,7 +30,7 @@ class Protection
* Editing restriction readOnly|comments|trackedChanges|forms
*
* @var string
- * @link http://www.datypic.com/sc/ooxml/a-w_edit-1.html
+ * @see http://www.datypic.com/sc/ooxml/a-w_edit-1.html
*/
private $editing;
diff --git a/src/PhpWord/Metadata/Settings.php b/src/PhpWord/Metadata/Settings.php
index 64788cc3..85c0659d 100644
--- a/src/PhpWord/Metadata/Settings.php
+++ b/src/PhpWord/Metadata/Settings.php
@@ -10,30 +10,30 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Metadata;
use PhpOffice\PhpWord\ComplexType\ProofState;
-use PhpOffice\PhpWord\SimpleType\Zoom;
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
+use PhpOffice\PhpWord\SimpleType\Zoom;
use PhpOffice\PhpWord\Style\Language;
/**
* Setting class
*
* @since 0.14.0
- * @link http://www.datypic.com/sc/ooxml/t-w_CT_Settings.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_CT_Settings.html
*/
class Settings
{
-
/**
* Magnification Setting
*
- * @link http://www.datypic.com/sc/ooxml/e-w_zoom-1.html
+ * @see http://www.datypic.com/sc/ooxml/e-w_zoom-1.html
* @var mixed either integer, in which case it treated as a percent, or one of PhpOffice\PhpWord\SimpleType\Zoom
*/
private $zoom = 100;
@@ -41,14 +41,14 @@ class Settings
/**
* Hide spelling errors
*
- * @var boolean
+ * @var bool
*/
private $hideSpellingErrors = false;
/**
* Hide grammatical errors
*
- * @var boolean
+ * @var bool
*/
private $hideGrammaticalErrors = false;
@@ -62,21 +62,21 @@ class Settings
/**
* Track Revisions to Document
*
- * @var boolean
+ * @var bool
*/
private $trackRevisions = false;
/**
* Do Not Use Move Syntax When Tracking Revisions
*
- * @var boolean
+ * @var bool
*/
private $doNotTrackMoves = false;
/**
* Do Not Track Formatting Revisions When Tracking Revisions
*
- * @var boolean
+ * @var bool
*/
private $doNotTrackFormatting = false;
@@ -103,7 +103,7 @@ class Settings
/**
* Theme Font Languages
- *
+ *
* @var Language
*/
private $themeFontLang;
@@ -123,6 +123,7 @@ class Settings
if ($this->documentProtection == null) {
$this->documentProtection = new Protection();
}
+
return $this->documentProtection;
}
@@ -142,6 +143,7 @@ class Settings
if ($this->proofState == null) {
$this->proofState = new ProofState();
}
+
return $this->proofState;
}
@@ -156,7 +158,7 @@ class Settings
/**
* Are spelling errors hidden
*
- * @return boolean
+ * @return bool
*/
public function hasHideSpellingErrors()
{
@@ -166,7 +168,7 @@ class Settings
/**
* Hide spelling errors
*
- * @param boolean $hideSpellingErrors
+ * @param bool $hideSpellingErrors
*/
public function setHideSpellingErrors($hideSpellingErrors)
{
@@ -176,7 +178,7 @@ class Settings
/**
* Are grammatical errors hidden
*
- * @return boolean
+ * @return bool
*/
public function hasHideGrammaticalErrors()
{
@@ -186,7 +188,7 @@ class Settings
/**
* Hide grammatical errors
*
- * @param boolean $hideGrammaticalErrors
+ * @param bool $hideGrammaticalErrors
*/
public function setHideGrammaticalErrors($hideGrammaticalErrors)
{
@@ -194,7 +196,7 @@ class Settings
}
/**
- * @return boolean
+ * @return bool
*/
public function hasEvenAndOddHeaders()
{
@@ -202,7 +204,7 @@ class Settings
}
/**
- * @param boolean $evenAndOddHeaders
+ * @param bool $evenAndOddHeaders
*/
public function setEvenAndOddHeaders($evenAndOddHeaders)
{
@@ -230,7 +232,7 @@ class Settings
}
/**
- * @return boolean
+ * @return bool
*/
public function hasTrackRevisions()
{
@@ -238,7 +240,7 @@ class Settings
}
/**
- * @param boolean $trackRevisions
+ * @param bool $trackRevisions
*/
public function setTrackRevisions($trackRevisions)
{
@@ -246,7 +248,7 @@ class Settings
}
/**
- * @return boolean
+ * @return bool
*/
public function hasDoNotTrackMoves()
{
@@ -254,7 +256,7 @@ class Settings
}
/**
- * @param boolean $doNotTrackMoves
+ * @param bool $doNotTrackMoves
*/
public function setDoNotTrackMoves($doNotTrackMoves)
{
@@ -262,7 +264,7 @@ class Settings
}
/**
- * @return boolean
+ * @return bool
*/
public function hasDoNotTrackFormatting()
{
@@ -270,7 +272,7 @@ class Settings
}
/**
- * @param boolean $doNotTrackFormatting
+ * @param bool $doNotTrackFormatting
*/
public function setDoNotTrackFormatting($doNotTrackFormatting)
{
@@ -301,7 +303,7 @@ class Settings
/**
* Returns the Language
- *
+ *
* @return Language
*/
public function getThemeFontLang()
@@ -311,7 +313,7 @@ class Settings
/**
* sets the Language for this document
- *
+ *
* @param Language $themeFontLang
*/
public function setThemeFontLang($themeFontLang)
diff --git a/src/PhpWord/PhpWord.php b/src/PhpWord/PhpWord.php
index 1571537e..d7c2348a 100644
--- a/src/PhpWord/PhpWord.php
+++ b/src/PhpWord/PhpWord.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -108,9 +108,9 @@ class PhpWord
* @param mixed $function
* @param mixed $args
*
- * @return mixed
- *
* @throws \BadMethodCallException
+ *
+ * @return mixed
*/
public function __call($function, $args)
{
@@ -241,7 +241,6 @@ class PhpWord
* Set default font name.
*
* @param string $fontName
- * @return void
*/
public function setDefaultFontName($fontName)
{
@@ -251,7 +250,7 @@ class PhpWord
/**
* Get default font size
*
- * @return integer
+ * @return int
*/
public function getDefaultFontSize()
{
@@ -262,7 +261,6 @@ class PhpWord
* Set default font size.
*
* @param int $fontSize
- * @return void
*/
public function setDefaultFontSize($fontSize)
{
@@ -285,21 +283,20 @@ class PhpWord
*
* @deprecated 0.12.0 Use `new TemplateProcessor($documentTemplate)` instead.
*
- * @param string $filename Fully qualified filename.
- *
- * @return TemplateProcessor
+ * @param string $filename Fully qualified filename
*
* @throws \PhpOffice\PhpWord\Exception\Exception
*
+ * @return TemplateProcessor
+ *
* @codeCoverageIgnore
*/
public function loadTemplate($filename)
{
if (file_exists($filename)) {
return new TemplateProcessor($filename);
- } else {
- throw new Exception("Template file {$filename} not found.");
}
+ throw new Exception("Template file {$filename} not found.");
}
/**
@@ -325,7 +322,7 @@ class PhpWord
$writer = IOFactory::createWriter($this, $format);
if ($download === true) {
- header("Content-Description: File Transfer");
+ header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Content-Type: ' . $mime[$format]);
header('Content-Transfer-Encoding: binary');
diff --git a/src/PhpWord/Reader/AbstractReader.php b/src/PhpWord/Reader/AbstractReader.php
index 93288c3b..f59a9556 100644
--- a/src/PhpWord/Reader/AbstractReader.php
+++ b/src/PhpWord/Reader/AbstractReader.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -62,6 +62,7 @@ abstract class AbstractReader implements ReaderInterface
public function setReadDataOnly($value = true)
{
$this->readDataOnly = $value;
+
return $this;
}
@@ -70,21 +71,21 @@ abstract class AbstractReader implements ReaderInterface
*
* @param string $filename
*
- * @return resource
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ *
+ * @return resource
*/
protected function openFile($filename)
{
// Check if file exists
if (!file_exists($filename) || !is_readable($filename)) {
- throw new Exception("Could not open " . $filename . " for reading! File does not exist.");
+ throw new Exception("Could not open $filename for reading! File does not exist.");
}
// Open file
$this->fileHandle = fopen($filename, 'r');
if ($this->fileHandle === false) {
- throw new Exception("Could not open file " . $filename . " for reading.");
+ throw new Exception("Could not open file $filename for reading.");
}
}
diff --git a/src/PhpWord/Reader/HTML.php b/src/PhpWord/Reader/HTML.php
index 824573e9..4e8b5e82 100644
--- a/src/PhpWord/Reader/HTML.php
+++ b/src/PhpWord/Reader/HTML.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Reader/MsDoc.php b/src/PhpWord/Reader/MsDoc.php
index b3fdd9d4..9baacb51 100644
--- a/src/PhpWord/Reader/MsDoc.php
+++ b/src/PhpWord/Reader/MsDoc.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -19,8 +19,8 @@ namespace PhpOffice\PhpWord\Reader;
use PhpOffice\Common\Drawing;
use PhpOffice\PhpWord\PhpWord;
-use PhpOffice\PhpWord\Style;
use PhpOffice\PhpWord\Shared\OLERead;
+use PhpOffice\PhpWord\Style;
/**
* Reader for Word97
@@ -164,13 +164,14 @@ class MsDoc extends AbstractReader implements ReaderInterface
$arrayCP[$inc] = self::getInt4d($data, $posMem);
$posMem += 4;
}
+
return $arrayCP;
}
/**
- *
- * @link http://msdn.microsoft.com/en-us/library/dd949344%28v=office.12%29.aspx
- * @link https://igor.io/2012/09/24/binary-parsing.html
+ * @see http://msdn.microsoft.com/en-us/library/dd949344%28v=office.12%29.aspx
+ * @see https://igor.io/2012/09/24/binary-parsing.html
+ * @param string $data
*/
private function readFib($data)
{
@@ -1095,6 +1096,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
$this->arrayFib['lcbColorSchemeMapping'] = self::getInt4d($data, $pos);
$pos += 4;
}
+
return $pos;
}
@@ -1107,11 +1109,11 @@ class MsDoc extends AbstractReader implements ReaderInterface
$this->readRecordPlcfSed();
// reading paragraphs
- //@link https://github.com/notmasteryet/CompoundFile/blob/ec118f354efebdee9102e41b5b7084fce81125b0/WordFileReader/WordDocument.cs#L86
+ //@see https://github.com/notmasteryet/CompoundFile/blob/ec118f354efebdee9102e41b5b7084fce81125b0/WordFileReader/WordDocument.cs#L86
$this->readRecordPlcfBtePapx();
// reading character formattings
- //@link https://github.com/notmasteryet/CompoundFile/blob/ec118f354efebdee9102e41b5b7084fce81125b0/WordFileReader/WordDocument.cs#L94
+ //@see https://github.com/notmasteryet/CompoundFile/blob/ec118f354efebdee9102e41b5b7084fce81125b0/WordFileReader/WordDocument.cs#L94
$this->readRecordPlcfBteChpx();
$this->generatePhpWord();
@@ -1119,7 +1121,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
/**
* Section and information about them
- * @link : http://msdn.microsoft.com/en-us/library/dd924458%28v=office.12%29.aspx
+ * @see : http://msdn.microsoft.com/en-us/library/dd924458%28v=office.12%29.aspx
*/
private function readRecordPlcfSed()
{
@@ -1133,7 +1135,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
$posMem += 4;
// PlcfSed : aSed
- //@link : http://msdn.microsoft.com/en-us/library/dd950194%28v=office.12%29.aspx
+ //@see : http://msdn.microsoft.com/en-us/library/dd950194%28v=office.12%29.aspx
$numSed = $this->getNumInLcb($this->arrayFib['lcbPlcfSed'], 12);
$aSed = array();
@@ -1164,7 +1166,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
/**
* Specifies the fonts that are used in the document
- * @link : http://msdn.microsoft.com/en-us/library/dd943880%28v=office.12%29.aspx
+ * @see : http://msdn.microsoft.com/en-us/library/dd943880%28v=office.12%29.aspx
*/
private function readRecordSttbfFfn()
{
@@ -1215,7 +1217,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
}
$this->arrayFonts[] = array(
'main' => $xszFfn,
- 'alt' => $xszAlt,
+ 'alt' => $xszAlt,
);
}
}
@@ -1223,7 +1225,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
/**
* Paragraph and information about them
- * @link http://msdn.microsoft.com/en-us/library/dd908569%28v=office.12%29.aspx
+ * @see http://msdn.microsoft.com/en-us/library/dd908569%28v=office.12%29.aspx
*/
private function readRecordPlcfBtePapx()
{
@@ -1247,7 +1249,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
}
$arrayRGB = array();
for ($inc = 1; $inc <= $numRun; $inc++) {
- // @link http://msdn.microsoft.com/en-us/library/dd925804(v=office.12).aspx
+ // @see http://msdn.microsoft.com/en-us/library/dd925804(v=office.12).aspx
$arrayRGB[$inc] = self::getInt1d($this->dataWorkDocument, $offset);
$offset += 1;
// reserved
@@ -1426,7 +1428,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
} else {
if ($istd > 0) {
// @todo : Determining Properties of a Paragraph Style
- # @link http://msdn.microsoft.com/en-us/library/dd948631%28v=office.12%29.aspx
+ # @see http://msdn.microsoft.com/en-us/library/dd948631%28v=office.12%29.aspx
}
}
}*/
@@ -1435,7 +1437,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
/**
* Character formatting properties to text in a document
- * @link http://msdn.microsoft.com/en-us/library/dd907108%28v=office.12%29.aspx
+ * @see http://msdn.microsoft.com/en-us/library/dd907108%28v=office.12%29.aspx
*/
private function readRecordPlcfBteChpx()
{
@@ -1453,7 +1455,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
$offset = $offsetBase;
// ChpxFkp
- // @link : http://msdn.microsoft.com/en-us/library/dd910989%28v=office.12%29.aspx
+ // @see : http://msdn.microsoft.com/en-us/library/dd910989%28v=office.12%29.aspx
$numRGFC = self::getInt1d($this->dataWorkDocument, $offset + 511);
$arrayRGFC = array();
for ($inc = 0; $inc <= $numRGFC; $inc++) {
@@ -1471,12 +1473,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
foreach ($arrayRGB as $keyRGB => $rgb) {
$oStyle = new \stdClass();
$oStyle->pos_start = $start;
- $oStyle->pos_len = (int)ceil((($arrayRGFC[$keyRGB] -1) - $arrayRGFC[$keyRGB -1]) / 2);
+ $oStyle->pos_len = (int) ceil((($arrayRGFC[$keyRGB] - 1) - $arrayRGFC[$keyRGB - 1]) / 2);
$start += $oStyle->pos_len;
if ($rgb > 0) {
// Chp Structure
- // @link : http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx
+ // @see : http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx
$posRGB = $offsetBase + $rgb * 2;
$cb = self::getInt1d($this->dataWorkDocument, $posRGB);
@@ -1500,12 +1502,13 @@ class MsDoc extends AbstractReader implements ReaderInterface
$oSprm->f = ($sprm / 512) & 0x0001;
$oSprm->sgc = ($sprm / 1024) & 0x0007;
$oSprm->spra = ($sprm / 8192);
+
return $oSprm;
}
/**
* @param string $data
- * @param integer $pos
+ * @param int $pos
* @param \stdClass $oSprm
* @return array
*/
@@ -1558,16 +1561,17 @@ class MsDoc extends AbstractReader implements ReaderInterface
}
return array(
- 'length' => $length,
+ 'length' => $length,
'operand' => $operand,
);
}
/**
- * @param $data integer
- * @param $pos integer
+ * @param $data int
+ * @param $pos int
+ * @param $cbNum int
* @return \stdClass
- * @link http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx
+ * @see http://msdn.microsoft.com/en-us/library/dd772849%28v=office.12%29.aspx
*/
private function readPrl($data, $pos, $cbNum)
{
@@ -1732,7 +1736,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
}
break;
// sprmCIco
- //@link http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx
+ //@see http://msdn.microsoft.com/en-us/library/dd773060%28v=office.12%29.aspx
case 0x42:
switch (dechex($operand)) {
case 0x00:
@@ -1787,7 +1791,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
break;
// sprmCHps
case 0x43:
- $oStylePrl->styleFont['size'] = dechex($operand/2);
+ $oStylePrl->styleFont['size'] = dechex($operand / 2);
break;
// sprmCIss
case 0x48:
@@ -1838,7 +1842,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
case 0x61:
break;
// sprmCShd80
- //@link http://msdn.microsoft.com/en-us/library/dd923447%28v=office.12%29.aspx
+ //@see http://msdn.microsoft.com/en-us/library/dd923447%28v=office.12%29.aspx
case 0x66:
// $operand = self::getInt2d($data, $pos);
$pos += 2;
@@ -1848,7 +1852,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
// $icoFore = ($operand >> 11) && bindec('11111');
break;
// sprmCCv
- //@link : http://msdn.microsoft.com/en-us/library/dd952824%28v=office.12%29.aspx
+ //@see : http://msdn.microsoft.com/en-us/library/dd952824%28v=office.12%29.aspx
case 0x70:
$red = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT);
$pos += 1;
@@ -1857,7 +1861,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
$blue = str_pad(dechex(self::getInt1d($this->dataWorkDocument, $pos)), 2, '0', STR_PAD_LEFT);
$pos += 1;
$pos += 1;
- $oStylePrl->styleFont['color'] = $red.$green.$blue;
+ $oStylePrl->styleFont['color'] = $red . $green . $blue;
$cbNum -= 4;
break;
default:
@@ -1950,7 +1954,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
// HFD > clsid
$sprmCPicLocation += 16;
// HFD > hyperlink
- //@link : http://msdn.microsoft.com/en-us/library/dd909835%28v=office.12%29.aspx
+ //@see : http://msdn.microsoft.com/en-us/library/dd909835%28v=office.12%29.aspx
$streamVersion = self::getInt4d($this->dataData, $sprmCPicLocation);
$sprmCPicLocation += 4;
$data = self::getInt4d($this->dataData, $sprmCPicLocation);
@@ -2018,8 +2022,8 @@ class MsDoc extends AbstractReader implements ReaderInterface
}*/
} else {
// Pictures
- //@link : http://msdn.microsoft.com/en-us/library/dd925458%28v=office.12%29.aspx
- //@link : http://msdn.microsoft.com/en-us/library/dd926136%28v=office.12%29.aspx
+ //@see : http://msdn.microsoft.com/en-us/library/dd925458%28v=office.12%29.aspx
+ //@see : http://msdn.microsoft.com/en-us/library/dd926136%28v=office.12%29.aspx
// PICF : lcb
$sprmCPicLocation += 4;
// PICF : cbHeader
@@ -2106,13 +2110,13 @@ class MsDoc extends AbstractReader implements ReaderInterface
$sprmCPicLocation += $shapeRH['recLen'];
}
// picture : rgfb
- //@link : http://msdn.microsoft.com/en-us/library/dd950560%28v=office.12%29.aspx
+ //@see : http://msdn.microsoft.com/en-us/library/dd950560%28v=office.12%29.aspx
$fileBlockRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation);
while ($fileBlockRH['recType'] == 0xF007 || ($fileBlockRH['recType'] >= 0xF018 && $fileBlockRH['recType'] <= 0xF117)) {
$sprmCPicLocation += 8;
switch ($fileBlockRH['recType']) {
// OfficeArtFBSE
- //@link : http://msdn.microsoft.com/en-us/library/dd944923%28v=office.12%29.aspx
+ //@see : http://msdn.microsoft.com/en-us/library/dd944923%28v=office.12%29.aspx
case 0xF007:
// btWin32
$sprmCPicLocation += 1;
@@ -2147,7 +2151,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
}
}
// embeddedBlip
- //@link : http://msdn.microsoft.com/en-us/library/dd910081%28v=office.12%29.aspx
+ //@see : http://msdn.microsoft.com/en-us/library/dd910081%28v=office.12%29.aspx
$embeddedBlipRH = $this->loadRecordHeader($this->dataData, $sprmCPicLocation);
switch ($embeddedBlipRH['recType']) {
case self::OFFICEARTBLIPJPG:
@@ -2192,13 +2196,14 @@ class MsDoc extends AbstractReader implements ReaderInterface
}
$oStylePrl->length = $pos - $posStart;
+
return $oStylePrl;
}
/**
* Read a record header
* @param string $stream
- * @param integer $pos
+ * @param int $pos
* @return array
*/
private function loadRecordHeader($stream, $pos)
@@ -2206,11 +2211,12 @@ class MsDoc extends AbstractReader implements ReaderInterface
$rec = self::getInt2d($stream, $pos);
$recType = self::getInt2d($stream, $pos + 2);
$recLen = self::getInt4d($stream, $pos + 4);
+
return array(
- 'recVer' => ($rec >> 0) & bindec('1111'),
+ 'recVer' => ($rec >> 0) & bindec('1111'),
'recInstance' => ($rec >> 4) & bindec('111111111111'),
- 'recType' => $recType,
- 'recLen' => $recLen,
+ 'recType' => $recType,
+ 'recLen' => $recLen,
);
}
@@ -2273,7 +2279,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
}
if (ord($sText[0]) == 1) {
if (isset($oCharacters->style->image)) {
- $fileImage = tempnam(sys_get_temp_dir(), 'PHPWord_MsDoc').'.'.$oCharacters->style->image['format'];
+ $fileImage = tempnam(sys_get_temp_dir(), 'PHPWord_MsDoc') . '.' . $oCharacters->style->image['format'];
file_put_contents($fileImage, $oCharacters->style->image['data']);
$oSection->addImage($fileImage, array('width' => $oCharacters->style->image['width'], 'height' => $oCharacters->style->image['height']));
// print_r('>addImage<'.$fileImage.'>'.EOL);
@@ -2308,7 +2314,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
*/
public static function getInt2d($data, $pos)
{
- return ord($data[$pos]) | (ord($data[$pos+1]) << 8);
+ return ord($data[$pos]) | (ord($data[$pos + 1]) << 8);
}
/**
@@ -2320,7 +2326,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
*/
public static function getInt3d($data, $pos)
{
- return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16);
+ return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16);
}
/**
@@ -2342,6 +2348,7 @@ class MsDoc extends AbstractReader implements ReaderInterface
} else {
$ord24 = ($or24 & 127) << 24;
}
- return ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | $ord24;
+
+ return ord($data[$pos]) | (ord($data[$pos + 1]) << 8) | (ord($data[$pos + 2]) << 16) | $ord24;
}
}
diff --git a/src/PhpWord/Reader/ODText.php b/src/PhpWord/Reader/ODText.php
index e8c86886..5a22b4ba 100644
--- a/src/PhpWord/Reader/ODText.php
+++ b/src/PhpWord/Reader/ODText.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -40,7 +40,7 @@ class ODText extends AbstractReader implements ReaderInterface
$readerParts = array(
'content.xml' => 'Content',
- 'meta.xml' => 'Meta',
+ 'meta.xml' => 'Meta',
);
foreach ($readerParts as $xmlFile => $partName) {
@@ -58,7 +58,6 @@ class ODText extends AbstractReader implements ReaderInterface
* @param string $partName
* @param string $docFile
* @param string $xmlFile
- * @return void
*/
private function readPart(PhpWord $phpWord, $relationships, $partName, $docFile, $xmlFile)
{
diff --git a/src/PhpWord/Reader/ODText/AbstractPart.php b/src/PhpWord/Reader/ODText/AbstractPart.php
index 5ec2f22d..bdac3b6f 100644
--- a/src/PhpWord/Reader/ODText/AbstractPart.php
+++ b/src/PhpWord/Reader/ODText/AbstractPart.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Reader/ODText/Content.php b/src/PhpWord/Reader/ODText/Content.php
index 0e11147b..8843d8a2 100644
--- a/src/PhpWord/Reader/ODText/Content.php
+++ b/src/PhpWord/Reader/ODText/Content.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -31,7 +31,6 @@ class Content extends AbstractPart
* Read content.xml.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
- * @return void
*/
public function read(PhpWord $phpWord)
{
@@ -48,11 +47,9 @@ class Content extends AbstractPart
$depth = $xmlReader->getAttribute('text:outline-level', $node);
$section->addTitle($node->nodeValue, $depth);
break;
-
case 'text:p': // Paragraph
$section->addText($node->nodeValue);
break;
-
case 'text:list': // List
$listItems = $xmlReader->getElements('text:list-item/text:p', $node);
foreach ($listItems as $listItem) {
diff --git a/src/PhpWord/Reader/ODText/Meta.php b/src/PhpWord/Reader/ODText/Meta.php
index 9533c38b..98832d17 100644
--- a/src/PhpWord/Reader/ODText/Meta.php
+++ b/src/PhpWord/Reader/ODText/Meta.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -31,7 +31,6 @@ class Meta extends AbstractPart
* Read meta.xml.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
- * @return void
* @todo Process property type
*/
public function read(PhpWord $phpWord)
@@ -70,9 +69,8 @@ class Meta extends AbstractPart
if (in_array($property, array('Category', 'Company', 'Manager'))) {
$method = "set{$property}";
$docProps->$method($propertyNode->nodeValue);
-
- // Set other custom properties
} else {
+ // Set other custom properties
$docProps->setCustomProperty($property, $propertyNode->nodeValue);
}
}
diff --git a/src/PhpWord/Reader/RTF.php b/src/PhpWord/Reader/RTF.php
index b6d2e21e..2d09a04d 100644
--- a/src/PhpWord/Reader/RTF.php
+++ b/src/PhpWord/Reader/RTF.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Reader/RTF/Document.php b/src/PhpWord/Reader/RTF/Document.php
index 4e0f2c35..be16d707 100644
--- a/src/PhpWord/Reader/RTF/Document.php
+++ b/src/PhpWord/Reader/RTF/Document.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -131,7 +131,6 @@ class Document
* - Pushes every other character into the text queue
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
- * @return void
* @todo Use `fread` stream for scalability
*/
public function read(PhpWord $phpWord)
@@ -153,7 +152,7 @@ class Document
// Walk each characters
while ($this->offset < $this->length) {
- $char = $this->rtf[$this->offset];
+ $char = $this->rtf[$this->offset];
$ascii = ord($char);
if (isset($markers[$ascii])) { // Marker found: {, }, \, LF, or CR
@@ -163,7 +162,7 @@ class Document
if (false === $this->isControl) { // Non control word: Push character
$this->pushText($char);
} else {
- if (preg_match("/^[a-zA-Z0-9-]?$/", $char)) { // No delimiter: Buffer control
+ if (preg_match('/^[a-zA-Z0-9-]?$/', $char)) { // No delimiter: Buffer control
$this->control .= $char;
$this->isFirst = false;
} else { // Delimiter found: Parse buffered control
@@ -184,8 +183,6 @@ class Document
/**
* Mark opening braket `{` character.
- *
- * @return void
*/
private function markOpening()
{
@@ -195,8 +192,6 @@ class Document
/**
* Mark closing braket `}` character.
- *
- * @return void
*/
private function markClosing()
{
@@ -206,8 +201,6 @@ class Document
/**
* Mark backslash `\` character.
- *
- * @return void
*/
private function markBackslash()
{
@@ -223,8 +216,6 @@ class Document
/**
* Mark newline character: Flush control word because it's not possible to span multiline.
- *
- * @return void
*/
private function markNewline()
{
@@ -237,7 +228,6 @@ class Document
* Flush control word or text.
*
* @param bool $isControl
- * @return void
*/
private function flush($isControl = false)
{
@@ -252,11 +242,10 @@ class Document
* Flush control word.
*
* @param bool $isControl
- * @return void
*/
private function flushControl($isControl = false)
{
- if (1 === preg_match("/^([A-Za-z]+)(-?[0-9]*) ?$/", $this->control, $match)) {
+ if (1 === preg_match('/^([A-Za-z]+)(-?[0-9]*) ?$/', $this->control, $match)) {
list(, $control, $parameter) = $match;
$this->parseControl($control, $parameter);
}
@@ -268,8 +257,6 @@ class Document
/**
* Flush text in queue.
- *
- * @return void
*/
private function flushText()
{
@@ -296,7 +283,6 @@ class Document
* Reset control word and first char state.
*
* @param bool $value
- * @return void
*/
private function setControl($value)
{
@@ -308,14 +294,13 @@ class Document
* Push text into queue.
*
* @param string $char
- * @return void
*/
private function pushText($char)
{
if ('<' == $char) {
- $this->text .= "<";
+ $this->text .= '<';
} elseif ('>' == $char) {
- $this->text .= ">";
+ $this->text .= '>';
} else {
$this->text .= $char;
}
@@ -326,19 +311,18 @@ class Document
*
* @param string $control
* @param string $parameter
- * @return void
*/
private function parseControl($control, $parameter)
{
$controls = array(
'par' => array(self::PARA, 'paragraph', true),
- 'b' => array(self::STYL, 'font', 'bold', true),
- 'i' => array(self::STYL, 'font', 'italic', true),
- 'u' => array(self::STYL, 'font', 'underline', true),
- 'strike' => array(self::STYL, 'font', 'strikethrough',true),
- 'fs' => array(self::STYL, 'font', 'size', $parameter),
- 'qc' => array(self::STYL, 'paragraph', 'alignment', Jc::CENTER),
- 'sa' => array(self::STYL, 'paragraph', 'spaceAfter', $parameter),
+ 'b' => array(self::STYL, 'font', 'bold', true),
+ 'i' => array(self::STYL, 'font', 'italic', true),
+ 'u' => array(self::STYL, 'font', 'underline', true),
+ 'strike' => array(self::STYL, 'font', 'strikethrough', true),
+ 'fs' => array(self::STYL, 'font', 'size', $parameter),
+ 'qc' => array(self::STYL, 'paragraph', 'alignment', Jc::CENTER),
+ 'sa' => array(self::STYL, 'paragraph', 'spaceAfter', $parameter),
'fonttbl' => array(self::SKIP, 'fonttbl', null),
'colortbl' => array(self::SKIP, 'colortbl', null),
'info' => array(self::SKIP, 'info', null),
@@ -366,7 +350,6 @@ class Document
* Read paragraph.
*
* @param array $directives
- * @return void
*/
private function readParagraph($directives)
{
@@ -379,7 +362,6 @@ class Document
* Read style.
*
* @param array $directives
- * @return void
*/
private function readStyle($directives)
{
@@ -391,7 +373,6 @@ class Document
* Read skip.
*
* @param array $directives
- * @return void
*/
private function readSkip($directives)
{
@@ -402,8 +383,6 @@ class Document
/**
* Read text.
- *
- * @return void
*/
private function readText()
{
diff --git a/src/PhpWord/Reader/ReaderInterface.php b/src/PhpWord/Reader/ReaderInterface.php
index 4f5231a7..3b2e357b 100644
--- a/src/PhpWord/Reader/ReaderInterface.php
+++ b/src/PhpWord/Reader/ReaderInterface.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,7 +28,7 @@ interface ReaderInterface
* Can the current ReaderInterface read the file?
*
* @param string $filename
- * @return boolean
+ * @return bool
*/
public function canRead($filename);
diff --git a/src/PhpWord/Reader/Word2007.php b/src/PhpWord/Reader/Word2007.php
index d203dd29..9f9fce08 100644
--- a/src/PhpWord/Reader/Word2007.php
+++ b/src/PhpWord/Reader/Word2007.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -55,7 +55,7 @@ class Word2007 extends AbstractReader implements ReaderInterface
array('stepPart' => 'document', 'stepItems' => array(
'endnotes' => 'Endnotes',
'footnotes' => 'Footnotes',
- 'settings' => 'Settings',
+ 'settings' => 'Settings',
)),
);
@@ -83,7 +83,6 @@ class Word2007 extends AbstractReader implements ReaderInterface
* @param string $partName
* @param string $docFile
* @param string $xmlFile
- * @return void
*/
private function readPart(PhpWord $phpWord, $relationships, $partName, $docFile, $xmlFile)
{
diff --git a/src/PhpWord/Reader/Word2007/AbstractPart.php b/src/PhpWord/Reader/Word2007/AbstractPart.php
index c94a3546..21e12902 100644
--- a/src/PhpWord/Reader/Word2007/AbstractPart.php
+++ b/src/PhpWord/Reader/Word2007/AbstractPart.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,9 +36,9 @@ abstract class AbstractPart
*/
const READ_VALUE = 'attributeValue'; // Read attribute value
const READ_EQUAL = 'attributeEquals'; // Read `true` when attribute value equals specified value
- const READ_TRUE = 'attributeTrue'; // Read `true` when element exists
+ const READ_TRUE = 'attributeTrue'; // Read `true` when element exists
const READ_FALSE = 'attributeFalse'; // Read `false` when element exists
- const READ_SIZE = 'attributeMultiplyByTwo'; // Read special attribute value for Font::$size
+ const READ_SIZE = 'attributeMultiplyByTwo'; // Read special attribute value for Font::$size
/**
* Document file
@@ -82,7 +82,6 @@ abstract class AbstractPart
* Set relationships.
*
* @param array $value
- * @return void
*/
public function setRels($value)
{
@@ -96,7 +95,6 @@ abstract class AbstractPart
* @param \DOMElement $domNode
* @param mixed $parent
* @param string $docPart
- * @return void
*
* @todo Get font style for preserve text
*/
@@ -137,9 +135,8 @@ abstract class AbstractPart
}
}
$parent->addPreserveText($textContent, $fontStyle, $paragraphStyle);
-
- // List item
} elseif ($xmlReader->elementExists('w:pPr/w:numPr', $domNode)) {
+ // List item
$textContent = '';
$numId = $xmlReader->getAttribute('w:val', $domNode, 'w:pPr/w:numPr/w:numId');
$levelId = $xmlReader->getAttribute('w:val', $domNode, 'w:pPr/w:numPr/w:ilvl');
@@ -148,18 +145,16 @@ abstract class AbstractPart
$textContent .= $xmlReader->getValue('w:t', $node);
}
$parent->addListItem($textContent, $levelId, null, "PHPWordList{$numId}", $paragraphStyle);
-
- // Heading
} elseif (!empty($headingMatches)) {
+ // Heading
$textContent = '';
$nodes = $xmlReader->getElements('w:r', $domNode);
foreach ($nodes as $node) {
$textContent .= $xmlReader->getValue('w:t', $node);
}
$parent->addTitle($textContent, $headingMatches[1]);
-
- // Text and TextRun
} else {
+ // Text and TextRun
$runCount = $xmlReader->countElements('w:r', $domNode);
$linkCount = $xmlReader->countElements('w:hyperlink', $domNode);
$runLinkCount = $runCount + $linkCount;
@@ -185,7 +180,6 @@ abstract class AbstractPart
* @param mixed $parent
* @param string $docPart
* @param mixed $paragraphStyle
- * @return void
*
* @todo Footnote paragraph style
*/
@@ -205,25 +199,22 @@ abstract class AbstractPart
$parent->addLink($target, $textContent, $fontStyle, $paragraphStyle);
}
} else {
- // Footnote
if ($xmlReader->elementExists('w:footnoteReference', $domNode)) {
+ // Footnote
$parent->addFootnote();
-
- // Endnote
} elseif ($xmlReader->elementExists('w:endnoteReference', $domNode)) {
+ // Endnote
$parent->addEndnote();
-
- // Image
} elseif ($xmlReader->elementExists('w:pict', $domNode)) {
+ // Image
$rId = $xmlReader->getAttribute('r:id', $domNode, 'w:pict/v:shape/v:imagedata');
$target = $this->getMediaTarget($docPart, $rId);
if (!is_null($target)) {
$imageSource = "zip://{$this->docFile}#{$target}";
$parent->addImage($imageSource);
}
-
- // Object
} elseif ($xmlReader->elementExists('w:object', $domNode)) {
+ // Object
$rId = $xmlReader->getAttribute('r:id', $domNode, 'w:object/o:OLEObject');
// $rIdIcon = $xmlReader->getAttribute('r:id', $domNode, 'w:object/v:shape/v:imagedata');
$target = $this->getMediaTarget($docPart, $rId);
@@ -231,9 +222,8 @@ abstract class AbstractPart
$textContent = "
";
$parent->addText($textContent, $fontStyle, $paragraphStyle);
}
-
- // TextRun
} else {
+ // TextRun
$textContent = $xmlReader->getValue('w:t', $domNode);
$parent->addText($textContent, $fontStyle, $paragraphStyle);
}
@@ -247,7 +237,6 @@ abstract class AbstractPart
* @param \DOMElement $domNode
* @param mixed $parent
* @param string $docPart
- * @return void
*/
protected function readTable(XMLReader $xmlReader, \DOMElement $domNode, $parent, $docPart = 'document')
{
diff --git a/src/PhpWord/Reader/Word2007/DocPropsApp.php b/src/PhpWord/Reader/Word2007/DocPropsApp.php
index 6b1410a5..df34c9c3 100644
--- a/src/PhpWord/Reader/Word2007/DocPropsApp.php
+++ b/src/PhpWord/Reader/Word2007/DocPropsApp.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Reader/Word2007/DocPropsCore.php b/src/PhpWord/Reader/Word2007/DocPropsCore.php
index 417a93bd..f82c6b4b 100644
--- a/src/PhpWord/Reader/Word2007/DocPropsCore.php
+++ b/src/PhpWord/Reader/Word2007/DocPropsCore.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,15 +33,15 @@ class DocPropsCore extends AbstractPart
* @var array
*/
protected $mapping = array(
- 'dc:creator' => 'setCreator',
- 'dc:title' => 'setTitle',
- 'dc:description' => 'setDescription',
- 'dc:subject' => 'setSubject',
- 'cp:keywords' => 'setKeywords',
- 'cp:category' => 'setCategory',
+ 'dc:creator' => 'setCreator',
+ 'dc:title' => 'setTitle',
+ 'dc:description' => 'setDescription',
+ 'dc:subject' => 'setSubject',
+ 'cp:keywords' => 'setKeywords',
+ 'cp:category' => 'setCategory',
'cp:lastModifiedBy' => 'setLastModifiedBy',
- 'dcterms:created' => 'setCreated',
- 'dcterms:modified' => 'setModified',
+ 'dcterms:created' => 'setCreated',
+ 'dcterms:modified' => 'setModified',
);
/**
@@ -55,7 +55,6 @@ class DocPropsCore extends AbstractPart
* Read core/extended document properties.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
- * @return void
*/
public function read(PhpWord $phpWord)
{
diff --git a/src/PhpWord/Reader/Word2007/DocPropsCustom.php b/src/PhpWord/Reader/Word2007/DocPropsCustom.php
index 979a2441..a3d6b90b 100644
--- a/src/PhpWord/Reader/Word2007/DocPropsCustom.php
+++ b/src/PhpWord/Reader/Word2007/DocPropsCustom.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -32,7 +32,6 @@ class DocPropsCustom extends AbstractPart
* Read custom document properties.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
- * @return void
*/
public function read(PhpWord $phpWord)
{
diff --git a/src/PhpWord/Reader/Word2007/Document.php b/src/PhpWord/Reader/Word2007/Document.php
index e5063fd9..ff094bcc 100644
--- a/src/PhpWord/Reader/Word2007/Document.php
+++ b/src/PhpWord/Reader/Word2007/Document.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -40,7 +40,6 @@ class Document extends AbstractPart
* Read document.xml.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
- * @return void
*/
public function read(PhpWord $phpWord)
{
@@ -66,7 +65,6 @@ class Document extends AbstractPart
*
* @param array $settings
* @param \PhpOffice\PhpWord\Element\Section &$section
- * @return void
*/
private function readHeaderFooter($settings, Section &$section)
{
@@ -131,7 +129,7 @@ class Document extends AbstractPart
$id = $xmlReader->getAttribute('r:id', $node);
$styles['hf'][$id] = array(
'method' => str_replace('w:', '', str_replace('Reference', '', $node->nodeName)),
- 'type' => $xmlReader->getAttribute('w:type', $node),
+ 'type' => $xmlReader->getAttribute('w:type', $node),
);
}
}
@@ -145,7 +143,6 @@ class Document extends AbstractPart
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $node
* @param \PhpOffice\PhpWord\Element\Section &$section
- * @return void
*
* @todo
*/
@@ -175,7 +172,6 @@ class Document extends AbstractPart
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $node
* @param \PhpOffice\PhpWord\Element\Section &$section
- * @return void
*/
private function readWSectPrNode(XMLReader $xmlReader, \DOMElement $node, Section &$section)
{
diff --git a/src/PhpWord/Reader/Word2007/Endnotes.php b/src/PhpWord/Reader/Word2007/Endnotes.php
index 7bcafc6a..0f46cb2f 100644
--- a/src/PhpWord/Reader/Word2007/Endnotes.php
+++ b/src/PhpWord/Reader/Word2007/Endnotes.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Reader/Word2007/Footnotes.php b/src/PhpWord/Reader/Word2007/Footnotes.php
index 3d85af71..61988723 100644
--- a/src/PhpWord/Reader/Word2007/Footnotes.php
+++ b/src/PhpWord/Reader/Word2007/Footnotes.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -45,7 +45,6 @@ class Footnotes extends AbstractPart
* Read (footnotes|endnotes).xml.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
- * @return void
*/
public function read(PhpWord $phpWord)
{
diff --git a/src/PhpWord/Reader/Word2007/Numbering.php b/src/PhpWord/Reader/Word2007/Numbering.php
index a00a6307..c2a81dd5 100644
--- a/src/PhpWord/Reader/Word2007/Numbering.php
+++ b/src/PhpWord/Reader/Word2007/Numbering.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -31,7 +31,6 @@ class Numbering extends AbstractPart
* Read numbering.xml.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
- * @return void
*/
public function read(PhpWord $phpWord)
{
@@ -92,7 +91,7 @@ class Numbering extends AbstractPart
*
* @param \PhpOffice\Common\XMLReader $xmlReader
* @param \DOMElement $subnode
- * @param integer $levelId
+ * @param int $levelId
* @return array
*/
private function readLevel(XMLReader $xmlReader, \DOMElement $subnode, $levelId)
diff --git a/src/PhpWord/Reader/Word2007/Settings.php b/src/PhpWord/Reader/Word2007/Settings.php
index 581d6b3d..2580209e 100644
--- a/src/PhpWord/Reader/Word2007/Settings.php
+++ b/src/PhpWord/Reader/Word2007/Settings.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -29,14 +29,12 @@ use PhpOffice\PhpWord\Style\Language;
*/
class Settings extends AbstractPart
{
-
private static $booleanProperties = array('hideSpellingErrors', 'hideGrammaticalErrors', 'trackRevisions', 'doNotTrackMoves', 'doNotTrackFormatting', 'evenAndOddHeaders');
/**
* Read settings.xml.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
- * @return void
*/
public function read(PhpWord $phpWord)
{
@@ -58,9 +56,9 @@ class Settings extends AbstractPart
} else {
$docSettings->$method(true);
}
- } else if (method_exists($this, $method)) {
+ } elseif (method_exists($this, $method)) {
$this->$method($xmlReader, $phpWord, $node);
- } else if (method_exists($docSettings, $method)) {
+ } elseif (method_exists($docSettings, $method)) {
$docSettings->$method($value);
}
}
@@ -69,14 +67,13 @@ class Settings extends AbstractPart
/**
* Sets the document Language
- *
+ *
* @param XMLReader $xmlReader
* @param PhpWord $phpWord
* @param \DOMNode $node
*/
protected function setThemeFontLang(XMLReader $xmlReader, PhpWord $phpWord, \DOMElement $node)
{
-
$val = $xmlReader->getAttribute('w:val', $node);
$eastAsia = $xmlReader->getAttribute('w:eastAsia', $node);
$bidi = $xmlReader->getAttribute('w:bidi', $node);
diff --git a/src/PhpWord/Reader/Word2007/Styles.php b/src/PhpWord/Reader/Word2007/Styles.php
index c38ca144..b8e6f22b 100644
--- a/src/PhpWord/Reader/Word2007/Styles.php
+++ b/src/PhpWord/Reader/Word2007/Styles.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -31,7 +31,6 @@ class Styles extends AbstractPart
* Read styles.xml.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
- * @return void
*/
public function read(PhpWord $phpWord)
{
@@ -64,14 +63,12 @@ class Styles extends AbstractPart
}
}
break;
-
case 'character':
$fontStyle = $this->readFontStyle($xmlReader, $node);
if (!empty($fontStyle)) {
$phpWord->addFontStyle($name, $fontStyle);
}
break;
-
case 'table':
$tStyle = $this->readTableStyle($xmlReader, $node);
if (!empty($tStyle)) {
diff --git a/src/PhpWord/Settings.php b/src/PhpWord/Settings.php
index 5309baf7..91efa1a6 100644
--- a/src/PhpWord/Settings.php
+++ b/src/PhpWord/Settings.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -30,8 +30,8 @@ class Settings
* @const string
*/
const ZIPARCHIVE = 'ZipArchive';
- const PCLZIP = 'PclZip';
- const OLD_LIB = 'PhpOffice\\PhpWord\\Shared\\ZipArchive'; // @deprecated 0.11
+ const PCLZIP = 'PclZip';
+ const OLD_LIB = 'PhpOffice\\PhpWord\\Shared\\ZipArchive'; // @deprecated 0.11
/**
* PDF rendering libraries
@@ -39,8 +39,8 @@ class Settings
* @const string
*/
const PDF_RENDERER_DOMPDF = 'DomPDF';
- const PDF_RENDERER_TCPDF = 'TCPDF';
- const PDF_RENDERER_MPDF = 'MPDF';
+ const PDF_RENDERER_TCPDF = 'TCPDF';
+ const PDF_RENDERER_MPDF = 'MPDF';
/**
* Measurement units multiplication factor
@@ -53,12 +53,12 @@ class Settings
*
* @const string
*/
- const UNIT_TWIP = 'twip'; // = 1/20 point
- const UNIT_CM = 'cm';
- const UNIT_MM = 'mm';
- const UNIT_INCH = 'inch';
+ const UNIT_TWIP = 'twip'; // = 1/20 point
+ const UNIT_CM = 'cm';
+ const UNIT_MM = 'mm';
+ const UNIT_INCH = 'inch';
const UNIT_POINT = 'point'; // = 1/72 inch
- const UNIT_PICA = 'pica'; // = 1/6 inch = 12 points
+ const UNIT_PICA = 'pica'; // = 1/6 inch = 12 points
/**
* Default font settings
@@ -154,7 +154,7 @@ class Settings
*/
public static function setCompatibility($compatibility)
{
- $compatibility = (bool)$compatibility;
+ $compatibility = (bool) $compatibility;
self::$xmlWriterCompatibility = $compatibility;
return true;
@@ -180,6 +180,7 @@ class Settings
{
if (in_array($zipClass, array(self::PCLZIP, self::ZIPARCHIVE, self::OLD_LIB))) {
self::$zipClass = $zipClass;
+
return true;
}
@@ -229,7 +230,6 @@ class Settings
return true;
}
-
/**
* Return the directory path to the PDF Rendering Library.
*
@@ -275,7 +275,7 @@ class Settings
public static function setMeasurementUnit($value)
{
$units = array(self::UNIT_TWIP, self::UNIT_CM, self::UNIT_MM, self::UNIT_INCH,
- self::UNIT_POINT, self::UNIT_PICA);
+ self::UNIT_POINT, self::UNIT_PICA, );
if (!in_array($value, $units)) {
return false;
}
@@ -289,9 +289,7 @@ class Settings
*
* @since 0.12.0
*
- * @param string $tempDir The user defined path to temporary directory.
- *
- * @return void
+ * @param string $tempDir The user defined path to temporary directory
*/
public static function setTempDir($tempDir)
{
@@ -319,7 +317,7 @@ class Settings
/**
* @since 0.13.0
*
- * @return boolean
+ * @return bool
*
* @codeCoverageIgnore
*/
@@ -331,7 +329,7 @@ class Settings
/**
* @since 0.13.0
*
- * @param boolean $outputEscapingEnabled
+ * @param bool $outputEscapingEnabled
*
* @codeCoverageIgnore
*/
@@ -360,6 +358,7 @@ class Settings
{
if (is_string($value) && trim($value) !== '') {
self::$defaultFontName = $value;
+
return true;
}
@@ -369,7 +368,7 @@ class Settings
/**
* Get default font size
*
- * @return integer
+ * @return int
*/
public static function getDefaultFontSize()
{
@@ -384,9 +383,10 @@ class Settings
*/
public static function setDefaultFontSize($value)
{
- $value = intval($value);
+ $value = (int) $value;
if ($value > 0) {
self::$defaultFontSize = $value;
+
return true;
}
diff --git a/src/PhpWord/Shared/AbstractEnum.php b/src/PhpWord/Shared/AbstractEnum.php
index 35a5749a..d7839c4f 100644
--- a/src/PhpWord/Shared/AbstractEnum.php
+++ b/src/PhpWord/Shared/AbstractEnum.php
@@ -3,7 +3,6 @@ namespace PhpOffice\PhpWord\Shared;
abstract class AbstractEnum
{
-
private static $constCacheArray = null;
private static function getConstants()
@@ -12,10 +11,11 @@ abstract class AbstractEnum
self::$constCacheArray = array();
}
$calledClass = get_called_class();
- if (! array_key_exists($calledClass, self::$constCacheArray)) {
+ if (!array_key_exists($calledClass, self::$constCacheArray)) {
$reflect = new \ReflectionClass($calledClass);
self::$constCacheArray[$calledClass] = $reflect->getConstants();
}
+
return self::$constCacheArray[$calledClass];
}
@@ -33,11 +33,12 @@ abstract class AbstractEnum
* Returns true the value is valid for this enum
*
* @param strign $value
- * @return boolean true if value is valid
+ * @return bool true if value is valid
*/
public static function isValid($value)
{
$values = array_values(self::getConstants());
+
return in_array($value, $values, true);
}
diff --git a/src/PhpWord/Shared/Converter.php b/src/PhpWord/Shared/Converter.php
index e5cb5b25..6ba2b567 100644
--- a/src/PhpWord/Shared/Converter.php
+++ b/src/PhpWord/Shared/Converter.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -22,12 +22,12 @@ namespace PhpOffice\PhpWord\Shared;
*/
class Converter
{
- const INCH_TO_CM = 2.54;
- const INCH_TO_TWIP = 1440;
- const INCH_TO_PIXEL = 96;
- const INCH_TO_POINT = 72;
- const PIXEL_TO_EMU = 9525;
- const DEGREE_TO_ANGLE = 60000;
+ const INCH_TO_CM = 2.54;
+ const INCH_TO_TWIP = 1440;
+ const INCH_TO_PIXEL = 96;
+ const INCH_TO_POINT = 72;
+ const PIXEL_TO_EMU = 9525;
+ const DEGREE_TO_ANGLE = 60000;
/**
* Convert centimeter to twip
@@ -235,7 +235,7 @@ class Converter
*/
public static function degreeToAngle($degree = 1)
{
- return (int)round($degree * self::DEGREE_TO_ANGLE);
+ return (int) round($degree * self::DEGREE_TO_ANGLE);
}
/**
diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php
index d03d0adf..670ba6e5 100644
--- a/src/PhpWord/Shared/Html.php
+++ b/src/PhpWord/Shared/Html.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -34,7 +34,6 @@ class Html
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element Where the parts need to be added
* @param string $html The code to parse
* @param bool $fullHTML If it's a full HTML, no need to add 'body' tag
- * @return void
*/
public static function addHtml($element, $html, $fullHTML = false)
{
@@ -95,7 +94,6 @@ class Html
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element object to add an element corresponding with the node
* @param array $styles Array with all styles
* @param array $data Array to transport data to a next level in the DOM tree, for example level of listitems
- * @return void
*/
protected static function parseNode($node, $element, $styles = array(), $data = array())
{
@@ -169,7 +167,6 @@ class Html
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array $styles
* @param array $data
- * @return void
*/
private static function parseChildNodes($node, $element, $styles, $data)
{
@@ -226,7 +223,6 @@ class Html
* @param \DOMNode $node
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array &$styles
- * @return null
*/
private static function parseText($node, $element, &$styles)
{
@@ -235,7 +231,7 @@ class Html
// Commented as source of bug #257. `method_exists` doesn't seems to work properly in this case.
// @todo Find better error checking for this one
// if (method_exists($element, 'addText')) {
- $element->addText($node->nodeValue, $styles['font'], $styles['paragraph']);
+ $element->addText($node->nodeValue, $styles['font'], $styles['paragraph']);
// }
return null;
@@ -247,7 +243,6 @@ class Html
* @param array &$styles
* @param string $argument1 Style name
* @param string $argument2 Style value
- * @return null
*/
private static function parseProperty(&$styles, $argument1, $argument2)
{
@@ -275,14 +270,14 @@ class Html
// $attributes = $node->attributes;
// if ($attributes->getNamedItem('width') !== null) {
- // $newElement->setWidth($attributes->getNamedItem('width')->value);
+ // $newElement->setWidth($attributes->getNamedItem('width')->value);
// }
// if ($attributes->getNamedItem('height') !== null) {
- // $newElement->setHeight($attributes->getNamedItem('height')->value);
+ // $newElement->setHeight($attributes->getNamedItem('height')->value);
// }
// if ($attributes->getNamedItem('width') !== null) {
- // $newElement=$element->addCell($width=$attributes->getNamedItem('width')->value);
+ // $newElement=$element->addCell($width=$attributes->getNamedItem('width')->value);
// }
return $newElement;
@@ -294,7 +289,6 @@ class Html
* @param array &$styles
* @param array &$data
* @param string $argument1 List type
- * @return null
*/
private static function parseList(&$styles, &$data, $argument1)
{
@@ -315,7 +309,6 @@ class Html
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
* @param array &$styles
* @param array $data
- * @return null
*
* @todo This function is almost the same like `parseChildNodes`. Merged?
* @todo As soon as ListItem inherits from AbstractContainer or TextRun delete parsing part of childNodes
@@ -364,10 +357,10 @@ class Html
$styles['alignment'] = $cValue; // todo: any mapping?
break;
case 'color':
- $styles['color'] = trim($cValue, "#");
+ $styles['color'] = trim($cValue, '#');
break;
case 'background-color':
- $styles['bgColor'] = trim($cValue, "#");
+ $styles['bgColor'] = trim($cValue, '#');
break;
}
}
diff --git a/src/PhpWord/Shared/OLERead.php b/src/PhpWord/Shared/OLERead.php
index aa671522..e4efd7da 100644
--- a/src/PhpWord/Shared/OLERead.php
+++ b/src/PhpWord/Shared/OLERead.php
@@ -10,11 +10,10 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
-
namespace PhpOffice\PhpWord\Shared;
use PhpOffice\PhpWord\Exception\Exception;
diff --git a/src/PhpWord/Shared/PCLZip/pclzip.lib.php b/src/PhpWord/Shared/PCLZip/pclzip.lib.php
index 4e2a496f..0a69f687 100644
--- a/src/PhpWord/Shared/PCLZip/pclzip.lib.php
+++ b/src/PhpWord/Shared/PCLZip/pclzip.lib.php
@@ -25,4926 +25,2241 @@
// $Id: pclzip.lib.php,v 1.60 2009/09/30 21:01:04 vblavet Exp $
// --------------------------------------------------------------------------------
- // ----- Constants
- if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
- define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
- }
+// ----- Constants
+if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
+ define('PCLZIP_READ_BLOCK_SIZE', 2048);
+}
- // ----- File list separator
- // In version 1.x of PclZip, the separator for file list is a space
- // (which is not a very smart choice, specifically for windows paths !).
- // A better separator should be a comma (,). This constant gives you the
- // abilty to change that.
- // However notice that changing this value, may have impact on existing
- // scripts, using space separated filenames.
- // Recommanded values for compatibility with older versions :
- //define( 'PCLZIP_SEPARATOR', ' ' );
- // Recommanded values for smart separation of filenames.
- if (!defined('PCLZIP_SEPARATOR')) {
- define( 'PCLZIP_SEPARATOR', ',' );
- }
+// ----- File list separator
+// In version 1.x of PclZip, the separator for file list is a space
+// (which is not a very smart choice, specifically for windows paths !).
+// A better separator should be a comma (,). This constant gives you the
+// abilty to change that.
+// However notice that changing this value, may have impact on existing
+// scripts, using space separated filenames.
+// Recommanded values for compatibility with older versions :
+//define( 'PCLZIP_SEPARATOR', ' ' );
+// Recommanded values for smart separation of filenames.
+if (!defined('PCLZIP_SEPARATOR')) {
+ define('PCLZIP_SEPARATOR', ',');
+}
- // ----- Error configuration
- // 0 : PclZip Class integrated error handling
- // 1 : PclError external library error handling. By enabling this
- // you must ensure that you have included PclError library.
- // [2,...] : reserved for futur use
- if (!defined('PCLZIP_ERROR_EXTERNAL')) {
- define( 'PCLZIP_ERROR_EXTERNAL', 0 );
- }
+// ----- Error configuration
+// 0 : PclZip Class integrated error handling
+// 1 : PclError external library error handling. By enabling this
+// you must ensure that you have included PclError library.
+// [2,...] : reserved for futur use
+if (!defined('PCLZIP_ERROR_EXTERNAL')) {
+ define('PCLZIP_ERROR_EXTERNAL', 0);
+}
- // ----- Optional static temporary directory
- // By default temporary files are generated in the script current
- // path.
- // If defined :
- // - MUST BE terminated by a '/'.
- // - MUST be a valid, already created directory
- // Samples :
- // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
- // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
- if (!defined('PCLZIP_TEMPORARY_DIR')) {
- define( 'PCLZIP_TEMPORARY_DIR', '' );
- }
+// ----- Optional static temporary directory
+// By default temporary files are generated in the script current
+// path.
+// If defined :
+// - MUST BE terminated by a '/'.
+// - MUST be a valid, already created directory
+// Samples :
+// define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
+// define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
+if (!defined('PCLZIP_TEMPORARY_DIR')) {
+ define('PCLZIP_TEMPORARY_DIR', '');
+}
- // ----- Optional threshold ratio for use of temporary files
- // Pclzip sense the size of the file to add/extract and decide to
- // use or not temporary file. The algorythm is looking for
- // memory_limit of PHP and apply a ratio.
- // threshold = memory_limit * ratio.
- // Recommended values are under 0.5. Default 0.47.
- // Samples :
- // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
- if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
- define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
- }
+// ----- Optional threshold ratio for use of temporary files
+// Pclzip sense the size of the file to add/extract and decide to
+// use or not temporary file. The algorythm is looking for
+// memory_limit of PHP and apply a ratio.
+// threshold = memory_limit * ratio.
+// Recommended values are under 0.5. Default 0.47.
+// Samples :
+// define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
+if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
+ define('PCLZIP_TEMPORARY_FILE_RATIO', 0.47);
+}
// --------------------------------------------------------------------------------
// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
// --------------------------------------------------------------------------------
- // ----- Global variables
- $g_pclzip_version = "2.8.2";
+// ----- Global variables
+$g_pclzip_version = "2.8.2";
- // ----- Error codes
- // -1 : Unable to open file in binary write mode
- // -2 : Unable to open file in binary read mode
- // -3 : Invalid parameters
- // -4 : File does not exist
- // -5 : Filename is too long (max. 255)
- // -6 : Not a valid zip file
- // -7 : Invalid extracted file size
- // -8 : Unable to create directory
- // -9 : Invalid archive extension
- // -10 : Invalid archive format
- // -11 : Unable to delete file (unlink)
- // -12 : Unable to rename file (rename)
- // -13 : Invalid header checksum
- // -14 : Invalid archive size
- define( 'PCLZIP_ERR_USER_ABORTED', 2 );
- define( 'PCLZIP_ERR_NO_ERROR', 0 );
- define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
- define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
- define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
- define( 'PCLZIP_ERR_MISSING_FILE', -4 );
- define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
- define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
- define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
- define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
- define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
- define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
- define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
- define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
- define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
- define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
- define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
- define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
- define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
- define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
- define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
- define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
- define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
+// ----- Error codes
+// -1 : Unable to open file in binary write mode
+// -2 : Unable to open file in binary read mode
+// -3 : Invalid parameters
+// -4 : File does not exist
+// -5 : Filename is too long (max. 255)
+// -6 : Not a valid zip file
+// -7 : Invalid extracted file size
+// -8 : Unable to create directory
+// -9 : Invalid archive extension
+// -10 : Invalid archive format
+// -11 : Unable to delete file (unlink)
+// -12 : Unable to rename file (rename)
+// -13 : Invalid header checksum
+// -14 : Invalid archive size
+define('PCLZIP_ERR_USER_ABORTED', 2);
+define('PCLZIP_ERR_NO_ERROR', 0);
+define('PCLZIP_ERR_WRITE_OPEN_FAIL', -1);
+define('PCLZIP_ERR_READ_OPEN_FAIL', -2);
+define('PCLZIP_ERR_INVALID_PARAMETER', -3);
+define('PCLZIP_ERR_MISSING_FILE', -4);
+define('PCLZIP_ERR_FILENAME_TOO_LONG', -5);
+define('PCLZIP_ERR_INVALID_ZIP', -6);
+define('PCLZIP_ERR_BAD_EXTRACTED_FILE', -7);
+define('PCLZIP_ERR_DIR_CREATE_FAIL', -8);
+define('PCLZIP_ERR_BAD_EXTENSION', -9);
+define('PCLZIP_ERR_BAD_FORMAT', -10);
+define('PCLZIP_ERR_DELETE_FILE_FAIL', -11);
+define('PCLZIP_ERR_RENAME_FILE_FAIL', -12);
+define('PCLZIP_ERR_BAD_CHECKSUM', -13);
+define('PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14);
+define('PCLZIP_ERR_MISSING_OPTION_VALUE', -15);
+define('PCLZIP_ERR_INVALID_OPTION_VALUE', -16);
+define('PCLZIP_ERR_ALREADY_A_DIRECTORY', -17);
+define('PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18);
+define('PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19);
+define('PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20);
+define('PCLZIP_ERR_DIRECTORY_RESTRICTION', -21);
- // ----- Options values
- define( 'PCLZIP_OPT_PATH', 77001 );
- define( 'PCLZIP_OPT_ADD_PATH', 77002 );
- define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
- define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
- define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
- define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
- define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
- define( 'PCLZIP_OPT_BY_NAME', 77008 );
- define( 'PCLZIP_OPT_BY_INDEX', 77009 );
- define( 'PCLZIP_OPT_BY_EREG', 77010 );
- define( 'PCLZIP_OPT_BY_PREG', 77011 );
- define( 'PCLZIP_OPT_COMMENT', 77012 );
- define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
- define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
- define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
- define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
- define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
- // Having big trouble with crypt. Need to multiply 2 long int
- // which is not correctly supported by PHP ...
- //define( 'PCLZIP_OPT_CRYPT', 77018 );
- define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
- define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
- define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
- define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
- define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
- define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
- define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
+// ----- Options values
+define('PCLZIP_OPT_PATH', 77001);
+define('PCLZIP_OPT_ADD_PATH', 77002);
+define('PCLZIP_OPT_REMOVE_PATH', 77003);
+define('PCLZIP_OPT_REMOVE_ALL_PATH', 77004);
+define('PCLZIP_OPT_SET_CHMOD', 77005);
+define('PCLZIP_OPT_EXTRACT_AS_STRING', 77006);
+define('PCLZIP_OPT_NO_COMPRESSION', 77007);
+define('PCLZIP_OPT_BY_NAME', 77008);
+define('PCLZIP_OPT_BY_INDEX', 77009);
+define('PCLZIP_OPT_BY_EREG', 77010);
+define('PCLZIP_OPT_BY_PREG', 77011);
+define('PCLZIP_OPT_COMMENT', 77012);
+define('PCLZIP_OPT_ADD_COMMENT', 77013);
+define('PCLZIP_OPT_PREPEND_COMMENT', 77014);
+define('PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015);
+define('PCLZIP_OPT_REPLACE_NEWER', 77016);
+define('PCLZIP_OPT_STOP_ON_ERROR', 77017);
+// Having big trouble with crypt. Need to multiply 2 long int
+// which is not correctly supported by PHP ...
+//define( 'PCLZIP_OPT_CRYPT', 77018 );
+define('PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019);
+define('PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020);
+define('PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020); // alias
+define('PCLZIP_OPT_TEMP_FILE_ON', 77021);
+define('PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021); // alias
+define('PCLZIP_OPT_TEMP_FILE_OFF', 77022);
+define('PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022); // alias
- // ----- File description attributes
- define( 'PCLZIP_ATT_FILE_NAME', 79001 );
- define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
- define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
- define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
- define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
- define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
+// ----- File description attributes
+define('PCLZIP_ATT_FILE_NAME', 79001);
+define('PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002);
+define('PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003);
+define('PCLZIP_ATT_FILE_MTIME', 79004);
+define('PCLZIP_ATT_FILE_CONTENT', 79005);
+define('PCLZIP_ATT_FILE_COMMENT', 79006);
- // ----- Call backs values
- define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
- define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
- define( 'PCLZIP_CB_PRE_ADD', 78003 );
- define( 'PCLZIP_CB_POST_ADD', 78004 );
- /* For futur use
- define( 'PCLZIP_CB_PRE_LIST', 78005 );
- define( 'PCLZIP_CB_POST_LIST', 78006 );
- define( 'PCLZIP_CB_PRE_DELETE', 78007 );
- define( 'PCLZIP_CB_POST_DELETE', 78008 );
- */
+// ----- Call backs values
+define('PCLZIP_CB_PRE_EXTRACT', 78001);
+define('PCLZIP_CB_POST_EXTRACT', 78002);
+define('PCLZIP_CB_PRE_ADD', 78003);
+define('PCLZIP_CB_POST_ADD', 78004);
+/* For futur use
+define( 'PCLZIP_CB_PRE_LIST', 78005 );
+define( 'PCLZIP_CB_POST_LIST', 78006 );
+define( 'PCLZIP_CB_PRE_DELETE', 78007 );
+define( 'PCLZIP_CB_POST_DELETE', 78008 );
+*/
- // --------------------------------------------------------------------------------
- // Class : PclZip
- // Description :
- // PclZip is the class that represent a Zip archive.
- // The public methods allow the manipulation of the archive.
- // Attributes :
- // Attributes must not be accessed directly.
- // Methods :
- // PclZip() : Object creator
- // create() : Creates the Zip archive
- // listContent() : List the content of the Zip archive
- // extract() : Extract the content of the archive
- // properties() : List the properties of the archive
- // --------------------------------------------------------------------------------
- class PclZip
- {
+// --------------------------------------------------------------------------------
+// Class : PclZip
+// Description :
+// PclZip is the class that represent a Zip archive.
+// The public methods allow the manipulation of the archive.
+// Attributes :
+// Attributes must not be accessed directly.
+// Methods :
+// PclZip() : Object creator
+// create() : Creates the Zip archive
+// listContent() : List the content of the Zip archive
+// extract() : Extract the content of the archive
+// properties() : List the properties of the archive
+// --------------------------------------------------------------------------------
+class PclZip
+{
// ----- Filename of the zip file
- var $zipname = '';
+ public $zipname = '';
// ----- File descriptor of the zip file
- var $zip_fd = 0;
+ public $zip_fd = 0;
// ----- Internal error handling
- var $error_code = 1;
- var $error_string = '';
+ public $error_code = 1;
+ public $error_string = '';
// ----- Current status of the magic_quotes_runtime
// This value store the php configuration for magic_quotes
// The class can then disable the magic_quotes and reset it after
- var $magic_quotes_status;
+ public $magic_quotes_status;
- // --------------------------------------------------------------------------------
- // Function : PclZip()
- // Description :
- // Creates a PclZip object and set the name of the associated Zip archive
- // filename.
- // Note that no real action is taken, if the archive does not exist it is not
- // created. Use create() for that.
- // --------------------------------------------------------------------------------
- function PclZip($p_zipname)
- {
-
- // ----- Tests the zlib
- if (!function_exists('gzopen'))
+ // --------------------------------------------------------------------------------
+ // Function : PclZip()
+ // Description :
+ // Creates a PclZip object and set the name of the associated Zip archive
+ // filename.
+ // Note that no real action is taken, if the archive does not exist it is not
+ // created. Use create() for that.
+ // --------------------------------------------------------------------------------
+ public function __construct($p_zipname)
{
- die('Abort '.basename(__FILE__).' : Missing zlib extensions');
- }
- // ----- Set the attributes
- $this->zipname = $p_zipname;
- $this->zip_fd = 0;
- $this->magic_quotes_status = -1;
-
- // ----- Return
- return;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function :
- // create($p_filelist, $p_add_dir="", $p_remove_dir="")
- // create($p_filelist, $p_option, $p_option_value, ...)
- // Description :
- // This method supports two different synopsis. The first one is historical.
- // This method creates a Zip Archive. The Zip file is created in the
- // filesystem. The files and directories indicated in $p_filelist
- // are added in the archive. See the parameters description for the
- // supported format of $p_filelist.
- // When a directory is in the list, the directory and its content is added
- // in the archive.
- // In this synopsis, the function takes an optional variable list of
- // options. See bellow the supported options.
- // Parameters :
- // $p_filelist : An array containing file or directory names, or
- // a string containing one filename or one directory name, or
- // a string containing a list of filenames and/or directory
- // names separated by spaces.
- // $p_add_dir : A path to add before the real path of the archived file,
- // in order to have it memorized in the archive.
- // $p_remove_dir : A path to remove from the real path of the file to archive,
- // in order to have a shorter path memorized in the archive.
- // When $p_add_dir and $p_remove_dir are set, $p_remove_dir
- // is removed first, before $p_add_dir is added.
- // Options :
- // PCLZIP_OPT_ADD_PATH :
- // PCLZIP_OPT_REMOVE_PATH :
- // PCLZIP_OPT_REMOVE_ALL_PATH :
- // PCLZIP_OPT_COMMENT :
- // PCLZIP_CB_PRE_ADD :
- // PCLZIP_CB_POST_ADD :
- // Return Values :
- // 0 on failure,
- // The list of the added files, with a status of the add action.
- // (see PclZip::listContent() for list entry format)
- // --------------------------------------------------------------------------------
- function create($p_filelist)
- {
- $v_result=1;
-
- // ----- Reset the error handler
- $this->privErrorReset();
-
- // ----- Set default values
- $v_options = array();
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
-
- // ----- Look for variable options arguments
- $v_size = func_num_args();
-
- // ----- Look for arguments
- if ($v_size > 1) {
- // ----- Get the arguments
- $v_arg_list = func_get_args();
-
- // ----- Remove from the options list the first argument
- array_shift($v_arg_list);
- $v_size--;
-
- // ----- Look for first arg
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
-
- // ----- Parse the options
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
- array (PCLZIP_OPT_REMOVE_PATH => 'optional',
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
- PCLZIP_OPT_ADD_PATH => 'optional',
- PCLZIP_CB_PRE_ADD => 'optional',
- PCLZIP_CB_POST_ADD => 'optional',
- PCLZIP_OPT_NO_COMPRESSION => 'optional',
- PCLZIP_OPT_COMMENT => 'optional',
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
- //, PCLZIP_OPT_CRYPT => 'optional'
- ));
- if ($v_result != 1) {
- return 0;
- }
- }
-
- // ----- Look for 2 args
- // Here we need to support the first historic synopsis of the
- // method.
- else {
-
- // ----- Get the first argument
- $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
-
- // ----- Look for the optional second argument
- if ($v_size == 2) {
- $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
- }
- else if ($v_size > 2) {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
- "Invalid number / type of arguments");
- return 0;
- }
- }
- }
-
- // ----- Look for default option values
- $this->privOptionDefaultThreshold($v_options);
-
- // ----- Init
- $v_string_list = array();
- $v_att_list = array();
- $v_filedescr_list = array();
- $p_result_list = array();
-
- // ----- Look if the $p_filelist is really an array
- if (is_array($p_filelist)) {
-
- // ----- Look if the first element is also an array
- // This will mean that this is a file description entry
- if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
- $v_att_list = $p_filelist;
- }
-
- // ----- The list is a list of string names
- else {
- $v_string_list = $p_filelist;
- }
- }
-
- // ----- Look if the $p_filelist is a string
- else if (is_string($p_filelist)) {
- // ----- Create a list from the string
- $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
- }
-
- // ----- Invalid variable type for $p_filelist
- else {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
- return 0;
- }
-
- // ----- Reformat the string list
- if (sizeof($v_string_list) != 0) {
- foreach ($v_string_list as $v_string) {
- if ($v_string != '') {
- $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
- }
- else {
- }
- }
- }
-
- // ----- For each file in the list check the attributes
- $v_supported_attributes
- = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
- ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
- ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
- ,PCLZIP_ATT_FILE_MTIME => 'optional'
- ,PCLZIP_ATT_FILE_CONTENT => 'optional'
- ,PCLZIP_ATT_FILE_COMMENT => 'optional'
- );
- foreach ($v_att_list as $v_entry) {
- $v_result = $this->privFileDescrParseAtt($v_entry,
- $v_filedescr_list[],
- $v_options,
- $v_supported_attributes);
- if ($v_result != 1) {
- return 0;
- }
- }
-
- // ----- Expand the filelist (expand directories)
- $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
- if ($v_result != 1) {
- return 0;
- }
-
- // ----- Call the create fct
- $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
- if ($v_result != 1) {
- return 0;
- }
-
- // ----- Return
- return $p_result_list;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function :
- // add($p_filelist, $p_add_dir="", $p_remove_dir="")
- // add($p_filelist, $p_option, $p_option_value, ...)
- // Description :
- // This method supports two synopsis. The first one is historical.
- // This methods add the list of files in an existing archive.
- // If a file with the same name already exists, it is added at the end of the
- // archive, the first one is still present.
- // If the archive does not exist, it is created.
- // Parameters :
- // $p_filelist : An array containing file or directory names, or
- // a string containing one filename or one directory name, or
- // a string containing a list of filenames and/or directory
- // names separated by spaces.
- // $p_add_dir : A path to add before the real path of the archived file,
- // in order to have it memorized in the archive.
- // $p_remove_dir : A path to remove from the real path of the file to archive,
- // in order to have a shorter path memorized in the archive.
- // When $p_add_dir and $p_remove_dir are set, $p_remove_dir
- // is removed first, before $p_add_dir is added.
- // Options :
- // PCLZIP_OPT_ADD_PATH :
- // PCLZIP_OPT_REMOVE_PATH :
- // PCLZIP_OPT_REMOVE_ALL_PATH :
- // PCLZIP_OPT_COMMENT :
- // PCLZIP_OPT_ADD_COMMENT :
- // PCLZIP_OPT_PREPEND_COMMENT :
- // PCLZIP_CB_PRE_ADD :
- // PCLZIP_CB_POST_ADD :
- // Return Values :
- // 0 on failure,
- // The list of the added files, with a status of the add action.
- // (see PclZip::listContent() for list entry format)
- // --------------------------------------------------------------------------------
- function add($p_filelist)
- {
- $v_result=1;
-
- // ----- Reset the error handler
- $this->privErrorReset();
-
- // ----- Set default values
- $v_options = array();
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
-
- // ----- Look for variable options arguments
- $v_size = func_num_args();
-
- // ----- Look for arguments
- if ($v_size > 1) {
- // ----- Get the arguments
- $v_arg_list = func_get_args();
-
- // ----- Remove form the options list the first argument
- array_shift($v_arg_list);
- $v_size--;
-
- // ----- Look for first arg
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
-
- // ----- Parse the options
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
- array (PCLZIP_OPT_REMOVE_PATH => 'optional',
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
- PCLZIP_OPT_ADD_PATH => 'optional',
- PCLZIP_CB_PRE_ADD => 'optional',
- PCLZIP_CB_POST_ADD => 'optional',
- PCLZIP_OPT_NO_COMPRESSION => 'optional',
- PCLZIP_OPT_COMMENT => 'optional',
- PCLZIP_OPT_ADD_COMMENT => 'optional',
- PCLZIP_OPT_PREPEND_COMMENT => 'optional',
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
- //, PCLZIP_OPT_CRYPT => 'optional'
- ));
- if ($v_result != 1) {
- return 0;
- }
- }
-
- // ----- Look for 2 args
- // Here we need to support the first historic synopsis of the
- // method.
- else {
-
- // ----- Get the first argument
- $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
-
- // ----- Look for the optional second argument
- if ($v_size == 2) {
- $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
- }
- else if ($v_size > 2) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
-
- // ----- Return
- return 0;
- }
- }
- }
-
- // ----- Look for default option values
- $this->privOptionDefaultThreshold($v_options);
-
- // ----- Init
- $v_string_list = array();
- $v_att_list = array();
- $v_filedescr_list = array();
- $p_result_list = array();
-
- // ----- Look if the $p_filelist is really an array
- if (is_array($p_filelist)) {
-
- // ----- Look if the first element is also an array
- // This will mean that this is a file description entry
- if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
- $v_att_list = $p_filelist;
- }
-
- // ----- The list is a list of string names
- else {
- $v_string_list = $p_filelist;
- }
- }
-
- // ----- Look if the $p_filelist is a string
- else if (is_string($p_filelist)) {
- // ----- Create a list from the string
- $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
- }
-
- // ----- Invalid variable type for $p_filelist
- else {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
- return 0;
- }
-
- // ----- Reformat the string list
- if (sizeof($v_string_list) != 0) {
- foreach ($v_string_list as $v_string) {
- $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
- }
- }
-
- // ----- For each file in the list check the attributes
- $v_supported_attributes
- = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
- ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
- ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
- ,PCLZIP_ATT_FILE_MTIME => 'optional'
- ,PCLZIP_ATT_FILE_CONTENT => 'optional'
- ,PCLZIP_ATT_FILE_COMMENT => 'optional'
- );
- foreach ($v_att_list as $v_entry) {
- $v_result = $this->privFileDescrParseAtt($v_entry,
- $v_filedescr_list[],
- $v_options,
- $v_supported_attributes);
- if ($v_result != 1) {
- return 0;
- }
- }
-
- // ----- Expand the filelist (expand directories)
- $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
- if ($v_result != 1) {
- return 0;
- }
-
- // ----- Call the create fct
- $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
- if ($v_result != 1) {
- return 0;
- }
-
- // ----- Return
- return $p_result_list;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : listContent()
- // Description :
- // This public method, gives the list of the files and directories, with their
- // properties.
- // The properties of each entries in the list are (used also in other functions) :
- // filename : Name of the file. For a create or add action it is the filename
- // given by the user. For an extract function it is the filename
- // of the extracted file.
- // stored_filename : Name of the file / directory stored in the archive.
- // size : Size of the stored file.
- // compressed_size : Size of the file's data compressed in the archive
- // (without the headers overhead)
- // mtime : Last known modification date of the file (UNIX timestamp)
- // comment : Comment associated with the file
- // folder : true | false
- // index : index of the file in the archive
- // status : status of the action (depending of the action) :
- // Values are :
- // ok : OK !
- // filtered : the file / dir is not extracted (filtered by user)
- // already_a_directory : the file can not be extracted because a
- // directory with the same name already exists
- // write_protected : the file can not be extracted because a file
- // with the same name already exists and is
- // write protected
- // newer_exist : the file was not extracted because a newer file exists
- // path_creation_fail : the file is not extracted because the folder
- // does not exist and can not be created
- // write_error : the file was not extracted because there was a
- // error while writing the file
- // read_error : the file was not extracted because there was a error
- // while reading the file
- // invalid_header : the file was not extracted because of an archive
- // format error (bad file header)
- // Note that each time a method can continue operating when there
- // is an action error on a file, the error is only logged in the file status.
- // Return Values :
- // 0 on an unrecoverable failure,
- // The list of the files in the archive.
- // --------------------------------------------------------------------------------
- function listContent()
- {
- $v_result=1;
-
- // ----- Reset the error handler
- $this->privErrorReset();
-
- // ----- Check archive
- if (!$this->privCheckFormat()) {
- return(0);
- }
-
- // ----- Call the extracting fct
- $p_list = array();
- if (($v_result = $this->privList($p_list)) != 1)
- {
- unset($p_list);
- return(0);
- }
-
- // ----- Return
- return $p_list;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function :
- // extract($p_path="./", $p_remove_path="")
- // extract([$p_option, $p_option_value, ...])
- // Description :
- // This method supports two synopsis. The first one is historical.
- // This method extract all the files / directories from the archive to the
- // folder indicated in $p_path.
- // If you want to ignore the 'root' part of path of the memorized files
- // you can indicate this in the optional $p_remove_path parameter.
- // By default, if a newer file with the same name already exists, the
- // file is not extracted.
- //
- // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
- // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
- // at the end of the path value of PCLZIP_OPT_PATH.
- // Parameters :
- // $p_path : Path where the files and directories are to be extracted
- // $p_remove_path : First part ('root' part) of the memorized path
- // (if any similar) to remove while extracting.
- // Options :
- // PCLZIP_OPT_PATH :
- // PCLZIP_OPT_ADD_PATH :
- // PCLZIP_OPT_REMOVE_PATH :
- // PCLZIP_OPT_REMOVE_ALL_PATH :
- // PCLZIP_CB_PRE_EXTRACT :
- // PCLZIP_CB_POST_EXTRACT :
- // Return Values :
- // 0 or a negative value on failure,
- // The list of the extracted files, with a status of the action.
- // (see PclZip::listContent() for list entry format)
- // --------------------------------------------------------------------------------
- function extract()
- {
- $v_result=1;
-
- // ----- Reset the error handler
- $this->privErrorReset();
-
- // ----- Check archive
- if (!$this->privCheckFormat()) {
- return(0);
- }
-
- // ----- Set default values
- $v_options = array();
-// $v_path = "./";
- $v_path = '';
- $v_remove_path = "";
- $v_remove_all_path = false;
-
- // ----- Look for variable options arguments
- $v_size = func_num_args();
-
- // ----- Default values for option
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
-
- // ----- Look for arguments
- if ($v_size > 0) {
- // ----- Get the arguments
- $v_arg_list = func_get_args();
-
- // ----- Look for first arg
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
-
- // ----- Parse the options
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
- array (PCLZIP_OPT_PATH => 'optional',
- PCLZIP_OPT_REMOVE_PATH => 'optional',
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
- PCLZIP_OPT_ADD_PATH => 'optional',
- PCLZIP_CB_PRE_EXTRACT => 'optional',
- PCLZIP_CB_POST_EXTRACT => 'optional',
- PCLZIP_OPT_SET_CHMOD => 'optional',
- PCLZIP_OPT_BY_NAME => 'optional',
- PCLZIP_OPT_BY_EREG => 'optional',
- PCLZIP_OPT_BY_PREG => 'optional',
- PCLZIP_OPT_BY_INDEX => 'optional',
- PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
- PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
- PCLZIP_OPT_REPLACE_NEWER => 'optional'
- ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
- ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
- ));
- if ($v_result != 1) {
- return 0;
+ // ----- Tests the zlib
+ if (!function_exists('gzopen')) {
+ die('Abort ' . basename(__FILE__) . ' : Missing zlib extensions');
}
- // ----- Set the arguments
- if (isset($v_options[PCLZIP_OPT_PATH])) {
- $v_path = $v_options[PCLZIP_OPT_PATH];
- }
- if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
- $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
- }
- if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
- $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
- }
- if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
- // ----- Check for '/' in last path char
- if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
- $v_path .= '/';
- }
- $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
- }
- }
-
- // ----- Look for 2 args
- // Here we need to support the first historic synopsis of the
- // method.
- else {
-
- // ----- Get the first argument
- $v_path = $v_arg_list[0];
-
- // ----- Look for the optional second argument
- if ($v_size == 2) {
- $v_remove_path = $v_arg_list[1];
- }
- else if ($v_size > 2) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
-
- // ----- Return
- return 0;
- }
- }
- }
-
- // ----- Look for default option values
- $this->privOptionDefaultThreshold($v_options);
-
- // ----- Trace
-
- // ----- Call the extracting fct
- $p_list = array();
- $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
- $v_remove_all_path, $v_options);
- if ($v_result < 1) {
- unset($p_list);
- return(0);
- }
-
- // ----- Return
- return $p_list;
- }
- // --------------------------------------------------------------------------------
-
-
- // --------------------------------------------------------------------------------
- // Function :
- // extractByIndex($p_index, $p_path="./", $p_remove_path="")
- // extractByIndex($p_index, [$p_option, $p_option_value, ...])
- // Description :
- // This method supports two synopsis. The first one is historical.
- // This method is doing a partial extract of the archive.
- // The extracted files or folders are identified by their index in the
- // archive (from 0 to n).
- // Note that if the index identify a folder, only the folder entry is
- // extracted, not all the files included in the archive.
- // Parameters :
- // $p_index : A single index (integer) or a string of indexes of files to
- // extract. The form of the string is "0,4-6,8-12" with only numbers
- // and '-' for range or ',' to separate ranges. No spaces or ';'
- // are allowed.
- // $p_path : Path where the files and directories are to be extracted
- // $p_remove_path : First part ('root' part) of the memorized path
- // (if any similar) to remove while extracting.
- // Options :
- // PCLZIP_OPT_PATH :
- // PCLZIP_OPT_ADD_PATH :
- // PCLZIP_OPT_REMOVE_PATH :
- // PCLZIP_OPT_REMOVE_ALL_PATH :
- // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
- // not as files.
- // The resulting content is in a new field 'content' in the file
- // structure.
- // This option must be used alone (any other options are ignored).
- // PCLZIP_CB_PRE_EXTRACT :
- // PCLZIP_CB_POST_EXTRACT :
- // Return Values :
- // 0 on failure,
- // The list of the extracted files, with a status of the action.
- // (see PclZip::listContent() for list entry format)
- // --------------------------------------------------------------------------------
- //function extractByIndex($p_index, options...)
- function extractByIndex($p_index)
- {
- $v_result=1;
-
- // ----- Reset the error handler
- $this->privErrorReset();
-
- // ----- Check archive
- if (!$this->privCheckFormat()) {
- return(0);
- }
-
- // ----- Set default values
- $v_options = array();
-// $v_path = "./";
- $v_path = '';
- $v_remove_path = "";
- $v_remove_all_path = false;
-
- // ----- Look for variable options arguments
- $v_size = func_num_args();
-
- // ----- Default values for option
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
-
- // ----- Look for arguments
- if ($v_size > 1) {
- // ----- Get the arguments
- $v_arg_list = func_get_args();
-
- // ----- Remove form the options list the first argument
- array_shift($v_arg_list);
- $v_size--;
-
- // ----- Look for first arg
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
-
- // ----- Parse the options
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
- array (PCLZIP_OPT_PATH => 'optional',
- PCLZIP_OPT_REMOVE_PATH => 'optional',
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
- PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
- PCLZIP_OPT_ADD_PATH => 'optional',
- PCLZIP_CB_PRE_EXTRACT => 'optional',
- PCLZIP_CB_POST_EXTRACT => 'optional',
- PCLZIP_OPT_SET_CHMOD => 'optional',
- PCLZIP_OPT_REPLACE_NEWER => 'optional'
- ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
- ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
- PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
- PCLZIP_OPT_TEMP_FILE_ON => 'optional',
- PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
- ));
- if ($v_result != 1) {
- return 0;
- }
-
- // ----- Set the arguments
- if (isset($v_options[PCLZIP_OPT_PATH])) {
- $v_path = $v_options[PCLZIP_OPT_PATH];
- }
- if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
- $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
- }
- if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
- $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
- }
- if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
- // ----- Check for '/' in last path char
- if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
- $v_path .= '/';
- }
- $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
- }
- if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
- }
- else {
- }
- }
-
- // ----- Look for 2 args
- // Here we need to support the first historic synopsis of the
- // method.
- else {
-
- // ----- Get the first argument
- $v_path = $v_arg_list[0];
-
- // ----- Look for the optional second argument
- if ($v_size == 2) {
- $v_remove_path = $v_arg_list[1];
- }
- else if ($v_size > 2) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
-
- // ----- Return
- return 0;
- }
- }
- }
-
- // ----- Trace
-
- // ----- Trick
- // Here I want to reuse extractByRule(), so I need to parse the $p_index
- // with privParseOptions()
- $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
- $v_options_trick = array();
- $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
- array (PCLZIP_OPT_BY_INDEX => 'optional' ));
- if ($v_result != 1) {
- return 0;
- }
- $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
-
- // ----- Look for default option values
- $this->privOptionDefaultThreshold($v_options);
-
- // ----- Call the extracting fct
- if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
- return(0);
- }
-
- // ----- Return
- return $p_list;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function :
- // delete([$p_option, $p_option_value, ...])
- // Description :
- // This method removes files from the archive.
- // If no parameters are given, then all the archive is emptied.
- // Parameters :
- // None or optional arguments.
- // Options :
- // PCLZIP_OPT_BY_INDEX :
- // PCLZIP_OPT_BY_NAME :
- // PCLZIP_OPT_BY_EREG :
- // PCLZIP_OPT_BY_PREG :
- // Return Values :
- // 0 on failure,
- // The list of the files which are still present in the archive.
- // (see PclZip::listContent() for list entry format)
- // --------------------------------------------------------------------------------
- function delete()
- {
- $v_result=1;
-
- // ----- Reset the error handler
- $this->privErrorReset();
-
- // ----- Check archive
- if (!$this->privCheckFormat()) {
- return(0);
- }
-
- // ----- Set default values
- $v_options = array();
-
- // ----- Look for variable options arguments
- $v_size = func_num_args();
-
- // ----- Look for arguments
- if ($v_size > 0) {
- // ----- Get the arguments
- $v_arg_list = func_get_args();
-
- // ----- Parse the options
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
- array (PCLZIP_OPT_BY_NAME => 'optional',
- PCLZIP_OPT_BY_EREG => 'optional',
- PCLZIP_OPT_BY_PREG => 'optional',
- PCLZIP_OPT_BY_INDEX => 'optional' ));
- if ($v_result != 1) {
- return 0;
- }
- }
-
- // ----- Magic quotes trick
- $this->privDisableMagicQuotes();
-
- // ----- Call the delete fct
- $v_list = array();
- if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
- $this->privSwapBackMagicQuotes();
- unset($v_list);
- return(0);
- }
-
- // ----- Magic quotes trick
- $this->privSwapBackMagicQuotes();
-
- // ----- Return
- return $v_list;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : deleteByIndex()
- // Description :
- // ***** Deprecated *****
- // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
- // --------------------------------------------------------------------------------
- function deleteByIndex($p_index)
- {
-
- $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
-
- // ----- Return
- return $p_list;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : properties()
- // Description :
- // This method gives the properties of the archive.
- // The properties are :
- // nb : Number of files in the archive
- // comment : Comment associated with the archive file
- // status : not_exist, ok
- // Parameters :
- // None
- // Return Values :
- // 0 on failure,
- // An array with the archive properties.
- // --------------------------------------------------------------------------------
- function properties()
- {
-
- // ----- Reset the error handler
- $this->privErrorReset();
-
- // ----- Magic quotes trick
- $this->privDisableMagicQuotes();
-
- // ----- Check archive
- if (!$this->privCheckFormat()) {
- $this->privSwapBackMagicQuotes();
- return(0);
- }
-
- // ----- Default properties
- $v_prop = array();
- $v_prop['comment'] = '';
- $v_prop['nb'] = 0;
- $v_prop['status'] = 'not_exist';
-
- // ----- Look if file exists
- if (@is_file($this->zipname))
- {
- // ----- Open the zip file
- if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
- {
- $this->privSwapBackMagicQuotes();
-
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
+ // ----- Set the attributes
+ $this->zipname = $p_zipname;
+ $this->zip_fd = 0;
+ $this->magic_quotes_status = -1;
// ----- Return
- return 0;
- }
-
- // ----- Read the central directory informations
- $v_central_dir = array();
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
- {
- $this->privSwapBackMagicQuotes();
- return 0;
- }
-
- // ----- Close the zip file
- $this->privCloseFd();
-
- // ----- Set the user attributes
- $v_prop['comment'] = $v_central_dir['comment'];
- $v_prop['nb'] = $v_central_dir['entries'];
- $v_prop['status'] = 'ok';
+ return;
}
+ // --------------------------------------------------------------------------------
- // ----- Magic quotes trick
- $this->privSwapBackMagicQuotes();
-
- // ----- Return
- return $v_prop;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : duplicate()
- // Description :
- // This method creates an archive by copying the content of an other one. If
- // the archive already exist, it is replaced by the new one without any warning.
- // Parameters :
- // $p_archive : The filename of a valid archive, or
- // a valid PclZip object.
- // Return Values :
- // 1 on success.
- // 0 or a negative value on error (error code).
- // --------------------------------------------------------------------------------
- function duplicate($p_archive)
- {
- $v_result = 1;
-
- // ----- Reset the error handler
- $this->privErrorReset();
-
- // ----- Look if the $p_archive is a PclZip object
- if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
+ // --------------------------------------------------------------------------------
+ // Function :
+ // create($p_filelist, $p_add_dir="", $p_remove_dir="")
+ // create($p_filelist, $p_option, $p_option_value, ...)
+ // Description :
+ // This method supports two different synopsis. The first one is historical.
+ // This method creates a Zip Archive. The Zip file is created in the
+ // filesystem. The files and directories indicated in $p_filelist
+ // are added in the archive. See the parameters description for the
+ // supported format of $p_filelist.
+ // When a directory is in the list, the directory and its content is added
+ // in the archive.
+ // In this synopsis, the function takes an optional variable list of
+ // options. See bellow the supported options.
+ // Parameters :
+ // $p_filelist : An array containing file or directory names, or
+ // a string containing one filename or one directory name, or
+ // a string containing a list of filenames and/or directory
+ // names separated by spaces.
+ // $p_add_dir : A path to add before the real path of the archived file,
+ // in order to have it memorized in the archive.
+ // $p_remove_dir : A path to remove from the real path of the file to archive,
+ // in order to have a shorter path memorized in the archive.
+ // When $p_add_dir and $p_remove_dir are set, $p_remove_dir
+ // is removed first, before $p_add_dir is added.
+ // Options :
+ // PCLZIP_OPT_ADD_PATH :
+ // PCLZIP_OPT_REMOVE_PATH :
+ // PCLZIP_OPT_REMOVE_ALL_PATH :
+ // PCLZIP_OPT_COMMENT :
+ // PCLZIP_CB_PRE_ADD :
+ // PCLZIP_CB_POST_ADD :
+ // Return Values :
+ // 0 on failure,
+ // The list of the added files, with a status of the add action.
+ // (see PclZip::listContent() for list entry format)
+ // --------------------------------------------------------------------------------
+ public function create($p_filelist)
{
-
- // ----- Duplicate the archive
- $v_result = $this->privDuplicate($p_archive->zipname);
- }
-
- // ----- Look if the $p_archive is a string (so a filename)
- else if (is_string($p_archive))
- {
-
- // ----- Check that $p_archive is a valid zip file
- // TBC : Should also check the archive format
- if (!is_file($p_archive)) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
- $v_result = PCLZIP_ERR_MISSING_FILE;
- }
- else {
- // ----- Duplicate the archive
- $v_result = $this->privDuplicate($p_archive);
- }
- }
-
- // ----- Invalid variable
- else
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
- $v_result = PCLZIP_ERR_INVALID_PARAMETER;
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : merge()
- // Description :
- // This method merge the $p_archive_to_add archive at the end of the current
- // one ($this).
- // If the archive ($this) does not exist, the merge becomes a duplicate.
- // If the $p_archive_to_add archive does not exist, the merge is a success.
- // Parameters :
- // $p_archive_to_add : It can be directly the filename of a valid zip archive,
- // or a PclZip object archive.
- // Return Values :
- // 1 on success,
- // 0 or negative values on error (see below).
- // --------------------------------------------------------------------------------
- function merge($p_archive_to_add)
- {
- $v_result = 1;
-
- // ----- Reset the error handler
- $this->privErrorReset();
-
- // ----- Check archive
- if (!$this->privCheckFormat()) {
- return(0);
- }
-
- // ----- Look if the $p_archive_to_add is a PclZip object
- if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
- {
-
- // ----- Merge the archive
- $v_result = $this->privMerge($p_archive_to_add);
- }
-
- // ----- Look if the $p_archive_to_add is a string (so a filename)
- else if (is_string($p_archive_to_add))
- {
-
- // ----- Create a temporary archive
- $v_object_archive = new PclZip($p_archive_to_add);
-
- // ----- Merge the archive
- $v_result = $this->privMerge($v_object_archive);
- }
-
- // ----- Invalid variable
- else
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
- $v_result = PCLZIP_ERR_INVALID_PARAMETER;
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
-
-
- // --------------------------------------------------------------------------------
- // Function : errorCode()
- // Description :
- // Parameters :
- // --------------------------------------------------------------------------------
- function errorCode()
- {
- if (PCLZIP_ERROR_EXTERNAL == 1) {
- return(PclErrorCode());
- }
- else {
- return($this->error_code);
- }
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : errorName()
- // Description :
- // Parameters :
- // --------------------------------------------------------------------------------
- function errorName($p_with_code=false)
- {
- $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
- PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
- PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
- PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
- PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
- PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
- PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
- PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
- PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
- PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
- PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
- PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
- PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
- PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
- PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
- PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
- PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
- PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
- PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
- ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
- ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
- );
-
- if (isset($v_name[$this->error_code])) {
- $v_value = $v_name[$this->error_code];
- }
- else {
- $v_value = 'NoName';
- }
-
- if ($p_with_code) {
- return($v_value.' ('.$this->error_code.')');
- }
- else {
- return($v_value);
- }
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : errorInfo()
- // Description :
- // Parameters :
- // --------------------------------------------------------------------------------
- function errorInfo($p_full=false)
- {
- if (PCLZIP_ERROR_EXTERNAL == 1) {
- return(PclErrorString());
- }
- else {
- if ($p_full) {
- return($this->errorName(true)." : ".$this->error_string);
- }
- else {
- return($this->error_string." [code ".$this->error_code."]");
- }
- }
- }
- // --------------------------------------------------------------------------------
-
-
-// --------------------------------------------------------------------------------
-// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
-// ***** *****
-// ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY *****
-// --------------------------------------------------------------------------------
-
-
-
- // --------------------------------------------------------------------------------
- // Function : privCheckFormat()
- // Description :
- // This method check that the archive exists and is a valid zip archive.
- // Several level of check exists. (futur)
- // Parameters :
- // $p_level : Level of check. Default 0.
- // 0 : Check the first bytes (magic codes) (default value))
- // 1 : 0 + Check the central directory (futur)
- // 2 : 1 + Check each file header (futur)
- // Return Values :
- // true on success,
- // false on error, the error code is set.
- // --------------------------------------------------------------------------------
- function privCheckFormat($p_level=0)
- {
- $v_result = true;
-
- // ----- Reset the file system cache
- clearstatcache();
-
- // ----- Reset the error handler
- $this->privErrorReset();
-
- // ----- Look if the file exits
- if (!is_file($this->zipname)) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
- return(false);
- }
-
- // ----- Check that the file is readeable
- if (!is_readable($this->zipname)) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
- return(false);
- }
-
- // ----- Check the magic code
- // TBC
-
- // ----- Check the central header
- // TBC
-
- // ----- Check each file header
- // TBC
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privParseOptions()
- // Description :
- // This internal methods reads the variable list of arguments ($p_options_list,
- // $p_size) and generate an array with the options and values ($v_result_list).
- // $v_requested_options contains the options that can be present and those that
- // must be present.
- // $v_requested_options is an array, with the option value as key, and 'optional',
- // or 'mandatory' as value.
- // Parameters :
- // See above.
- // Return Values :
- // 1 on success.
- // 0 on failure.
- // --------------------------------------------------------------------------------
- function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
- {
- $v_result=1;
-
- // ----- Read the options
- $i=0;
- while ($i<$p_size) {
-
- // ----- Check if the option is supported
- if (!isset($v_requested_options[$p_options_list[$i]])) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Look for next option
- switch ($p_options_list[$i]) {
- // ----- Look for options that request a path value
- case PCLZIP_OPT_PATH :
- case PCLZIP_OPT_REMOVE_PATH :
- case PCLZIP_OPT_ADD_PATH :
- // ----- Check the number of parameters
- if (($i+1) >= $p_size) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Get the value
- $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
- $i++;
- break;
-
- case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
- // ----- Check the number of parameters
- if (($i+1) >= $p_size) {
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
- return PclZip::errorCode();
- }
-
- // ----- Check for incompatible options
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
- return PclZip::errorCode();
- }
-
- // ----- Check the value
- $v_value = $p_options_list[$i+1];
- if ((!is_integer($v_value)) || ($v_value<0)) {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
- return PclZip::errorCode();
- }
-
- // ----- Get the value (and convert it in bytes)
- $v_result_list[$p_options_list[$i]] = $v_value*1048576;
- $i++;
- break;
-
- case PCLZIP_OPT_TEMP_FILE_ON :
- // ----- Check for incompatible options
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
- return PclZip::errorCode();
- }
-
- $v_result_list[$p_options_list[$i]] = true;
- break;
-
- case PCLZIP_OPT_TEMP_FILE_OFF :
- // ----- Check for incompatible options
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
- return PclZip::errorCode();
- }
- // ----- Check for incompatible options
- if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
- return PclZip::errorCode();
- }
-
- $v_result_list[$p_options_list[$i]] = true;
- break;
-
- case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
- // ----- Check the number of parameters
- if (($i+1) >= $p_size) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Get the value
- if ( is_string($p_options_list[$i+1])
- && ($p_options_list[$i+1] != '')) {
- $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
- $i++;
- }
- else {
- }
- break;
-
- // ----- Look for options that request an array of string for value
- case PCLZIP_OPT_BY_NAME :
- // ----- Check the number of parameters
- if (($i+1) >= $p_size) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Get the value
- if (is_string($p_options_list[$i+1])) {
- $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
- }
- else if (is_array($p_options_list[$i+1])) {
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
- }
- else {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
- $i++;
- break;
-
- // ----- Look for options that request an EREG or PREG expression
- case PCLZIP_OPT_BY_EREG :
- // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
- // to PCLZIP_OPT_BY_PREG
- $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
- case PCLZIP_OPT_BY_PREG :
- //case PCLZIP_OPT_CRYPT :
- // ----- Check the number of parameters
- if (($i+1) >= $p_size) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Get the value
- if (is_string($p_options_list[$i+1])) {
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
- }
- else {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
- $i++;
- break;
-
- // ----- Look for options that takes a string
- case PCLZIP_OPT_COMMENT :
- case PCLZIP_OPT_ADD_COMMENT :
- case PCLZIP_OPT_PREPEND_COMMENT :
- // ----- Check the number of parameters
- if (($i+1) >= $p_size) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
- "Missing parameter value for option '"
- .PclZipUtilOptionText($p_options_list[$i])
- ."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Get the value
- if (is_string($p_options_list[$i+1])) {
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
- }
- else {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
- "Wrong parameter value for option '"
- .PclZipUtilOptionText($p_options_list[$i])
- ."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
- $i++;
- break;
-
- // ----- Look for options that request an array of index
- case PCLZIP_OPT_BY_INDEX :
- // ----- Check the number of parameters
- if (($i+1) >= $p_size) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Get the value
- $v_work_list = array();
- if (is_string($p_options_list[$i+1])) {
-
- // ----- Remove spaces
- $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
-
- // ----- Parse items
- $v_work_list = explode(",", $p_options_list[$i+1]);
- }
- else if (is_integer($p_options_list[$i+1])) {
- $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
- }
- else if (is_array($p_options_list[$i+1])) {
- $v_work_list = $p_options_list[$i+1];
- }
- else {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Reduce the index list
- // each index item in the list must be a couple with a start and
- // an end value : [0,3], [5-5], [8-10], ...
- // ----- Check the format of each item
- $v_sort_flag=false;
- $v_sort_value=0;
- for ($j=0; $j= $p_size) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Get the value
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
- $i++;
- break;
-
- // ----- Look for options that request a call-back
- case PCLZIP_CB_PRE_EXTRACT :
- case PCLZIP_CB_POST_EXTRACT :
- case PCLZIP_CB_PRE_ADD :
- case PCLZIP_CB_POST_ADD :
- /* for futur use
- case PCLZIP_CB_PRE_DELETE :
- case PCLZIP_CB_POST_DELETE :
- case PCLZIP_CB_PRE_LIST :
- case PCLZIP_CB_POST_LIST :
- */
- // ----- Check the number of parameters
- if (($i+1) >= $p_size) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Get the value
- $v_function_name = $p_options_list[$i+1];
-
- // ----- Check that the value is a valid existing function
- if (!function_exists($v_function_name)) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Set the attribute
- $v_result_list[$p_options_list[$i]] = $v_function_name;
- $i++;
- break;
-
- default :
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
- "Unknown parameter '"
- .$p_options_list[$i]."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Next options
- $i++;
- }
-
- // ----- Look for mandatory options
- if ($v_requested_options !== false) {
- for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
- // ----- Look for mandatory option
- if ($v_requested_options[$key] == 'mandatory') {
- // ----- Look if present
- if (!isset($v_result_list[$key])) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
-
- // ----- Return
- return PclZip::errorCode();
- }
- }
- }
- }
-
- // ----- Look for default values
- if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
-
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privOptionDefaultThreshold()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privOptionDefaultThreshold(&$p_options)
- {
- $v_result=1;
-
- if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
- || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
- return $v_result;
- }
-
- // ----- Get 'memory_limit' configuration value
- $v_memory_limit = ini_get('memory_limit');
- $v_memory_limit = trim($v_memory_limit);
- $last = strtolower(substr($v_memory_limit, -1));
-
- if($last == 'g')
- //$v_memory_limit = $v_memory_limit*1024*1024*1024;
- $v_memory_limit = $v_memory_limit*1073741824;
- if($last == 'm')
- //$v_memory_limit = $v_memory_limit*1024*1024;
- $v_memory_limit = $v_memory_limit*1048576;
- if($last == 'k')
- $v_memory_limit = $v_memory_limit*1024;
-
- $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
-
-
- // ----- Sanity check : No threshold if value lower than 1M
- if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
- unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privFileDescrParseAtt()
- // Description :
- // Parameters :
- // Return Values :
- // 1 on success.
- // 0 on failure.
- // --------------------------------------------------------------------------------
- function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
- {
- $v_result=1;
-
- // ----- For each file in the list check the attributes
- foreach ($p_file_list as $v_key => $v_value) {
-
- // ----- Check if the option is supported
- if (!isset($v_requested_options[$v_key])) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Look for attribute
- switch ($v_key) {
- case PCLZIP_ATT_FILE_NAME :
- if (!is_string($v_value)) {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
- return PclZip::errorCode();
- }
-
- $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
-
- if ($p_filedescr['filename'] == '') {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
- return PclZip::errorCode();
- }
-
- break;
-
- case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
- if (!is_string($v_value)) {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
- return PclZip::errorCode();
- }
-
- $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
-
- if ($p_filedescr['new_short_name'] == '') {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
- return PclZip::errorCode();
- }
- break;
-
- case PCLZIP_ATT_FILE_NEW_FULL_NAME :
- if (!is_string($v_value)) {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
- return PclZip::errorCode();
- }
-
- $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
-
- if ($p_filedescr['new_full_name'] == '') {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
- return PclZip::errorCode();
- }
- break;
-
- // ----- Look for options that takes a string
- case PCLZIP_ATT_FILE_COMMENT :
- if (!is_string($v_value)) {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
- return PclZip::errorCode();
- }
-
- $p_filedescr['comment'] = $v_value;
- break;
-
- case PCLZIP_ATT_FILE_MTIME :
- if (!is_integer($v_value)) {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
- return PclZip::errorCode();
- }
-
- $p_filedescr['mtime'] = $v_value;
- break;
-
- case PCLZIP_ATT_FILE_CONTENT :
- $p_filedescr['content'] = $v_value;
- break;
-
- default :
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
- "Unknown parameter '".$v_key."'");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Look for mandatory options
- if ($v_requested_options !== false) {
- for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
- // ----- Look for mandatory option
- if ($v_requested_options[$key] == 'mandatory') {
- // ----- Look if present
- if (!isset($p_file_list[$key])) {
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
- return PclZip::errorCode();
- }
- }
- }
- }
-
- // end foreach
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privFileDescrExpand()
- // Description :
- // This method look for each item of the list to see if its a file, a folder
- // or a string to be added as file. For any other type of files (link, other)
- // just ignore the item.
- // Then prepare the information that will be stored for that file.
- // When its a folder, expand the folder with all the files that are in that
- // folder (recursively).
- // Parameters :
- // Return Values :
- // 1 on success.
- // 0 on failure.
- // --------------------------------------------------------------------------------
- function privFileDescrExpand(&$p_filedescr_list, &$p_options)
- {
- $v_result=1;
-
- // ----- Create a result list
- $v_result_list = array();
-
- // ----- Look each entry
- for ($i=0; $iprivCalculateStoredFilename($v_descr, $p_options);
-
- // ----- Add the descriptor in result list
- $v_result_list[sizeof($v_result_list)] = $v_descr;
-
- // ----- Look for folder
- if ($v_descr['type'] == 'folder') {
- // ----- List of items in folder
- $v_dirlist_descr = array();
- $v_dirlist_nb = 0;
- if ($v_folder_handler = @opendir($v_descr['filename'])) {
- while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
-
- // ----- Skip '.' and '..'
- if (($v_item_handler == '.') || ($v_item_handler == '..')) {
- continue;
- }
-
- // ----- Compose the full filename
- $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
-
- // ----- Look for different stored filename
- // Because the name of the folder was changed, the name of the
- // files/sub-folders also change
- if (($v_descr['stored_filename'] != $v_descr['filename'])
- && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
- if ($v_descr['stored_filename'] != '') {
- $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
- }
- else {
- $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
- }
- }
-
- $v_dirlist_nb++;
- }
-
- @closedir($v_folder_handler);
- }
- else {
- // TBC : unable to open folder in read mode
- }
-
- // ----- Expand each element of the list
- if ($v_dirlist_nb != 0) {
- // ----- Expand
- if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
- return $v_result;
- }
-
- // ----- Concat the resulting list
- $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
- }
- else {
- }
-
- // ----- Free local array
- unset($v_dirlist_descr);
- }
- }
-
- // ----- Get the result list
- $p_filedescr_list = $v_result_list;
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privCreate()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
- {
- $v_result=1;
- $v_list_detail = array();
-
- // ----- Magic quotes trick
- $this->privDisableMagicQuotes();
-
- // ----- Open the file in write mode
- if (($v_result = $this->privOpenFd('wb')) != 1)
- {
- // ----- Return
- return $v_result;
- }
-
- // ----- Add the list of files
- $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
-
- // ----- Close
- $this->privCloseFd();
-
- // ----- Magic quotes trick
- $this->privSwapBackMagicQuotes();
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privAdd()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
- {
- $v_result=1;
- $v_list_detail = array();
-
- // ----- Look if the archive exists or is empty
- if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
- {
-
- // ----- Do a create
- $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
-
- // ----- Return
- return $v_result;
- }
- // ----- Magic quotes trick
- $this->privDisableMagicQuotes();
-
- // ----- Open the zip file
- if (($v_result=$this->privOpenFd('rb')) != 1)
- {
- // ----- Magic quotes trick
- $this->privSwapBackMagicQuotes();
-
- // ----- Return
- return $v_result;
- }
-
- // ----- Read the central directory informations
- $v_central_dir = array();
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
- {
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
- return $v_result;
- }
-
- // ----- Go to beginning of File
- @rewind($this->zip_fd);
-
- // ----- Creates a temporay file
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
-
- // ----- Open the temporary file in write mode
- if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
- {
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
-
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Copy the files from the archive to the temporary file
- // TBC : Here I should better append the file and go back to erase the central dir
- $v_size = $v_central_dir['offset'];
- while ($v_size != 0)
- {
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = fread($this->zip_fd, $v_read_size);
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
- $v_size -= $v_read_size;
- }
-
- // ----- Swap the file descriptor
- // Here is a trick : I swap the temporary fd with the zip fd, in order to use
- // the following methods on the temporary fil and not the real archive
- $v_swap = $this->zip_fd;
- $this->zip_fd = $v_zip_temp_fd;
- $v_zip_temp_fd = $v_swap;
-
- // ----- Add the files
- $v_header_list = array();
- if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
- {
- fclose($v_zip_temp_fd);
- $this->privCloseFd();
- @unlink($v_zip_temp_name);
- $this->privSwapBackMagicQuotes();
-
- // ----- Return
- return $v_result;
- }
-
- // ----- Store the offset of the central dir
- $v_offset = @ftell($this->zip_fd);
-
- // ----- Copy the block of file headers from the old archive
- $v_size = $v_central_dir['size'];
- while ($v_size != 0)
- {
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
- @fwrite($this->zip_fd, $v_buffer, $v_read_size);
- $v_size -= $v_read_size;
- }
-
- // ----- Create the Central Dir files header
- for ($i=0, $v_count=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) {
- fclose($v_zip_temp_fd);
- $this->privCloseFd();
- @unlink($v_zip_temp_name);
- $this->privSwapBackMagicQuotes();
-
- // ----- Return
- return $v_result;
- }
- $v_count++;
- }
-
- // ----- Transform the header to a 'usable' info
- $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
- }
-
- // ----- Zip file comment
- $v_comment = $v_central_dir['comment'];
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
- }
- if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
- $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
- }
- if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
- $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
- }
-
- // ----- Calculate the size of the central header
- $v_size = @ftell($this->zip_fd)-$v_offset;
-
- // ----- Create the central dir footer
- if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
- {
- // ----- Reset the file list
- unset($v_header_list);
- $this->privSwapBackMagicQuotes();
-
- // ----- Return
- return $v_result;
- }
-
- // ----- Swap back the file descriptor
- $v_swap = $this->zip_fd;
- $this->zip_fd = $v_zip_temp_fd;
- $v_zip_temp_fd = $v_swap;
-
- // ----- Close
- $this->privCloseFd();
-
- // ----- Close the temporary file
- @fclose($v_zip_temp_fd);
-
- // ----- Magic quotes trick
- $this->privSwapBackMagicQuotes();
-
- // ----- Delete the zip file
- // TBC : I should test the result ...
- @unlink($this->zipname);
-
- // ----- Rename the temporary file
- // TBC : I should test the result ...
- //@rename($v_zip_temp_name, $this->zipname);
- PclZipUtilRename($v_zip_temp_name, $this->zipname);
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privOpenFd()
- // Description :
- // Parameters :
- // --------------------------------------------------------------------------------
- function privOpenFd($p_mode)
- {
- $v_result=1;
-
- // ----- Look if already open
- if ($this->zip_fd != 0)
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Open the zip file
- if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privCloseFd()
- // Description :
- // Parameters :
- // --------------------------------------------------------------------------------
- function privCloseFd()
- {
- $v_result=1;
-
- if ($this->zip_fd != 0)
- @fclose($this->zip_fd);
- $this->zip_fd = 0;
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privAddList()
- // Description :
- // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
- // different from the real path of the file. This is usefull if you want to have PclTar
- // running in any directory, and memorize relative path from an other directory.
- // Parameters :
- // $p_list : An array containing the file or directory names to add in the tar
- // $p_result_list : list of added files with their properties (specially the status field)
- // $p_add_dir : Path to add in the filename path archived
- // $p_remove_dir : Path to remove in the filename path archived
- // Return Values :
- // --------------------------------------------------------------------------------
-// function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
- function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
- {
- $v_result=1;
-
- // ----- Add the files
- $v_header_list = array();
- if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
- {
- // ----- Return
- return $v_result;
- }
-
- // ----- Store the offset of the central dir
- $v_offset = @ftell($this->zip_fd);
-
- // ----- Create the Central Dir files header
- for ($i=0,$v_count=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) {
- // ----- Return
- return $v_result;
- }
- $v_count++;
- }
-
- // ----- Transform the header to a 'usable' info
- $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
- }
-
- // ----- Zip file comment
- $v_comment = '';
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
- }
-
- // ----- Calculate the size of the central header
- $v_size = @ftell($this->zip_fd)-$v_offset;
-
- // ----- Create the central dir footer
- if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
- {
- // ----- Reset the file list
- unset($v_header_list);
-
- // ----- Return
- return $v_result;
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privAddFileList()
- // Description :
- // Parameters :
- // $p_filedescr_list : An array containing the file description
- // or directory names to add in the zip
- // $p_result_list : list of added files with their properties (specially the status field)
- // Return Values :
- // --------------------------------------------------------------------------------
- function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
- {
- $v_result=1;
- $v_header = array();
-
- // ----- Recuperate the current number of elt in list
- $v_nb = sizeof($p_result_list);
-
- // ----- Loop on the files
- for ($j=0; ($jprivAddFile($p_filedescr_list[$j], $v_header,
- $p_options);
- if ($v_result != 1) {
- return $v_result;
- }
-
- // ----- Store the file infos
- $p_result_list[$v_nb++] = $v_header;
- }
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privAddFile()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privAddFile($p_filedescr, &$p_header, &$p_options)
- {
- $v_result=1;
-
- // ----- Working variable
- $p_filename = $p_filedescr['filename'];
-
- // TBC : Already done in the fileAtt check ... ?
- if ($p_filename == "") {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Look for a stored different filename
- /* TBC : Removed
- if (isset($p_filedescr['stored_filename'])) {
- $v_stored_filename = $p_filedescr['stored_filename'];
- }
- else {
- $v_stored_filename = $p_filedescr['stored_filename'];
- }
- */
-
- // ----- Set the file properties
- clearstatcache();
- $p_header['version'] = 20;
- $p_header['version_extracted'] = 10;
- $p_header['flag'] = 0;
- $p_header['compression'] = 0;
- $p_header['crc'] = 0;
- $p_header['compressed_size'] = 0;
- $p_header['filename_len'] = strlen($p_filename);
- $p_header['extra_len'] = 0;
- $p_header['disk'] = 0;
- $p_header['internal'] = 0;
- $p_header['offset'] = 0;
- $p_header['filename'] = $p_filename;
-// TBC : Removed $p_header['stored_filename'] = $v_stored_filename;
- $p_header['stored_filename'] = $p_filedescr['stored_filename'];
- $p_header['extra'] = '';
- $p_header['status'] = 'ok';
- $p_header['index'] = -1;
-
- // ----- Look for regular file
- if ($p_filedescr['type']=='file') {
- $p_header['external'] = 0x00000000;
- $p_header['size'] = filesize($p_filename);
- }
-
- // ----- Look for regular folder
- else if ($p_filedescr['type']=='folder') {
- $p_header['external'] = 0x00000010;
- $p_header['mtime'] = filemtime($p_filename);
- $p_header['size'] = filesize($p_filename);
- }
-
- // ----- Look for virtual file
- else if ($p_filedescr['type'] == 'virtual_file') {
- $p_header['external'] = 0x00000000;
- $p_header['size'] = strlen($p_filedescr['content']);
- }
-
-
- // ----- Look for filetime
- if (isset($p_filedescr['mtime'])) {
- $p_header['mtime'] = $p_filedescr['mtime'];
- }
- else if ($p_filedescr['type'] == 'virtual_file') {
- $p_header['mtime'] = time();
- }
- else {
- $p_header['mtime'] = filemtime($p_filename);
- }
-
- // ------ Look for file comment
- if (isset($p_filedescr['comment'])) {
- $p_header['comment_len'] = strlen($p_filedescr['comment']);
- $p_header['comment'] = $p_filedescr['comment'];
- }
- else {
- $p_header['comment_len'] = 0;
- $p_header['comment'] = '';
- }
-
- // ----- Look for pre-add callback
- if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
-
- // ----- Generate a local information
- $v_local_header = array();
- $this->privConvertHeader2FileInfo($p_header, $v_local_header);
-
- // ----- Call the callback
- // Here I do not use call_user_func() because I need to send a reference to the
- // header.
-// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
- $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
- if ($v_result == 0) {
- // ----- Change the file status
- $p_header['status'] = "skipped";
$v_result = 1;
- }
- // ----- Update the informations
- // Only some fields can be modified
- if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
- $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
- }
- }
+ // ----- Reset the error handler
+ $this->privErrorReset();
- // ----- Look for empty stored filename
- if ($p_header['stored_filename'] == "") {
- $p_header['status'] = "filtered";
- }
+ // ----- Set default values
+ $v_options = array();
+ $v_options[PCLZIP_OPT_NO_COMPRESSION] = false;
- // ----- Check the path length
- if (strlen($p_header['stored_filename']) > 0xFF) {
- $p_header['status'] = 'filename_too_long';
- }
+ // ----- Look for variable options arguments
+ $v_size = func_num_args();
- // ----- Look if no error, or file not skipped
- if ($p_header['status'] == 'ok') {
+ // ----- Look for arguments
+ if ($v_size > 1) {
+ // ----- Get the arguments
+ $v_arg_list = func_get_args();
- // ----- Look for a file
- if ($p_filedescr['type'] == 'file') {
- // ----- Look for using temporary file to zip
- if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
- && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
- || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
- && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
- $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
- if ($v_result < PCLZIP_ERR_NO_ERROR) {
- return $v_result;
- }
+ // ----- Remove from the options list the first argument
+ array_shift($v_arg_list);
+ $v_size--;
+
+ // ----- Look for first arg
+ if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
+
+ // ----- Parse the options
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(
+ PCLZIP_OPT_REMOVE_PATH => 'optional',
+ PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
+ PCLZIP_OPT_ADD_PATH => 'optional',
+ PCLZIP_CB_PRE_ADD => 'optional',
+ PCLZIP_CB_POST_ADD => 'optional',
+ PCLZIP_OPT_NO_COMPRESSION => 'optional',
+ PCLZIP_OPT_COMMENT => 'optional',
+ PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
+ PCLZIP_OPT_TEMP_FILE_ON => 'optional',
+ PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
+ //, PCLZIP_OPT_CRYPT => 'optional'
+ ));
+ if ($v_result != 1) {
+ return 0;
+ }
+
+ // ----- Look for 2 args
+ // Here we need to support the first historic synopsis of the
+ // method.
+ } else {
+
+ // ----- Get the first argument
+ $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
+
+ // ----- Look for the optional second argument
+ if ($v_size == 2) {
+ $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
+ } elseif ($v_size > 2) {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
+
+ return 0;
+ }
+ }
}
- // ----- Use "in memory" zip algo
- else {
+ // ----- Look for default option values
+ $this->privOptionDefaultThreshold($v_options);
- // ----- Open the source file
- if (($v_file = @fopen($p_filename, "rb")) == 0) {
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
- return PclZip::errorCode();
+ // ----- Init
+ $v_string_list = array();
+ $v_att_list = array();
+ $v_filedescr_list = array();
+ $p_result_list = array();
+
+ // ----- Look if the $p_filelist is really an array
+ if (is_array($p_filelist)) {
+
+ // ----- Look if the first element is also an array
+ // This will mean that this is a file description entry
+ if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
+ $v_att_list = $p_filelist;
+
+ // ----- The list is a list of string names
+ } else {
+ $v_string_list = $p_filelist;
+ }
+
+ // ----- Look if the $p_filelist is a string
+ } elseif (is_string($p_filelist)) {
+ // ----- Create a list from the string
+ $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
+
+ // ----- Invalid variable type for $p_filelist
+ } else {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
+
+ return 0;
}
- // ----- Read the file content
- $v_content = @fread($v_file, $p_header['size']);
-
- // ----- Close the file
- @fclose($v_file);
-
- // ----- Calculate the CRC
- $p_header['crc'] = @crc32($v_content);
-
- // ----- Look for no compression
- if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
- // ----- Set header parameters
- $p_header['compressed_size'] = $p_header['size'];
- $p_header['compression'] = 0;
+ // ----- Reformat the string list
+ if (sizeof($v_string_list) != 0) {
+ foreach ($v_string_list as $v_string) {
+ if ($v_string != '') {
+ $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
+ } else {
+ }
+ }
}
- // ----- Look for normal compression
- else {
- // ----- Compress the content
- $v_content = @gzdeflate($v_content);
-
- // ----- Set header parameters
- $p_header['compressed_size'] = strlen($v_content);
- $p_header['compression'] = 8;
+ // ----- For each file in the list check the attributes
+ $v_supported_attributes = array(
+ PCLZIP_ATT_FILE_NAME => 'mandatory',
+ PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional',
+ PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional',
+ PCLZIP_ATT_FILE_MTIME => 'optional',
+ PCLZIP_ATT_FILE_CONTENT => 'optional',
+ PCLZIP_ATT_FILE_COMMENT => 'optional'
+ );
+ foreach ($v_att_list as $v_entry) {
+ $v_result = $this->privFileDescrParseAtt($v_entry, $v_filedescr_list[], $v_options, $v_supported_attributes);
+ if ($v_result != 1) {
+ return 0;
+ }
}
- // ----- Call the header generation
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
- @fclose($v_file);
- return $v_result;
+ // ----- Expand the filelist (expand directories)
+ $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
+ if ($v_result != 1) {
+ return 0;
}
- // ----- Write the compressed (or not) content
- @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
-
+ // ----- Call the create fct
+ $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
+ if ($v_result != 1) {
+ return 0;
}
- }
-
- // ----- Look for a virtual file (a file from string)
- else if ($p_filedescr['type'] == 'virtual_file') {
-
- $v_content = $p_filedescr['content'];
-
- // ----- Calculate the CRC
- $p_header['crc'] = @crc32($v_content);
-
- // ----- Look for no compression
- if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
- // ----- Set header parameters
- $p_header['compressed_size'] = $p_header['size'];
- $p_header['compression'] = 0;
- }
-
- // ----- Look for normal compression
- else {
- // ----- Compress the content
- $v_content = @gzdeflate($v_content);
-
- // ----- Set header parameters
- $p_header['compressed_size'] = strlen($v_content);
- $p_header['compression'] = 8;
- }
-
- // ----- Call the header generation
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
- @fclose($v_file);
- return $v_result;
- }
-
- // ----- Write the compressed (or not) content
- @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
- }
-
- // ----- Look for a directory
- else if ($p_filedescr['type'] == 'folder') {
- // ----- Look for directory last '/'
- if (@substr($p_header['stored_filename'], -1) != '/') {
- $p_header['stored_filename'] .= '/';
- }
-
- // ----- Set the file properties
- $p_header['size'] = 0;
- //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked
- $p_header['external'] = 0x00000010; // Value for a folder : to be checked
-
- // ----- Call the header generation
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
- {
- return $v_result;
- }
- }
- }
-
- // ----- Look for post-add callback
- if (isset($p_options[PCLZIP_CB_POST_ADD])) {
-
- // ----- Generate a local information
- $v_local_header = array();
- $this->privConvertHeader2FileInfo($p_header, $v_local_header);
-
- // ----- Call the callback
- // Here I do not use call_user_func() because I need to send a reference to the
- // header.
-// eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
- $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
- if ($v_result == 0) {
- // ----- Ignored
- $v_result = 1;
- }
-
- // ----- Update the informations
- // Nothing can be modified
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privAddFileUsingTempFile()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
- {
- $v_result=PCLZIP_ERR_NO_ERROR;
-
- // ----- Working variable
- $p_filename = $p_filedescr['filename'];
-
-
- // ----- Open the source file
- if (($v_file = @fopen($p_filename, "rb")) == 0) {
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
- return PclZip::errorCode();
- }
-
- // ----- Creates a compressed temporary file
- $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
- if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
- fclose($v_file);
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
- return PclZip::errorCode();
- }
-
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
- $v_size = filesize($p_filename);
- while ($v_size != 0) {
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = @fread($v_file, $v_read_size);
- //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
- @gzputs($v_file_compressed, $v_buffer, $v_read_size);
- $v_size -= $v_read_size;
- }
-
- // ----- Close the file
- @fclose($v_file);
- @gzclose($v_file_compressed);
-
- // ----- Check the minimum file size
- if (filesize($v_gzip_temp_name) < 18) {
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
- return PclZip::errorCode();
- }
-
- // ----- Extract the compressed attributes
- if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
- return PclZip::errorCode();
- }
-
- // ----- Read the gzip file header
- $v_binary_data = @fread($v_file_compressed, 10);
- $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
-
- // ----- Check some parameters
- $v_data_header['os'] = bin2hex($v_data_header['os']);
-
- // ----- Read the gzip file footer
- @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
- $v_binary_data = @fread($v_file_compressed, 8);
- $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
-
- // ----- Set the attributes
- $p_header['compression'] = ord($v_data_header['cm']);
- //$p_header['mtime'] = $v_data_header['mtime'];
- $p_header['crc'] = $v_data_footer['crc'];
- $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
-
- // ----- Close the file
- @fclose($v_file_compressed);
-
- // ----- Call the header generation
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
- return $v_result;
- }
-
- // ----- Add the compressed data
- if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
- {
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
- return PclZip::errorCode();
- }
-
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
- fseek($v_file_compressed, 10);
- $v_size = $p_header['compressed_size'];
- while ($v_size != 0)
- {
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = @fread($v_file_compressed, $v_read_size);
- //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
- @fwrite($this->zip_fd, $v_buffer, $v_read_size);
- $v_size -= $v_read_size;
- }
-
- // ----- Close the file
- @fclose($v_file_compressed);
-
- // ----- Unlink the temporary file
- @unlink($v_gzip_temp_name);
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privCalculateStoredFilename()
- // Description :
- // Based on file descriptor properties and global options, this method
- // calculate the filename that will be stored in the archive.
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privCalculateStoredFilename(&$p_filedescr, &$p_options)
- {
- $v_result=1;
-
- // ----- Working variables
- $p_filename = $p_filedescr['filename'];
- if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
- $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
- }
- else {
- $p_add_dir = '';
- }
- if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
- $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
- }
- else {
- $p_remove_dir = '';
- }
- if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
- $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
- }
- else {
- $p_remove_all_dir = 0;
- }
-
-
- // ----- Look for full name change
- if (isset($p_filedescr['new_full_name'])) {
- // ----- Remove drive letter if any
- $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
- }
-
- // ----- Look for path and/or short name change
- else {
-
- // ----- Look for short name change
- // Its when we cahnge just the filename but not the path
- if (isset($p_filedescr['new_short_name'])) {
- $v_path_info = pathinfo($p_filename);
- $v_dir = '';
- if ($v_path_info['dirname'] != '') {
- $v_dir = $v_path_info['dirname'].'/';
- }
- $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
- }
- else {
- // ----- Calculate the stored filename
- $v_stored_filename = $p_filename;
- }
-
- // ----- Look for all path to remove
- if ($p_remove_all_dir) {
- $v_stored_filename = basename($p_filename);
- }
- // ----- Look for partial path remove
- else if ($p_remove_dir != "") {
- if (substr($p_remove_dir, -1) != '/')
- $p_remove_dir .= "/";
-
- if ( (substr($p_filename, 0, 2) == "./")
- || (substr($p_remove_dir, 0, 2) == "./")) {
-
- if ( (substr($p_filename, 0, 2) == "./")
- && (substr($p_remove_dir, 0, 2) != "./")) {
- $p_remove_dir = "./".$p_remove_dir;
- }
- if ( (substr($p_filename, 0, 2) != "./")
- && (substr($p_remove_dir, 0, 2) == "./")) {
- $p_remove_dir = substr($p_remove_dir, 2);
- }
- }
-
- $v_compare = PclZipUtilPathInclusion($p_remove_dir,
- $v_stored_filename);
- if ($v_compare > 0) {
- if ($v_compare == 2) {
- $v_stored_filename = "";
- }
- else {
- $v_stored_filename = substr($v_stored_filename,
- strlen($p_remove_dir));
- }
- }
- }
-
- // ----- Remove drive letter if any
- $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
-
- // ----- Look for path to add
- if ($p_add_dir != "") {
- if (substr($p_add_dir, -1) == "/")
- $v_stored_filename = $p_add_dir.$v_stored_filename;
- else
- $v_stored_filename = $p_add_dir."/".$v_stored_filename;
- }
- }
-
- // ----- Filename (reduce the path of stored name)
- $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
- $p_filedescr['stored_filename'] = $v_stored_filename;
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privWriteFileHeader()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privWriteFileHeader(&$p_header)
- {
- $v_result=1;
-
- // ----- Store the offset position of the file
- $p_header['offset'] = ftell($this->zip_fd);
-
- // ----- Transform UNIX mtime to DOS format mdate/mtime
- $v_date = getdate($p_header['mtime']);
- $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
- $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
-
- // ----- Packed data
- $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
- $p_header['version_extracted'], $p_header['flag'],
- $p_header['compression'], $v_mtime, $v_mdate,
- $p_header['crc'], $p_header['compressed_size'],
- $p_header['size'],
- strlen($p_header['stored_filename']),
- $p_header['extra_len']);
-
- // ----- Write the first 148 bytes of the header in the archive
- fputs($this->zip_fd, $v_binary_data, 30);
-
- // ----- Write the variable fields
- if (strlen($p_header['stored_filename']) != 0)
- {
- fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
- }
- if ($p_header['extra_len'] != 0)
- {
- fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privWriteCentralFileHeader()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privWriteCentralFileHeader(&$p_header)
- {
- $v_result=1;
-
- // TBC
- //for(reset($p_header); $key = key($p_header); next($p_header)) {
- //}
-
- // ----- Transform UNIX mtime to DOS format mdate/mtime
- $v_date = getdate($p_header['mtime']);
- $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
- $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
-
-
- // ----- Packed data
- $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
- $p_header['version'], $p_header['version_extracted'],
- $p_header['flag'], $p_header['compression'],
- $v_mtime, $v_mdate, $p_header['crc'],
- $p_header['compressed_size'], $p_header['size'],
- strlen($p_header['stored_filename']),
- $p_header['extra_len'], $p_header['comment_len'],
- $p_header['disk'], $p_header['internal'],
- $p_header['external'], $p_header['offset']);
-
- // ----- Write the 42 bytes of the header in the zip file
- fputs($this->zip_fd, $v_binary_data, 46);
-
- // ----- Write the variable fields
- if (strlen($p_header['stored_filename']) != 0)
- {
- fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
- }
- if ($p_header['extra_len'] != 0)
- {
- fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
- }
- if ($p_header['comment_len'] != 0)
- {
- fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privWriteCentralHeader()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
- {
- $v_result=1;
-
- // ----- Packed data
- $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
- $p_nb_entries, $p_size,
- $p_offset, strlen($p_comment));
-
- // ----- Write the 22 bytes of the header in the zip file
- fputs($this->zip_fd, $v_binary_data, 22);
-
- // ----- Write the variable fields
- if (strlen($p_comment) != 0)
- {
- fputs($this->zip_fd, $p_comment, strlen($p_comment));
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privList()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privList(&$p_list)
- {
- $v_result=1;
-
- // ----- Magic quotes trick
- $this->privDisableMagicQuotes();
-
- // ----- Open the zip file
- if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
- {
- // ----- Magic quotes trick
- $this->privSwapBackMagicQuotes();
-
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Read the central directory informations
- $v_central_dir = array();
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
- {
- $this->privSwapBackMagicQuotes();
- return $v_result;
- }
-
- // ----- Go to beginning of Central Dir
- @rewind($this->zip_fd);
- if (@fseek($this->zip_fd, $v_central_dir['offset']))
- {
- $this->privSwapBackMagicQuotes();
-
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Read each entry
- for ($i=0; $i<$v_central_dir['entries']; $i++)
- {
- // ----- Read the file header
- if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
- {
- $this->privSwapBackMagicQuotes();
- return $v_result;
- }
- $v_header['index'] = $i;
-
- // ----- Get the only interesting attributes
- $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
- unset($v_header);
- }
-
- // ----- Close the zip file
- $this->privCloseFd();
-
- // ----- Magic quotes trick
- $this->privSwapBackMagicQuotes();
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privConvertHeader2FileInfo()
- // Description :
- // This function takes the file informations from the central directory
- // entries and extract the interesting parameters that will be given back.
- // The resulting file infos are set in the array $p_info
- // $p_info['filename'] : Filename with full path. Given by user (add),
- // extracted in the filesystem (extract).
- // $p_info['stored_filename'] : Stored filename in the archive.
- // $p_info['size'] = Size of the file.
- // $p_info['compressed_size'] = Compressed size of the file.
- // $p_info['mtime'] = Last modification date of the file.
- // $p_info['comment'] = Comment associated with the file.
- // $p_info['folder'] = true/false : indicates if the entry is a folder or not.
- // $p_info['status'] = status of the action on the file.
- // $p_info['crc'] = CRC of the file content.
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privConvertHeader2FileInfo($p_header, &$p_info)
- {
- $v_result=1;
-
- // ----- Get the interesting attributes
- $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
- $p_info['filename'] = $v_temp_path;
- $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
- $p_info['stored_filename'] = $v_temp_path;
- $p_info['size'] = $p_header['size'];
- $p_info['compressed_size'] = $p_header['compressed_size'];
- $p_info['mtime'] = $p_header['mtime'];
- $p_info['comment'] = $p_header['comment'];
- $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
- $p_info['index'] = $p_header['index'];
- $p_info['status'] = $p_header['status'];
- $p_info['crc'] = $p_header['crc'];
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privExtractByRule()
- // Description :
- // Extract a file or directory depending of rules (by index, by name, ...)
- // Parameters :
- // $p_file_list : An array where will be placed the properties of each
- // extracted file
- // $p_path : Path to add while writing the extracted files
- // $p_remove_path : Path to remove (from the file memorized path) while writing the
- // extracted files. If the path does not match the file path,
- // the file is extracted with its memorized path.
- // $p_remove_path does not apply to 'list' mode.
- // $p_path and $p_remove_path are commulative.
- // Return Values :
- // 1 on success,0 or less on error (see error code list)
- // --------------------------------------------------------------------------------
- function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
- {
- $v_result=1;
-
- // ----- Magic quotes trick
- $this->privDisableMagicQuotes();
-
- // ----- Check the path
- if ( ($p_path == "")
- || ( (substr($p_path, 0, 1) != "/")
- && (substr($p_path, 0, 3) != "../")
- && (substr($p_path,1,2)!=":/")))
- $p_path = "./".$p_path;
-
- // ----- Reduce the path last (and duplicated) '/'
- if (($p_path != "./") && ($p_path != "/"))
- {
- // ----- Look for the path end '/'
- while (substr($p_path, -1) == "/")
- {
- $p_path = substr($p_path, 0, strlen($p_path)-1);
- }
- }
-
- // ----- Look for path to remove format (should end by /)
- if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
- {
- $p_remove_path .= '/';
- }
- $p_remove_path_size = strlen($p_remove_path);
-
- // ----- Open the zip file
- if (($v_result = $this->privOpenFd('rb')) != 1)
- {
- $this->privSwapBackMagicQuotes();
- return $v_result;
- }
-
- // ----- Read the central directory informations
- $v_central_dir = array();
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
- {
- // ----- Close the zip file
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
-
- return $v_result;
- }
-
- // ----- Start at beginning of Central Dir
- $v_pos_entry = $v_central_dir['offset'];
-
- // ----- Read each entry
- $j_start = 0;
- for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
- {
-
- // ----- Read next Central dir entry
- @rewind($this->zip_fd);
- if (@fseek($this->zip_fd, $v_pos_entry))
- {
- // ----- Close the zip file
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
-
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
-
// ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Read the file header
- $v_header = array();
- if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
- {
- // ----- Close the zip file
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
-
- return $v_result;
- }
-
- // ----- Store the index
- $v_header['index'] = $i;
-
- // ----- Store the file position
- $v_pos_entry = ftell($this->zip_fd);
-
- // ----- Look for the specific extract rules
- $v_extract = false;
-
- // ----- Look for extract by name rule
- if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
- && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
-
- // ----- Look if the filename is in the list
- for ($j=0; ($j strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
- && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
- $v_extract = true;
- }
- }
- // ----- Look for a filename
- elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
- $v_extract = true;
- }
- }
- }
-
- // ----- Look for extract by ereg rule
- // ereg() is deprecated with PHP 5.3
- /*
- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
- && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
-
- if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
- $v_extract = true;
- }
- }
- */
-
- // ----- Look for extract by preg rule
- else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
- && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
-
- if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
- $v_extract = true;
- }
- }
-
- // ----- Look for extract by index rule
- else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
- && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
-
- // ----- Look if the index is in the list
- for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
- $v_extract = true;
- }
- if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
- $j_start = $j+1;
- }
-
- if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
- break;
- }
- }
- }
-
- // ----- Look for no rule, which means extract all the archive
- else {
- $v_extract = true;
- }
-
- // ----- Check compression method
- if ( ($v_extract)
- && ( ($v_header['compression'] != 8)
- && ($v_header['compression'] != 0))) {
- $v_header['status'] = 'unsupported_compression';
-
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
-
- $this->privSwapBackMagicQuotes();
-
- PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
- "Filename '".$v_header['stored_filename']."' is "
- ."compressed by an unsupported compression "
- ."method (".$v_header['compression'].") ");
-
- return PclZip::errorCode();
- }
- }
-
- // ----- Check encrypted files
- if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
- $v_header['status'] = 'unsupported_encryption';
-
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
-
- $this->privSwapBackMagicQuotes();
-
- PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
- "Unsupported encryption for "
- ." filename '".$v_header['stored_filename']
- ."'");
-
- return PclZip::errorCode();
- }
+ return $p_result_list;
}
+ // --------------------------------------------------------------------------------
- // ----- Look for real extraction
- if (($v_extract) && ($v_header['status'] != 'ok')) {
- $v_result = $this->privConvertHeader2FileInfo($v_header,
- $p_file_list[$v_nb_extracted++]);
- if ($v_result != 1) {
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
- return $v_result;
- }
-
- $v_extract = false;
- }
-
- // ----- Look for real extraction
- if ($v_extract)
- {
-
- // ----- Go to the file position
- @rewind($this->zip_fd);
- if (@fseek($this->zip_fd, $v_header['offset']))
- {
- // ----- Close the zip file
- $this->privCloseFd();
-
- $this->privSwapBackMagicQuotes();
-
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Look for extraction as string
- if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
-
- $v_string = '';
-
- // ----- Extracting the file
- $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
- if ($v_result1 < 1) {
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
- return $v_result1;
- }
-
- // ----- Get the only interesting attributes
- if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
- {
- // ----- Close the zip file
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
-
- return $v_result;
- }
-
- // ----- Set the file content
- $p_file_list[$v_nb_extracted]['content'] = $v_string;
-
- // ----- Next extracted file
- $v_nb_extracted++;
-
- // ----- Look for user callback abort
- if ($v_result1 == 2) {
- break;
- }
- }
- // ----- Look for extraction in standard output
- elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
- && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
- // ----- Extracting the file in standard output
- $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
- if ($v_result1 < 1) {
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
- return $v_result1;
- }
-
- // ----- Get the only interesting attributes
- if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
- return $v_result;
- }
-
- // ----- Look for user callback abort
- if ($v_result1 == 2) {
- break;
- }
- }
- // ----- Look for normal extraction
- else {
- // ----- Extracting the file
- $v_result1 = $this->privExtractFile($v_header,
- $p_path, $p_remove_path,
- $p_remove_all_path,
- $p_options);
- if ($v_result1 < 1) {
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
- return $v_result1;
- }
-
- // ----- Get the only interesting attributes
- if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
- {
- // ----- Close the zip file
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
-
- return $v_result;
- }
-
- // ----- Look for user callback abort
- if ($v_result1 == 2) {
- break;
- }
- }
- }
- }
-
- // ----- Close the zip file
- $this->privCloseFd();
- $this->privSwapBackMagicQuotes();
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privExtractFile()
- // Description :
- // Parameters :
- // Return Values :
- //
- // 1 : ... ?
- // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
- // --------------------------------------------------------------------------------
- function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
- {
- $v_result=1;
-
- // ----- Read the file header
- if (($v_result = $this->privReadFileHeader($v_header)) != 1)
+ // --------------------------------------------------------------------------------
+ // Function :
+ // add($p_filelist, $p_add_dir="", $p_remove_dir="")
+ // add($p_filelist, $p_option, $p_option_value, ...)
+ // Description :
+ // This method supports two synopsis. The first one is historical.
+ // This methods add the list of files in an existing archive.
+ // If a file with the same name already exists, it is added at the end of the
+ // archive, the first one is still present.
+ // If the archive does not exist, it is created.
+ // Parameters :
+ // $p_filelist : An array containing file or directory names, or
+ // a string containing one filename or one directory name, or
+ // a string containing a list of filenames and/or directory
+ // names separated by spaces.
+ // $p_add_dir : A path to add before the real path of the archived file,
+ // in order to have it memorized in the archive.
+ // $p_remove_dir : A path to remove from the real path of the file to archive,
+ // in order to have a shorter path memorized in the archive.
+ // When $p_add_dir and $p_remove_dir are set, $p_remove_dir
+ // is removed first, before $p_add_dir is added.
+ // Options :
+ // PCLZIP_OPT_ADD_PATH :
+ // PCLZIP_OPT_REMOVE_PATH :
+ // PCLZIP_OPT_REMOVE_ALL_PATH :
+ // PCLZIP_OPT_COMMENT :
+ // PCLZIP_OPT_ADD_COMMENT :
+ // PCLZIP_OPT_PREPEND_COMMENT :
+ // PCLZIP_CB_PRE_ADD :
+ // PCLZIP_CB_POST_ADD :
+ // Return Values :
+ // 0 on failure,
+ // The list of the added files, with a status of the add action.
+ // (see PclZip::listContent() for list entry format)
+ // --------------------------------------------------------------------------------
+ public function add($p_filelist)
{
- // ----- Return
- return $v_result;
- }
+ $v_result = 1;
+ // ----- Reset the error handler
+ $this->privErrorReset();
- // ----- Check that the file header is coherent with $p_entry info
- if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
- // TBC
- }
+ // ----- Set default values
+ $v_options = array();
+ $v_options[PCLZIP_OPT_NO_COMPRESSION] = false;
- // ----- Look for all path to remove
- if ($p_remove_all_path == true) {
- // ----- Look for folder entry that not need to be extracted
- if (($p_entry['external']&0x00000010)==0x00000010) {
+ // ----- Look for variable options arguments
+ $v_size = func_num_args();
- $p_entry['status'] = "filtered";
+ // ----- Look for arguments
+ if ($v_size > 1) {
+ // ----- Get the arguments
+ $v_arg_list = func_get_args();
- return $v_result;
+ // ----- Remove form the options list the first argument
+ array_shift($v_arg_list);
+ $v_size--;
+
+ // ----- Look for first arg
+ if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
+
+ // ----- Parse the options
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(
+ PCLZIP_OPT_REMOVE_PATH => 'optional',
+ PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
+ PCLZIP_OPT_ADD_PATH => 'optional',
+ PCLZIP_CB_PRE_ADD => 'optional',
+ PCLZIP_CB_POST_ADD => 'optional',
+ PCLZIP_OPT_NO_COMPRESSION => 'optional',
+ PCLZIP_OPT_COMMENT => 'optional',
+ PCLZIP_OPT_ADD_COMMENT => 'optional',
+ PCLZIP_OPT_PREPEND_COMMENT => 'optional',
+ PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
+ PCLZIP_OPT_TEMP_FILE_ON => 'optional',
+ PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
+ //, PCLZIP_OPT_CRYPT => 'optional'
+ ));
+ if ($v_result != 1) {
+ return 0;
+ }
+
+ // ----- Look for 2 args
+ // Here we need to support the first historic synopsis of the
+ // method.
+ } else {
+
+ // ----- Get the first argument
+ $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
+
+ // ----- Look for the optional second argument
+ if ($v_size == 2) {
+ $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
+ } elseif ($v_size > 2) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
+
+ // ----- Return
+ return 0;
+ }
+ }
}
- // ----- Get the basename of the path
- $p_entry['filename'] = basename($p_entry['filename']);
- }
+ // ----- Look for default option values
+ $this->privOptionDefaultThreshold($v_options);
- // ----- Look for path to remove
- else if ($p_remove_path != "")
- {
- if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
- {
+ // ----- Init
+ $v_string_list = array();
+ $v_att_list = array();
+ $v_filedescr_list = array();
+ $p_result_list = array();
- // ----- Change the file status
- $p_entry['status'] = "filtered";
+ // ----- Look if the $p_filelist is really an array
+ if (is_array($p_filelist)) {
+
+ // ----- Look if the first element is also an array
+ // This will mean that this is a file description entry
+ if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
+ $v_att_list = $p_filelist;
+
+ // ----- The list is a list of string names
+ } else {
+ $v_string_list = $p_filelist;
+ }
+
+ // ----- Look if the $p_filelist is a string
+ } elseif (is_string($p_filelist)) {
+ // ----- Create a list from the string
+ $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
+
+ // ----- Invalid variable type for $p_filelist
+ } else {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '" . gettype($p_filelist) . "' for p_filelist");
+
+ return 0;
+ }
+
+ // ----- Reformat the string list
+ if (sizeof($v_string_list) != 0) {
+ foreach ($v_string_list as $v_string) {
+ $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
+ }
+ }
+
+ // ----- For each file in the list check the attributes
+ $v_supported_attributes = array(
+ PCLZIP_ATT_FILE_NAME => 'mandatory',
+ PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional',
+ PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional',
+ PCLZIP_ATT_FILE_MTIME => 'optional',
+ PCLZIP_ATT_FILE_CONTENT => 'optional',
+ PCLZIP_ATT_FILE_COMMENT => 'optional'
+ );
+ foreach ($v_att_list as $v_entry) {
+ $v_result = $this->privFileDescrParseAtt($v_entry, $v_filedescr_list[], $v_options, $v_supported_attributes);
+ if ($v_result != 1) {
+ return 0;
+ }
+ }
+
+ // ----- Expand the filelist (expand directories)
+ $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
+ if ($v_result != 1) {
+ return 0;
+ }
+
+ // ----- Call the create fct
+ $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
+ if ($v_result != 1) {
+ return 0;
+ }
// ----- Return
- return $v_result;
- }
-
- $p_remove_path_size = strlen($p_remove_path);
- if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
- {
-
- // ----- Remove the path
- $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
-
- }
+ return $p_result_list;
}
+ // --------------------------------------------------------------------------------
- // ----- Add the path
- if ($p_path != '') {
- $p_entry['filename'] = $p_path."/".$p_entry['filename'];
- }
-
- // ----- Check a base_dir_restriction
- if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
- $v_inclusion
- = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
- $p_entry['filename']);
- if ($v_inclusion == 0) {
-
- PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
- "Filename '".$p_entry['filename']."' is "
- ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
-
- return PclZip::errorCode();
- }
- }
-
- // ----- Look for pre-extract callback
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
-
- // ----- Generate a local information
- $v_local_header = array();
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
-
- // ----- Call the callback
- // Here I do not use call_user_func() because I need to send a reference to the
- // header.
-// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
- $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
- if ($v_result == 0) {
- // ----- Change the file status
- $p_entry['status'] = "skipped";
- $v_result = 1;
- }
-
- // ----- Look for abort result
- if ($v_result == 2) {
- // ----- This status is internal and will be changed in 'skipped'
- $p_entry['status'] = "aborted";
- $v_result = PCLZIP_ERR_USER_ABORTED;
- }
-
- // ----- Update the informations
- // Only some fields can be modified
- $p_entry['filename'] = $v_local_header['filename'];
- }
-
-
- // ----- Look if extraction should be done
- if ($p_entry['status'] == 'ok') {
-
- // ----- Look for specific actions while the file exist
- if (file_exists($p_entry['filename']))
+ // --------------------------------------------------------------------------------
+ // Function : listContent()
+ // Description :
+ // This public method, gives the list of the files and directories, with their
+ // properties.
+ // The properties of each entries in the list are (used also in other functions) :
+ // filename : Name of the file. For a create or add action it is the filename
+ // given by the user. For an extract function it is the filename
+ // of the extracted file.
+ // stored_filename : Name of the file / directory stored in the archive.
+ // size : Size of the stored file.
+ // compressed_size : Size of the file's data compressed in the archive
+ // (without the headers overhead)
+ // mtime : Last known modification date of the file (UNIX timestamp)
+ // comment : Comment associated with the file
+ // folder : true | false
+ // index : index of the file in the archive
+ // status : status of the action (depending of the action) :
+ // Values are :
+ // ok : OK !
+ // filtered : the file / dir is not extracted (filtered by user)
+ // already_a_directory : the file can not be extracted because a
+ // directory with the same name already exists
+ // write_protected : the file can not be extracted because a file
+ // with the same name already exists and is
+ // write protected
+ // newer_exist : the file was not extracted because a newer file exists
+ // path_creation_fail : the file is not extracted because the folder
+ // does not exist and can not be created
+ // write_error : the file was not extracted because there was a
+ // error while writing the file
+ // read_error : the file was not extracted because there was a error
+ // while reading the file
+ // invalid_header : the file was not extracted because of an archive
+ // format error (bad file header)
+ // Note that each time a method can continue operating when there
+ // is an action error on a file, the error is only logged in the file status.
+ // Return Values :
+ // 0 on an unrecoverable failure,
+ // The list of the files in the archive.
+ // --------------------------------------------------------------------------------
+ public function listContent()
{
-
- // ----- Look if file is a directory
- if (is_dir($p_entry['filename']))
- {
-
- // ----- Change the file status
- $p_entry['status'] = "already_a_directory";
-
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
- // For historical reason first PclZip implementation does not stop
- // when this kind of error occurs.
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
-
- PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
- "Filename '".$p_entry['filename']."' is "
- ."already used by an existing directory");
-
- return PclZip::errorCode();
- }
- }
- // ----- Look if file is write protected
- else if (!is_writeable($p_entry['filename']))
- {
-
- // ----- Change the file status
- $p_entry['status'] = "write_protected";
-
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
- // For historical reason first PclZip implementation does not stop
- // when this kind of error occurs.
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
-
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
- "Filename '".$p_entry['filename']."' exists "
- ."and is write protected");
-
- return PclZip::errorCode();
- }
- }
-
- // ----- Look if the extracted file is older
- else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
- {
- // ----- Change the file status
- if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
- && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
- }
- else {
- $p_entry['status'] = "newer_exist";
-
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
- // For historical reason first PclZip implementation does not stop
- // when this kind of error occurs.
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
-
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
- "Newer version of '".$p_entry['filename']."' exists "
- ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
-
- return PclZip::errorCode();
- }
- }
- }
- else {
- }
- }
-
- // ----- Check the directory availability and create it if necessary
- else {
- if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
- $v_dir_to_check = $p_entry['filename'];
- else if (!strstr($p_entry['filename'], "/"))
- $v_dir_to_check = "";
- else
- $v_dir_to_check = dirname($p_entry['filename']);
-
- if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
-
- // ----- Change the file status
- $p_entry['status'] = "path_creation_fail";
-
- // ----- Return
- //return $v_result;
- $v_result = 1;
- }
- }
- }
-
- // ----- Look if extraction should be done
- if ($p_entry['status'] == 'ok') {
-
- // ----- Do the extraction (if not a folder)
- if (!(($p_entry['external']&0x00000010)==0x00000010))
- {
- // ----- Look for not compressed file
- if ($p_entry['compression'] == 0) {
-
- // ----- Opening destination file
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
- {
-
- // ----- Change the file status
- $p_entry['status'] = "write_error";
-
- // ----- Return
- return $v_result;
- }
-
-
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
- $v_size = $p_entry['compressed_size'];
- while ($v_size != 0)
- {
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = @fread($this->zip_fd, $v_read_size);
- /* Try to speed up the code
- $v_binary_data = pack('a'.$v_read_size, $v_buffer);
- @fwrite($v_dest_file, $v_binary_data, $v_read_size);
- */
- @fwrite($v_dest_file, $v_buffer, $v_read_size);
- $v_size -= $v_read_size;
- }
-
- // ----- Closing the destination file
- fclose($v_dest_file);
-
- // ----- Change the file mtime
- touch($p_entry['filename'], $p_entry['mtime']);
-
-
- }
- else {
- // ----- TBC
- // Need to be finished
- if (($p_entry['flag'] & 1) == 1) {
- PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
- return PclZip::errorCode();
- }
-
-
- // ----- Look for using temporary file to unzip
- if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
- && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
- || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
- && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
- $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
- if ($v_result < PCLZIP_ERR_NO_ERROR) {
- return $v_result;
- }
- }
-
- // ----- Look for extract in memory
- else {
-
-
- // ----- Read the compressed file in a buffer (one shot)
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
-
- // ----- Decompress the file
- $v_file_content = @gzinflate($v_buffer);
- unset($v_buffer);
- if ($v_file_content === FALSE) {
-
- // ----- Change the file status
- // TBC
- $p_entry['status'] = "error";
-
- return $v_result;
- }
-
- // ----- Opening destination file
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
-
- // ----- Change the file status
- $p_entry['status'] = "write_error";
-
- return $v_result;
- }
-
- // ----- Write the uncompressed data
- @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
- unset($v_file_content);
-
- // ----- Closing the destination file
- @fclose($v_dest_file);
-
- }
-
- // ----- Change the file mtime
- @touch($p_entry['filename'], $p_entry['mtime']);
- }
-
- // ----- Look for chmod option
- if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
-
- // ----- Change the mode of the file
- @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
- }
-
- }
- }
-
- // ----- Change abort status
- if ($p_entry['status'] == "aborted") {
- $p_entry['status'] = "skipped";
- }
-
- // ----- Look for post-extract callback
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
-
- // ----- Generate a local information
- $v_local_header = array();
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
-
- // ----- Call the callback
- // Here I do not use call_user_func() because I need to send a reference to the
- // header.
-// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
- $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
-
- // ----- Look for abort result
- if ($v_result == 2) {
- $v_result = PCLZIP_ERR_USER_ABORTED;
- }
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privExtractFileUsingTempFile()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privExtractFileUsingTempFile(&$p_entry, &$p_options)
- {
- $v_result=1;
-
- // ----- Creates a temporary file
- $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
- if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
- fclose($v_file);
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
- return PclZip::errorCode();
- }
-
-
- // ----- Write gz file format header
- $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
- @fwrite($v_dest_file, $v_binary_data, 10);
-
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
- $v_size = $p_entry['compressed_size'];
- while ($v_size != 0)
- {
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = @fread($this->zip_fd, $v_read_size);
- //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
- @fwrite($v_dest_file, $v_buffer, $v_read_size);
- $v_size -= $v_read_size;
- }
-
- // ----- Write gz file format footer
- $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
- @fwrite($v_dest_file, $v_binary_data, 8);
-
- // ----- Close the temporary file
- @fclose($v_dest_file);
-
- // ----- Opening destination file
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
- $p_entry['status'] = "write_error";
- return $v_result;
- }
-
- // ----- Open the temporary gz file
- if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
- @fclose($v_dest_file);
- $p_entry['status'] = "read_error";
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
- return PclZip::errorCode();
- }
-
-
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
- $v_size = $p_entry['size'];
- while ($v_size != 0) {
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = @gzread($v_src_file, $v_read_size);
- //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
- @fwrite($v_dest_file, $v_buffer, $v_read_size);
- $v_size -= $v_read_size;
- }
- @fclose($v_dest_file);
- @gzclose($v_src_file);
-
- // ----- Delete the temporary file
- @unlink($v_gzip_temp_name);
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privExtractFileInOutput()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privExtractFileInOutput(&$p_entry, &$p_options)
- {
- $v_result=1;
-
- // ----- Read the file header
- if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
- return $v_result;
- }
-
-
- // ----- Check that the file header is coherent with $p_entry info
- if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
- // TBC
- }
-
- // ----- Look for pre-extract callback
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
-
- // ----- Generate a local information
- $v_local_header = array();
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
-
- // ----- Call the callback
- // Here I do not use call_user_func() because I need to send a reference to the
- // header.
-// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
- $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
- if ($v_result == 0) {
- // ----- Change the file status
- $p_entry['status'] = "skipped";
$v_result = 1;
- }
- // ----- Look for abort result
- if ($v_result == 2) {
- // ----- This status is internal and will be changed in 'skipped'
- $p_entry['status'] = "aborted";
- $v_result = PCLZIP_ERR_USER_ABORTED;
- }
+ // ----- Reset the error handler
+ $this->privErrorReset();
- // ----- Update the informations
- // Only some fields can be modified
- $p_entry['filename'] = $v_local_header['filename'];
- }
-
- // ----- Trace
-
- // ----- Look if extraction should be done
- if ($p_entry['status'] == 'ok') {
-
- // ----- Do the extraction (if not a folder)
- if (!(($p_entry['external']&0x00000010)==0x00000010)) {
- // ----- Look for not compressed file
- if ($p_entry['compressed_size'] == $p_entry['size']) {
-
- // ----- Read the file in a buffer (one shot)
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
-
- // ----- Send the file to the output
- echo $v_buffer;
- unset($v_buffer);
+ // ----- Check archive
+ if (!$this->privCheckFormat()) {
+ return (0);
}
- else {
- // ----- Read the compressed file in a buffer (one shot)
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
+ // ----- Call the extracting fct
+ $p_list = array();
+ if (($v_result = $this->privList($p_list)) != 1) {
+ unset($p_list);
- // ----- Decompress the file
- $v_file_content = gzinflate($v_buffer);
- unset($v_buffer);
-
- // ----- Send the file to the output
- echo $v_file_content;
- unset($v_file_content);
+ return (0);
}
- }
+
+ // ----- Return
+ return $p_list;
}
+ // --------------------------------------------------------------------------------
- // ----- Change abort status
- if ($p_entry['status'] == "aborted") {
- $p_entry['status'] = "skipped";
- }
-
- // ----- Look for post-extract callback
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
-
- // ----- Generate a local information
- $v_local_header = array();
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
-
- // ----- Call the callback
- // Here I do not use call_user_func() because I need to send a reference to the
- // header.
-// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
- $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
-
- // ----- Look for abort result
- if ($v_result == 2) {
- $v_result = PCLZIP_ERR_USER_ABORTED;
- }
- }
-
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privExtractFileAsString()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
- {
- $v_result=1;
-
- // ----- Read the file header
- $v_header = array();
- if (($v_result = $this->privReadFileHeader($v_header)) != 1)
+ // --------------------------------------------------------------------------------
+ // Function :
+ // extract($p_path="./", $p_remove_path="")
+ // extract([$p_option, $p_option_value, ...])
+ // Description :
+ // This method supports two synopsis. The first one is historical.
+ // This method extract all the files / directories from the archive to the
+ // folder indicated in $p_path.
+ // If you want to ignore the 'root' part of path of the memorized files
+ // you can indicate this in the optional $p_remove_path parameter.
+ // By default, if a newer file with the same name already exists, the
+ // file is not extracted.
+ //
+ // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
+ // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
+ // at the end of the path value of PCLZIP_OPT_PATH.
+ // Parameters :
+ // $p_path : Path where the files and directories are to be extracted
+ // $p_remove_path : First part ('root' part) of the memorized path
+ // (if any similar) to remove while extracting.
+ // Options :
+ // PCLZIP_OPT_PATH :
+ // PCLZIP_OPT_ADD_PATH :
+ // PCLZIP_OPT_REMOVE_PATH :
+ // PCLZIP_OPT_REMOVE_ALL_PATH :
+ // PCLZIP_CB_PRE_EXTRACT :
+ // PCLZIP_CB_POST_EXTRACT :
+ // Return Values :
+ // 0 or a negative value on failure,
+ // The list of the extracted files, with a status of the action.
+ // (see PclZip::listContent() for list entry format)
+ // --------------------------------------------------------------------------------
+ public function extract()
{
- // ----- Return
- return $v_result;
- }
-
-
- // ----- Check that the file header is coherent with $p_entry info
- if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
- // TBC
- }
-
- // ----- Look for pre-extract callback
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
-
- // ----- Generate a local information
- $v_local_header = array();
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
-
- // ----- Call the callback
- // Here I do not use call_user_func() because I need to send a reference to the
- // header.
-// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
- $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
- if ($v_result == 0) {
- // ----- Change the file status
- $p_entry['status'] = "skipped";
$v_result = 1;
- }
- // ----- Look for abort result
- if ($v_result == 2) {
- // ----- This status is internal and will be changed in 'skipped'
- $p_entry['status'] = "aborted";
- $v_result = PCLZIP_ERR_USER_ABORTED;
- }
+ // ----- Reset the error handler
+ $this->privErrorReset();
- // ----- Update the informations
- // Only some fields can be modified
- $p_entry['filename'] = $v_local_header['filename'];
- }
-
-
- // ----- Look if extraction should be done
- if ($p_entry['status'] == 'ok') {
-
- // ----- Do the extraction (if not a folder)
- if (!(($p_entry['external']&0x00000010)==0x00000010)) {
- // ----- Look for not compressed file
- // if ($p_entry['compressed_size'] == $p_entry['size'])
- if ($p_entry['compression'] == 0) {
-
- // ----- Reading the file
- $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
+ // ----- Check archive
+ if (!$this->privCheckFormat()) {
+ return (0);
}
- else {
- // ----- Reading the file
- $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
+ // ----- Set default values
+ $v_options = array();
+ // $v_path = "./";
+ $v_path = '';
+ $v_remove_path = "";
+ $v_remove_all_path = false;
- // ----- Decompress the file
- if (($p_string = @gzinflate($v_data)) === FALSE) {
- // TBC
- }
+ // ----- Look for variable options arguments
+ $v_size = func_num_args();
+
+ // ----- Default values for option
+ $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = false;
+
+ // ----- Look for arguments
+ if ($v_size > 0) {
+ // ----- Get the arguments
+ $v_arg_list = func_get_args();
+
+ // ----- Look for first arg
+ if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
+
+ // ----- Parse the options
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(
+ PCLZIP_OPT_PATH => 'optional',
+ PCLZIP_OPT_REMOVE_PATH => 'optional',
+ PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
+ PCLZIP_OPT_ADD_PATH => 'optional',
+ PCLZIP_CB_PRE_EXTRACT => 'optional',
+ PCLZIP_CB_POST_EXTRACT => 'optional',
+ PCLZIP_OPT_SET_CHMOD => 'optional',
+ PCLZIP_OPT_BY_NAME => 'optional',
+ PCLZIP_OPT_BY_EREG => 'optional',
+ PCLZIP_OPT_BY_PREG => 'optional',
+ PCLZIP_OPT_BY_INDEX => 'optional',
+ PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
+ PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
+ PCLZIP_OPT_REPLACE_NEWER => 'optional',
+ PCLZIP_OPT_STOP_ON_ERROR => 'optional',
+ PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
+ PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
+ PCLZIP_OPT_TEMP_FILE_ON => 'optional',
+ PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
+ ));
+ if ($v_result != 1) {
+ return 0;
+ }
+
+ // ----- Set the arguments
+ if (isset($v_options[PCLZIP_OPT_PATH])) {
+ $v_path = $v_options[PCLZIP_OPT_PATH];
+ }
+ if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
+ $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
+ }
+ if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
+ $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
+ }
+ if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
+ // ----- Check for '/' in last path char
+ if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
+ $v_path .= '/';
+ }
+ $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
+ }
+
+ // ----- Look for 2 args
+ // Here we need to support the first historic synopsis of the
+ // method.
+ } else {
+
+ // ----- Get the first argument
+ $v_path = $v_arg_list[0];
+
+ // ----- Look for the optional second argument
+ if ($v_size == 2) {
+ $v_remove_path = $v_arg_list[1];
+ } elseif ($v_size > 2) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
+
+ // ----- Return
+ return 0;
+ }
+ }
+ }
+
+ // ----- Look for default option values
+ $this->privOptionDefaultThreshold($v_options);
+
+ // ----- Trace
+
+ // ----- Call the extracting fct
+ $p_list = array();
+ $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options);
+ if ($v_result < 1) {
+ unset($p_list);
+
+ return (0);
+ }
+
+ // ----- Return
+ return $p_list;
+ }
+ // --------------------------------------------------------------------------------
+
+
+ // --------------------------------------------------------------------------------
+ // Function :
+ // extractByIndex($p_index, $p_path="./", $p_remove_path="")
+ // extractByIndex($p_index, [$p_option, $p_option_value, ...])
+ // Description :
+ // This method supports two synopsis. The first one is historical.
+ // This method is doing a partial extract of the archive.
+ // The extracted files or folders are identified by their index in the
+ // archive (from 0 to n).
+ // Note that if the index identify a folder, only the folder entry is
+ // extracted, not all the files included in the archive.
+ // Parameters :
+ // $p_index : A single index (integer) or a string of indexes of files to
+ // extract. The form of the string is "0,4-6,8-12" with only numbers
+ // and '-' for range or ',' to separate ranges. No spaces or ';'
+ // are allowed.
+ // $p_path : Path where the files and directories are to be extracted
+ // $p_remove_path : First part ('root' part) of the memorized path
+ // (if any similar) to remove while extracting.
+ // Options :
+ // PCLZIP_OPT_PATH :
+ // PCLZIP_OPT_ADD_PATH :
+ // PCLZIP_OPT_REMOVE_PATH :
+ // PCLZIP_OPT_REMOVE_ALL_PATH :
+ // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
+ // not as files.
+ // The resulting content is in a new field 'content' in the file
+ // structure.
+ // This option must be used alone (any other options are ignored).
+ // PCLZIP_CB_PRE_EXTRACT :
+ // PCLZIP_CB_POST_EXTRACT :
+ // Return Values :
+ // 0 on failure,
+ // The list of the extracted files, with a status of the action.
+ // (see PclZip::listContent() for list entry format)
+ // --------------------------------------------------------------------------------
+ //function extractByIndex($p_index, options...)
+ public function extractByIndex($p_index)
+ {
+ $v_result = 1;
+
+ // ----- Reset the error handler
+ $this->privErrorReset();
+
+ // ----- Check archive
+ if (!$this->privCheckFormat()) {
+ return (0);
+ }
+
+ // ----- Set default values
+ $v_options = array();
+ // $v_path = "./";
+ $v_path = '';
+ $v_remove_path = "";
+ $v_remove_all_path = false;
+
+ // ----- Look for variable options arguments
+ $v_size = func_num_args();
+
+ // ----- Default values for option
+ $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = false;
+
+ // ----- Look for arguments
+ if ($v_size > 1) {
+ // ----- Get the arguments
+ $v_arg_list = func_get_args();
+
+ // ----- Remove form the options list the first argument
+ array_shift($v_arg_list);
+ $v_size--;
+
+ // ----- Look for first arg
+ if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
+
+ // ----- Parse the options
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(
+ PCLZIP_OPT_PATH => 'optional',
+ PCLZIP_OPT_REMOVE_PATH => 'optional',
+ PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
+ PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
+ PCLZIP_OPT_ADD_PATH => 'optional',
+ PCLZIP_CB_PRE_EXTRACT => 'optional',
+ PCLZIP_CB_POST_EXTRACT => 'optional',
+ PCLZIP_OPT_SET_CHMOD => 'optional',
+ PCLZIP_OPT_REPLACE_NEWER => 'optional',
+ PCLZIP_OPT_STOP_ON_ERROR => 'optional',
+ PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
+ PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
+ PCLZIP_OPT_TEMP_FILE_ON => 'optional',
+ PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
+ ));
+ if ($v_result != 1) {
+ return 0;
+ }
+
+ // ----- Set the arguments
+ if (isset($v_options[PCLZIP_OPT_PATH])) {
+ $v_path = $v_options[PCLZIP_OPT_PATH];
+ }
+ if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
+ $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
+ }
+ if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
+ $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
+ }
+ if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
+ // ----- Check for '/' in last path char
+ if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
+ $v_path .= '/';
+ }
+ $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
+ }
+ if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
+ $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = false;
+ } else {
+ }
+
+ // ----- Look for 2 args
+ // Here we need to support the first historic synopsis of the
+ // method.
+ } else {
+
+ // ----- Get the first argument
+ $v_path = $v_arg_list[0];
+
+ // ----- Look for the optional second argument
+ if ($v_size == 2) {
+ $v_remove_path = $v_arg_list[1];
+ } elseif ($v_size > 2) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
+
+ // ----- Return
+ return 0;
+ }
+ }
}
// ----- Trace
- }
- else {
- // TBC : error : can not extract a folder in a string
- }
- }
-
- // ----- Change abort status
- if ($p_entry['status'] == "aborted") {
- $p_entry['status'] = "skipped";
- }
-
- // ----- Look for post-extract callback
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
-
- // ----- Generate a local information
- $v_local_header = array();
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
-
- // ----- Swap the content to header
- $v_local_header['content'] = $p_string;
- $p_string = '';
-
- // ----- Call the callback
- // Here I do not use call_user_func() because I need to send a reference to the
- // header.
-// eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
- $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
-
- // ----- Swap back the content to header
- $p_string = $v_local_header['content'];
- unset($v_local_header['content']);
-
- // ----- Look for abort result
- if ($v_result == 2) {
- $v_result = PCLZIP_ERR_USER_ABORTED;
- }
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privReadFileHeader()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privReadFileHeader(&$p_header)
- {
- $v_result=1;
-
- // ----- Read the 4 bytes signature
- $v_binary_data = @fread($this->zip_fd, 4);
- $v_data = unpack('Vid', $v_binary_data);
-
- // ----- Check signature
- if ($v_data['id'] != 0x04034b50)
- {
-
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Read the first 42 bytes of the header
- $v_binary_data = fread($this->zip_fd, 26);
-
- // ----- Look for invalid block size
- if (strlen($v_binary_data) != 26)
- {
- $p_header['filename'] = "";
- $p_header['status'] = "invalid_header";
-
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Extract the values
- $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
-
- // ----- Get filename
- $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
-
- // ----- Get extra_fields
- if ($v_data['extra_len'] != 0) {
- $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
- }
- else {
- $p_header['extra'] = '';
- }
-
- // ----- Extract properties
- $p_header['version_extracted'] = $v_data['version'];
- $p_header['compression'] = $v_data['compression'];
- $p_header['size'] = $v_data['size'];
- $p_header['compressed_size'] = $v_data['compressed_size'];
- $p_header['crc'] = $v_data['crc'];
- $p_header['flag'] = $v_data['flag'];
- $p_header['filename_len'] = $v_data['filename_len'];
-
- // ----- Recuperate date in UNIX format
- $p_header['mdate'] = $v_data['mdate'];
- $p_header['mtime'] = $v_data['mtime'];
- if ($p_header['mdate'] && $p_header['mtime'])
- {
- // ----- Extract time
- $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
- $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
- $v_seconde = ($p_header['mtime'] & 0x001F)*2;
-
- // ----- Extract date
- $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
- $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
- $v_day = $p_header['mdate'] & 0x001F;
-
- // ----- Get UNIX date format
- $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
-
- }
- else
- {
- $p_header['mtime'] = time();
- }
-
- // TBC
- //for(reset($v_data); $key = key($v_data); next($v_data)) {
- //}
-
- // ----- Set the stored filename
- $p_header['stored_filename'] = $p_header['filename'];
-
- // ----- Set the status field
- $p_header['status'] = "ok";
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privReadCentralFileHeader()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privReadCentralFileHeader(&$p_header)
- {
- $v_result=1;
-
- // ----- Read the 4 bytes signature
- $v_binary_data = @fread($this->zip_fd, 4);
- $v_data = unpack('Vid', $v_binary_data);
-
- // ----- Check signature
- if ($v_data['id'] != 0x02014b50)
- {
-
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Read the first 42 bytes of the header
- $v_binary_data = fread($this->zip_fd, 42);
-
- // ----- Look for invalid block size
- if (strlen($v_binary_data) != 42)
- {
- $p_header['filename'] = "";
- $p_header['status'] = "invalid_header";
-
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Extract the values
- $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
-
- // ----- Get filename
- if ($p_header['filename_len'] != 0)
- $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
- else
- $p_header['filename'] = '';
-
- // ----- Get extra
- if ($p_header['extra_len'] != 0)
- $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
- else
- $p_header['extra'] = '';
-
- // ----- Get comment
- if ($p_header['comment_len'] != 0)
- $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
- else
- $p_header['comment'] = '';
-
- // ----- Extract properties
-
- // ----- Recuperate date in UNIX format
- //if ($p_header['mdate'] && $p_header['mtime'])
- // TBC : bug : this was ignoring time with 0/0/0
- if (1)
- {
- // ----- Extract time
- $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
- $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
- $v_seconde = ($p_header['mtime'] & 0x001F)*2;
-
- // ----- Extract date
- $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
- $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
- $v_day = $p_header['mdate'] & 0x001F;
-
- // ----- Get UNIX date format
- $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
-
- }
- else
- {
- $p_header['mtime'] = time();
- }
-
- // ----- Set the stored filename
- $p_header['stored_filename'] = $p_header['filename'];
-
- // ----- Set default status to ok
- $p_header['status'] = 'ok';
-
- // ----- Look if it is a directory
- if (substr($p_header['filename'], -1) == '/') {
- //$p_header['external'] = 0x41FF0010;
- $p_header['external'] = 0x00000010;
- }
-
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privCheckFileHeaders()
- // Description :
- // Parameters :
- // Return Values :
- // 1 on success,
- // 0 on error;
- // --------------------------------------------------------------------------------
- function privCheckFileHeaders(&$p_local_header, &$p_central_header)
- {
- $v_result=1;
-
- // ----- Check the static values
- // TBC
- if ($p_local_header['filename'] != $p_central_header['filename']) {
- }
- if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
- }
- if ($p_local_header['flag'] != $p_central_header['flag']) {
- }
- if ($p_local_header['compression'] != $p_central_header['compression']) {
- }
- if ($p_local_header['mtime'] != $p_central_header['mtime']) {
- }
- if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
- }
-
- // ----- Look for flag bit 3
- if (($p_local_header['flag'] & 8) == 8) {
- $p_local_header['size'] = $p_central_header['size'];
- $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
- $p_local_header['crc'] = $p_central_header['crc'];
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privReadEndCentralDir()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privReadEndCentralDir(&$p_central_dir)
- {
- $v_result=1;
-
- // ----- Go to the end of the zip file
- $v_size = filesize($this->zipname);
- @fseek($this->zip_fd, $v_size);
- if (@ftell($this->zip_fd) != $v_size)
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- First try : look if this is an archive with no commentaries (most of the time)
- // in this case the end of central dir is at 22 bytes of the file end
- $v_found = 0;
- if ($v_size > 26) {
- @fseek($this->zip_fd, $v_size-22);
- if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Read for bytes
- $v_binary_data = @fread($this->zip_fd, 4);
- $v_data = @unpack('Vid', $v_binary_data);
-
- // ----- Check signature
- if ($v_data['id'] == 0x06054b50) {
- $v_found = 1;
- }
-
- $v_pos = ftell($this->zip_fd);
- }
-
- // ----- Go back to the maximum possible size of the Central Dir End Record
- if (!$v_found) {
- $v_maximum_size = 65557; // 0xFFFF + 22;
- if ($v_maximum_size > $v_size)
- $v_maximum_size = $v_size;
- @fseek($this->zip_fd, $v_size-$v_maximum_size);
- if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
- {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Read byte per byte in order to find the signature
- $v_pos = ftell($this->zip_fd);
- $v_bytes = 0x00000000;
- while ($v_pos < $v_size)
- {
- // ----- Read a byte
- $v_byte = @fread($this->zip_fd, 1);
-
- // ----- Add the byte
- //$v_bytes = ($v_bytes << 8) | Ord($v_byte);
- // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
- // Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
- $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
-
- // ----- Compare the bytes
- if ($v_bytes == 0x504b0506)
- {
- $v_pos++;
- break;
+ // ----- Trick
+ // Here I want to reuse extractByRule(), so I need to parse the $p_index
+ // with privParseOptions()
+ $v_arg_trick = array(
+ PCLZIP_OPT_BY_INDEX,
+ $p_index
+ );
+ $v_options_trick = array();
+ $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick, array(
+ PCLZIP_OPT_BY_INDEX => 'optional'
+ ));
+ if ($v_result != 1) {
+ return 0;
+ }
+ $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
+
+ // ----- Look for default option values
+ $this->privOptionDefaultThreshold($v_options);
+
+ // ----- Call the extracting fct
+ if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
+ return (0);
}
- $v_pos++;
- }
-
- // ----- Look if not found end of central dir
- if ($v_pos == $v_size)
- {
-
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
-
// ----- Return
- return PclZip::errorCode();
- }
+ return $p_list;
}
+ // --------------------------------------------------------------------------------
- // ----- Read the first 18 bytes of the header
- $v_binary_data = fread($this->zip_fd, 18);
-
- // ----- Look for invalid block size
- if (strlen($v_binary_data) != 18)
+ // --------------------------------------------------------------------------------
+ // Function :
+ // delete([$p_option, $p_option_value, ...])
+ // Description :
+ // This method removes files from the archive.
+ // If no parameters are given, then all the archive is emptied.
+ // Parameters :
+ // None or optional arguments.
+ // Options :
+ // PCLZIP_OPT_BY_INDEX :
+ // PCLZIP_OPT_BY_NAME :
+ // PCLZIP_OPT_BY_EREG :
+ // PCLZIP_OPT_BY_PREG :
+ // Return Values :
+ // 0 on failure,
+ // The list of the files which are still present in the archive.
+ // (see PclZip::listContent() for list entry format)
+ // --------------------------------------------------------------------------------
+ public function delete()
{
+ $v_result = 1;
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
+ // ----- Reset the error handler
+ $this->privErrorReset();
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Extract the values
- $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
-
- // ----- Check the global size
- if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
-
- // ----- Removed in release 2.2 see readme file
- // The check of the file size is a little too strict.
- // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
- // While decrypted, zip has training 0 bytes
- if (0) {
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
- 'The central dir is not at the end of the archive.'
- .' Some trailing bytes exists after the archive.');
-
- // ----- Return
- return PclZip::errorCode();
- }
- }
-
- // ----- Get comment
- if ($v_data['comment_size'] != 0) {
- $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
- }
- else
- $p_central_dir['comment'] = '';
-
- $p_central_dir['entries'] = $v_data['entries'];
- $p_central_dir['disk_entries'] = $v_data['disk_entries'];
- $p_central_dir['offset'] = $v_data['offset'];
- $p_central_dir['size'] = $v_data['size'];
- $p_central_dir['disk'] = $v_data['disk'];
- $p_central_dir['disk_start'] = $v_data['disk_start'];
-
- // TBC
- //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
- //}
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privDeleteByRule()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privDeleteByRule(&$p_result_list, &$p_options)
- {
- $v_result=1;
- $v_list_detail = array();
-
- // ----- Open the zip file
- if (($v_result=$this->privOpenFd('rb')) != 1)
- {
- // ----- Return
- return $v_result;
- }
-
- // ----- Read the central directory informations
- $v_central_dir = array();
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
- {
- $this->privCloseFd();
- return $v_result;
- }
-
- // ----- Go to beginning of File
- @rewind($this->zip_fd);
-
- // ----- Scan all the files
- // ----- Start at beginning of Central Dir
- $v_pos_entry = $v_central_dir['offset'];
- @rewind($this->zip_fd);
- if (@fseek($this->zip_fd, $v_pos_entry))
- {
- // ----- Close the zip file
- $this->privCloseFd();
-
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Read each entry
- $v_header_list = array();
- $j_start = 0;
- for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
- {
-
- // ----- Read the file header
- $v_header_list[$v_nb_extracted] = array();
- if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
- {
- // ----- Close the zip file
- $this->privCloseFd();
-
- return $v_result;
- }
-
-
- // ----- Store the index
- $v_header_list[$v_nb_extracted]['index'] = $i;
-
- // ----- Look for the specific extract rules
- $v_found = false;
-
- // ----- Look for extract by name rule
- if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
- && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
-
- // ----- Look if the filename is in the list
- for ($j=0; ($j strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
- && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
- $v_found = true;
- }
- elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
- && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
- $v_found = true;
- }
- }
- // ----- Look for a filename
- elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
- $v_found = true;
- }
- }
- }
-
- // ----- Look for extract by ereg rule
- // ereg() is deprecated with PHP 5.3
- /*
- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
- && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
-
- if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
- $v_found = true;
- }
- }
- */
-
- // ----- Look for extract by preg rule
- else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
- && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
-
- if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
- $v_found = true;
- }
- }
-
- // ----- Look for extract by index rule
- else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
- && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
-
- // ----- Look if the index is in the list
- for ($j=$j_start; ($j=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
- $v_found = true;
- }
- if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
- $j_start = $j+1;
- }
-
- if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
- break;
- }
- }
- }
- else {
- $v_found = true;
- }
-
- // ----- Look for deletion
- if ($v_found)
- {
- unset($v_header_list[$v_nb_extracted]);
- }
- else
- {
- $v_nb_extracted++;
- }
- }
-
- // ----- Look if something need to be deleted
- if ($v_nb_extracted > 0) {
-
- // ----- Creates a temporay file
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
-
- // ----- Creates a temporary zip archive
- $v_temp_zip = new PclZip($v_zip_temp_name);
-
- // ----- Open the temporary zip file in write mode
- if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
- $this->privCloseFd();
-
- // ----- Return
- return $v_result;
+ // ----- Check archive
+ if (!$this->privCheckFormat()) {
+ return (0);
}
- // ----- Look which file need to be kept
- for ($i=0; $izip_fd);
- if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
- // ----- Close the zip file
- $this->privCloseFd();
- $v_temp_zip->privCloseFd();
- @unlink($v_zip_temp_name);
+ // ----- Look for variable options arguments
+ $v_size = func_num_args();
+
+ // ----- Look for arguments
+ if ($v_size > 0) {
+ // ----- Get the arguments
+ $v_arg_list = func_get_args();
+
+ // ----- Parse the options
+ $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options, array(
+ PCLZIP_OPT_BY_NAME => 'optional',
+ PCLZIP_OPT_BY_EREG => 'optional',
+ PCLZIP_OPT_BY_PREG => 'optional',
+ PCLZIP_OPT_BY_INDEX => 'optional'
+ ));
+ if ($v_result != 1) {
+ return 0;
+ }
+ }
+
+ // ----- Magic quotes trick
+ $this->privDisableMagicQuotes();
+
+ // ----- Call the delete fct
+ $v_list = array();
+ if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
+ $this->privSwapBackMagicQuotes();
+ unset($v_list);
+
+ return (0);
+ }
+
+ // ----- Magic quotes trick
+ $this->privSwapBackMagicQuotes();
+
+ // ----- Return
+ return $v_list;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : deleteByIndex()
+ // Description :
+ // ***** Deprecated *****
+ // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
+ // --------------------------------------------------------------------------------
+ public function deleteByIndex($p_index)
+ {
+
+ $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
+
+ // ----- Return
+ return $p_list;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : properties()
+ // Description :
+ // This method gives the properties of the archive.
+ // The properties are :
+ // nb : Number of files in the archive
+ // comment : Comment associated with the archive file
+ // status : not_exist, ok
+ // Parameters :
+ // None
+ // Return Values :
+ // 0 on failure,
+ // An array with the archive properties.
+ // --------------------------------------------------------------------------------
+ public function properties()
+ {
+
+ // ----- Reset the error handler
+ $this->privErrorReset();
+
+ // ----- Magic quotes trick
+ $this->privDisableMagicQuotes();
+
+ // ----- Check archive
+ if (!$this->privCheckFormat()) {
+ $this->privSwapBackMagicQuotes();
+
+ return (0);
+ }
+
+ // ----- Default properties
+ $v_prop = array();
+ $v_prop['comment'] = '';
+ $v_prop['nb'] = 0;
+ $v_prop['status'] = 'not_exist';
+
+ // ----- Look if file exists
+ if (@is_file($this->zipname)) {
+ // ----- Open the zip file
+ if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) {
+ $this->privSwapBackMagicQuotes();
// ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \'' . $this->zipname . '\' in binary read mode');
+
+ // ----- Return
+ return 0;
+ }
+
+ // ----- Read the central directory informations
+ $v_central_dir = array();
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) {
+ $this->privSwapBackMagicQuotes();
+
+ return 0;
+ }
+
+ // ----- Close the zip file
+ $this->privCloseFd();
+
+ // ----- Set the user attributes
+ $v_prop['comment'] = $v_central_dir['comment'];
+ $v_prop['nb'] = $v_central_dir['entries'];
+ $v_prop['status'] = 'ok';
+ }
+
+ // ----- Magic quotes trick
+ $this->privSwapBackMagicQuotes();
+
+ // ----- Return
+ return $v_prop;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : duplicate()
+ // Description :
+ // This method creates an archive by copying the content of an other one. If
+ // the archive already exist, it is replaced by the new one without any warning.
+ // Parameters :
+ // $p_archive : The filename of a valid archive, or
+ // a valid PclZip object.
+ // Return Values :
+ // 1 on success.
+ // 0 or a negative value on error (error code).
+ // --------------------------------------------------------------------------------
+ public function duplicate($p_archive)
+ {
+ $v_result = 1;
+
+ // ----- Reset the error handler
+ $this->privErrorReset();
+
+ // ----- Look if the $p_archive is a PclZip object
+ if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip')) {
+
+ // ----- Duplicate the archive
+ $v_result = $this->privDuplicate($p_archive->zipname);
+
+ // ----- Look if the $p_archive is a string (so a filename)
+ } elseif (is_string($p_archive)) {
+
+ // ----- Check that $p_archive is a valid zip file
+ // TBC : Should also check the archive format
+ if (!is_file($p_archive)) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '" . $p_archive . "'");
+ $v_result = PCLZIP_ERR_MISSING_FILE;
+ } else {
+ // ----- Duplicate the archive
+ $v_result = $this->privDuplicate($p_archive);
+ }
+
+ // ----- Invalid variable
+ } else {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
+ $v_result = PCLZIP_ERR_INVALID_PARAMETER;
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : merge()
+ // Description :
+ // This method merge the $p_archive_to_add archive at the end of the current
+ // one ($this).
+ // If the archive ($this) does not exist, the merge becomes a duplicate.
+ // If the $p_archive_to_add archive does not exist, the merge is a success.
+ // Parameters :
+ // $p_archive_to_add : It can be directly the filename of a valid zip archive,
+ // or a PclZip object archive.
+ // Return Values :
+ // 1 on success,
+ // 0 or negative values on error (see below).
+ // --------------------------------------------------------------------------------
+ public function merge($p_archive_to_add)
+ {
+ $v_result = 1;
+
+ // ----- Reset the error handler
+ $this->privErrorReset();
+
+ // ----- Check archive
+ if (!$this->privCheckFormat()) {
+ return (0);
+ }
+
+ // ----- Look if the $p_archive_to_add is a PclZip object
+ if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip')) {
+
+ // ----- Merge the archive
+ $v_result = $this->privMerge($p_archive_to_add);
+
+ // ----- Look if the $p_archive_to_add is a string (so a filename)
+ } elseif (is_string($p_archive_to_add)) {
+
+ // ----- Create a temporary archive
+ $v_object_archive = new PclZip($p_archive_to_add);
+
+ // ----- Merge the archive
+ $v_result = $this->privMerge($v_object_archive);
+
+ // ----- Invalid variable
+ } else {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
+ $v_result = PCLZIP_ERR_INVALID_PARAMETER;
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : errorCode()
+ // Description :
+ // Parameters :
+ // --------------------------------------------------------------------------------
+ public function errorCode()
+ {
+ if (PCLZIP_ERROR_EXTERNAL == 1) {
+ return (PclErrorCode());
+ } else {
+ return ($this->error_code);
+ }
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : errorName()
+ // Description :
+ // Parameters :
+ // --------------------------------------------------------------------------------
+ public function errorName($p_with_code = false)
+ {
+ $v_name = array(
+ PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
+ PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
+ PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
+ PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
+ PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
+ PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
+ PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
+ PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
+ PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
+ PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
+ PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
+ PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
+ PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
+ PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
+ PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
+ PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
+ PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
+ PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
+ PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION',
+ PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE',
+ PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
+ );
+
+ if (isset($v_name[$this->error_code])) {
+ $v_value = $v_name[$this->error_code];
+ } else {
+ $v_value = 'NoName';
+ }
+
+ if ($p_with_code) {
+ return ($v_value . ' (' . $this->error_code . ')');
+ } else {
+ return ($v_value);
+ }
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : errorInfo()
+ // Description :
+ // Parameters :
+ // --------------------------------------------------------------------------------
+ public function errorInfo($p_full = false)
+ {
+ if (PCLZIP_ERROR_EXTERNAL == 1) {
+ return (PclErrorString());
+ } else {
+ if ($p_full) {
+ return ($this->errorName(true) . " : " . $this->error_string);
+ } else {
+ return ($this->error_string . " [code " . $this->error_code . "]");
+ }
+ }
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
+ // ***** *****
+ // ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY *****
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privCheckFormat()
+ // Description :
+ // This method check that the archive exists and is a valid zip archive.
+ // Several level of check exists. (futur)
+ // Parameters :
+ // $p_level : Level of check. Default 0.
+ // 0 : Check the first bytes (magic codes) (default value))
+ // 1 : 0 + Check the central directory (futur)
+ // 2 : 1 + Check each file header (futur)
+ // Return Values :
+ // true on success,
+ // false on error, the error code is set.
+ // --------------------------------------------------------------------------------
+ public function privCheckFormat($p_level = 0)
+ {
+ $v_result = true;
+
+ // ----- Reset the file system cache
+ clearstatcache();
+
+ // ----- Reset the error handler
+ $this->privErrorReset();
+
+ // ----- Look if the file exits
+ if (!is_file($this->zipname)) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '" . $this->zipname . "'");
+
+ return (false);
+ }
+
+ // ----- Check that the file is readeable
+ if (!is_readable($this->zipname)) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '" . $this->zipname . "'");
+
+ return (false);
+ }
+
+ // ----- Check the magic code
+ // TBC
+
+ // ----- Check the central header
+ // TBC
+
+ // ----- Check each file header
+ // TBC
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privParseOptions()
+ // Description :
+ // This internal methods reads the variable list of arguments ($p_options_list,
+ // $p_size) and generate an array with the options and values ($v_result_list).
+ // $v_requested_options contains the options that can be present and those that
+ // must be present.
+ // $v_requested_options is an array, with the option value as key, and 'optional',
+ // or 'mandatory' as value.
+ // Parameters :
+ // See above.
+ // Return Values :
+ // 1 on success.
+ // 0 on failure.
+ // --------------------------------------------------------------------------------
+ public function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options = false)
+ {
+ $v_result = 1;
+
+ // ----- Read the options
+ $i = 0;
+ while ($i < $p_size) {
+
+ // ----- Check if the option is supported
+ if (!isset($v_requested_options[$p_options_list[$i]])) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '" . $p_options_list[$i] . "' for this method");
// ----- Return
return PclZip::errorCode();
}
- // ----- Read the file header
- $v_local_header = array();
- if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
- // ----- Close the zip file
- $this->privCloseFd();
- $v_temp_zip->privCloseFd();
- @unlink($v_zip_temp_name);
+ // ----- Look for next option
+ switch ($p_options_list[$i]) {
+ // ----- Look for options that request a path value
+ case PCLZIP_OPT_PATH:
+ case PCLZIP_OPT_REMOVE_PATH:
+ case PCLZIP_OPT_ADD_PATH:
+ // ----- Check the number of parameters
+ if (($i + 1) >= $p_size) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
- // ----- Return
- return $v_result;
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Get the value
+ $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i + 1], false);
+ $i++;
+ break;
+
+ case PCLZIP_OPT_TEMP_FILE_THRESHOLD:
+ // ----- Check the number of parameters
+ if (($i + 1) >= $p_size) {
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Check for incompatible options
+ if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '" . PclZipUtilOptionText($p_options_list[$i]) . "' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Check the value
+ $v_value = $p_options_list[$i + 1];
+ if ((!is_integer($v_value)) || ($v_value < 0)) {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Get the value (and convert it in bytes)
+ $v_result_list[$p_options_list[$i]] = $v_value * 1048576;
+ $i++;
+ break;
+
+ case PCLZIP_OPT_TEMP_FILE_ON:
+ // ----- Check for incompatible options
+ if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '" . PclZipUtilOptionText($p_options_list[$i]) . "' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
+
+ return PclZip::errorCode();
+ }
+
+ $v_result_list[$p_options_list[$i]] = true;
+ break;
+
+ case PCLZIP_OPT_TEMP_FILE_OFF:
+ // ----- Check for incompatible options
+ if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '" . PclZipUtilOptionText($p_options_list[$i]) . "' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
+
+ return PclZip::errorCode();
+ }
+ // ----- Check for incompatible options
+ if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '" . PclZipUtilOptionText($p_options_list[$i]) . "' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
+
+ return PclZip::errorCode();
+ }
+
+ $v_result_list[$p_options_list[$i]] = true;
+ break;
+
+ case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION:
+ // ----- Check the number of parameters
+ if (($i + 1) >= $p_size) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Get the value
+ if (is_string($p_options_list[$i + 1]) && ($p_options_list[$i + 1] != '')) {
+ $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i + 1], false);
+ $i++;
+ } else {
+ }
+ break;
+
+ // ----- Look for options that request an array of string for value
+ case PCLZIP_OPT_BY_NAME:
+ // ----- Check the number of parameters
+ if (($i + 1) >= $p_size) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Get the value
+ if (is_string($p_options_list[$i + 1])) {
+ $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i + 1];
+ } elseif (is_array($p_options_list[$i + 1])) {
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1];
+ } else {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+ $i++;
+ break;
+
+ // ----- Look for options that request an EREG or PREG expression
+ case PCLZIP_OPT_BY_EREG:
+ $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
+ // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
+ // to PCLZIP_OPT_BY_PREG
+ case PCLZIP_OPT_BY_PREG:
+ //case PCLZIP_OPT_CRYPT :
+ // ----- Check the number of parameters
+ if (($i + 1) >= $p_size) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Get the value
+ if (is_string($p_options_list[$i + 1])) {
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1];
+ } else {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+ $i++;
+ break;
+
+ // ----- Look for options that takes a string
+ case PCLZIP_OPT_COMMENT:
+ case PCLZIP_OPT_ADD_COMMENT:
+ case PCLZIP_OPT_PREPEND_COMMENT:
+ // ----- Check the number of parameters
+ if (($i + 1) >= $p_size) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Get the value
+ if (is_string($p_options_list[$i + 1])) {
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1];
+ } else {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+ $i++;
+ break;
+
+ // ----- Look for options that request an array of index
+ case PCLZIP_OPT_BY_INDEX:
+ // ----- Check the number of parameters
+ if (($i + 1) >= $p_size) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Get the value
+ $v_work_list = array();
+ if (is_string($p_options_list[$i + 1])) {
+
+ // ----- Remove spaces
+ $p_options_list[$i + 1] = strtr($p_options_list[$i + 1], ' ', '');
+
+ // ----- Parse items
+ $v_work_list = explode(",", $p_options_list[$i + 1]);
+ } elseif (is_integer($p_options_list[$i + 1])) {
+ $v_work_list[0] = $p_options_list[$i + 1] . '-' . $p_options_list[$i + 1];
+ } elseif (is_array($p_options_list[$i + 1])) {
+ $v_work_list = $p_options_list[$i + 1];
+ } else {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Reduce the index list
+ // each index item in the list must be a couple with a start and
+ // an end value : [0,3], [5-5], [8-10], ...
+ // ----- Check the format of each item
+ $v_sort_flag = false;
+ $v_sort_value = 0;
+ for ($j = 0; $j < sizeof($v_work_list); $j++) {
+ // ----- Explode the item
+ $v_item_list = explode("-", $v_work_list[$j]);
+ $v_size_item_list = sizeof($v_item_list);
+
+ // ----- TBC : Here we might check that each item is a
+ // real integer ...
+
+ // ----- Look for single value
+ if ($v_size_item_list == 1) {
+ // ----- Set the option value
+ $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
+ $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
+ } elseif ($v_size_item_list == 2) {
+ // ----- Set the option value
+ $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
+ $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
+ } else {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Look for list sort
+ if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
+ $v_sort_flag = true;
+
+ // ----- TBC : An automatic sort should be writen ...
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+ $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
+ }
+
+ // ----- Sort the items
+ if ($v_sort_flag) {
+ // TBC : To Be Completed
+ }
+
+ // ----- Next option
+ $i++;
+ break;
+
+ // ----- Look for options that request no value
+ case PCLZIP_OPT_REMOVE_ALL_PATH:
+ case PCLZIP_OPT_EXTRACT_AS_STRING:
+ case PCLZIP_OPT_NO_COMPRESSION:
+ case PCLZIP_OPT_EXTRACT_IN_OUTPUT:
+ case PCLZIP_OPT_REPLACE_NEWER:
+ case PCLZIP_OPT_STOP_ON_ERROR:
+ $v_result_list[$p_options_list[$i]] = true;
+ break;
+
+ // ----- Look for options that request an octal value
+ case PCLZIP_OPT_SET_CHMOD:
+ // ----- Check the number of parameters
+ if (($i + 1) >= $p_size) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Get the value
+ $v_result_list[$p_options_list[$i]] = $p_options_list[$i + 1];
+ $i++;
+ break;
+
+ // ----- Look for options that request a call-back
+ case PCLZIP_CB_PRE_EXTRACT:
+ case PCLZIP_CB_POST_EXTRACT:
+ case PCLZIP_CB_PRE_ADD:
+ case PCLZIP_CB_POST_ADD:
+ /* for futur use
+ case PCLZIP_CB_PRE_DELETE :
+ case PCLZIP_CB_POST_DELETE :
+ case PCLZIP_CB_PRE_LIST :
+ case PCLZIP_CB_POST_LIST :
+ */
+ // ----- Check the number of parameters
+ if (($i + 1) >= $p_size) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Get the value
+ $v_function_name = $p_options_list[$i + 1];
+
+ // ----- Check that the value is a valid existing function
+ if (!function_exists($v_function_name)) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '" . $v_function_name . "()' is not an existing function for option '" . PclZipUtilOptionText($p_options_list[$i]) . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Set the attribute
+ $v_result_list[$p_options_list[$i]] = $v_function_name;
+ $i++;
+ break;
+
+ default:
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown parameter '" . $p_options_list[$i] . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
}
- // ----- Check that local file header is same as central file header
- if ($this->privCheckFileHeaders($v_local_header,
- $v_header_list[$i]) != 1) {
- // TBC
- }
- unset($v_local_header);
+ // ----- Next options
+ $i++;
+ }
- // ----- Write the file header
- if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
- // ----- Close the zip file
- $this->privCloseFd();
- $v_temp_zip->privCloseFd();
- @unlink($v_zip_temp_name);
+ // ----- Look for mandatory options
+ if ($v_requested_options !== false) {
+ for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) {
+ // ----- Look for mandatory option
+ if ($v_requested_options[$key] == 'mandatory') {
+ // ----- Look if present
+ if (!isset($v_result_list[$key])) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter " . PclZipUtilOptionText($key) . "(" . $key . ")");
- // ----- Return
- return $v_result;
- }
-
- // ----- Read/write the data block
- if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
- // ----- Close the zip file
- $this->privCloseFd();
- $v_temp_zip->privCloseFd();
- @unlink($v_zip_temp_name);
-
- // ----- Return
- return $v_result;
+ // ----- Return
+ return PclZip::errorCode();
+ }
+ }
}
}
- // ----- Store the offset of the central dir
- $v_offset = @ftell($v_temp_zip->zip_fd);
+ // ----- Look for default values
+ if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
- // ----- Re-Create the Central Dir files header
- for ($i=0; $iprivWriteCentralFileHeader($v_header_list[$i])) != 1) {
- $v_temp_zip->privCloseFd();
- $this->privCloseFd();
- @unlink($v_zip_temp_name);
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privOptionDefaultThreshold()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privOptionDefaultThreshold(&$p_options)
+ {
+ $v_result = 1;
+
+ if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
+ return $v_result;
+ }
+
+ // ----- Get 'memory_limit' configuration value
+ $v_memory_limit = ini_get('memory_limit');
+ $v_memory_limit = trim($v_memory_limit);
+ $last = strtolower(substr($v_memory_limit, -1));
+ $v_memory_limit = preg_replace('/[^0-9,.]/', '', $v_memory_limit);
+
+ if ($last == 'g') {
+ //$v_memory_limit = $v_memory_limit*1024*1024*1024;
+ $v_memory_limit = $v_memory_limit * 1073741824;
+ }
+ if ($last == 'm') {
+ //$v_memory_limit = $v_memory_limit*1024*1024;
+ $v_memory_limit = $v_memory_limit * 1048576;
+ }
+ if ($last == 'k') {
+ $v_memory_limit = $v_memory_limit * 1024;
+ }
+
+ $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit * PCLZIP_TEMPORARY_FILE_RATIO);
+
+ // ----- Sanity check : No threshold if value lower than 1M
+ if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
+ unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privFileDescrParseAtt()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // 1 on success.
+ // 0 on failure.
+ // --------------------------------------------------------------------------------
+ public function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options = false)
+ {
+ $v_result = 1;
+
+ // ----- For each file in the list check the attributes
+ foreach ($p_file_list as $v_key => $v_value) {
+
+ // ----- Check if the option is supported
+ if (!isset($v_requested_options[$v_key])) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '" . $v_key . "' for this file");
// ----- Return
- return $v_result;
+ return PclZip::errorCode();
}
- // ----- Transform the header to a 'usable' info
- $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
+ // ----- Look for attribute
+ switch ($v_key) {
+ case PCLZIP_ATT_FILE_NAME:
+ if (!is_string($v_value)) {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". String expected for attribute '" . PclZipUtilOptionText($v_key) . "'");
+
+ return PclZip::errorCode();
+ }
+
+ $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
+
+ if ($p_filedescr['filename'] == '') {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '" . PclZipUtilOptionText($v_key) . "'");
+
+ return PclZip::errorCode();
+ }
+
+ break;
+
+ case PCLZIP_ATT_FILE_NEW_SHORT_NAME:
+ if (!is_string($v_value)) {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". String expected for attribute '" . PclZipUtilOptionText($v_key) . "'");
+
+ return PclZip::errorCode();
+ }
+
+ $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
+
+ if ($p_filedescr['new_short_name'] == '') {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '" . PclZipUtilOptionText($v_key) . "'");
+
+ return PclZip::errorCode();
+ }
+ break;
+
+ case PCLZIP_ATT_FILE_NEW_FULL_NAME:
+ if (!is_string($v_value)) {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". String expected for attribute '" . PclZipUtilOptionText($v_key) . "'");
+
+ return PclZip::errorCode();
+ }
+
+ $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
+
+ if ($p_filedescr['new_full_name'] == '') {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '" . PclZipUtilOptionText($v_key) . "'");
+
+ return PclZip::errorCode();
+ }
+ break;
+
+ // ----- Look for options that takes a string
+ case PCLZIP_ATT_FILE_COMMENT:
+ if (!is_string($v_value)) {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". String expected for attribute '" . PclZipUtilOptionText($v_key) . "'");
+
+ return PclZip::errorCode();
+ }
+
+ $p_filedescr['comment'] = $v_value;
+ break;
+
+ case PCLZIP_ATT_FILE_MTIME:
+ if (!is_integer($v_value)) {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type " . gettype($v_value) . ". Integer expected for attribute '" . PclZipUtilOptionText($v_key) . "'");
+
+ return PclZip::errorCode();
+ }
+
+ $p_filedescr['mtime'] = $v_value;
+ break;
+
+ case PCLZIP_ATT_FILE_CONTENT:
+ $p_filedescr['content'] = $v_value;
+ break;
+
+ default:
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown parameter '" . $v_key . "'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Look for mandatory options
+ if ($v_requested_options !== false) {
+ for ($key = reset($v_requested_options); $key = key($v_requested_options); $key = next($v_requested_options)) {
+ // ----- Look for mandatory option
+ if ($v_requested_options[$key] == 'mandatory') {
+ // ----- Look if present
+ if (!isset($p_file_list[$key])) {
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter " . PclZipUtilOptionText($key) . "(" . $key . ")");
+
+ return PclZip::errorCode();
+ }
+ }
+ }
+ }
+
+ // end foreach
}
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
- // ----- Zip file comment
- $v_comment = '';
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
+ // --------------------------------------------------------------------------------
+ // Function : privFileDescrExpand()
+ // Description :
+ // This method look for each item of the list to see if its a file, a folder
+ // or a string to be added as file. For any other type of files (link, other)
+ // just ignore the item.
+ // Then prepare the information that will be stored for that file.
+ // When its a folder, expand the folder with all the files that are in that
+ // folder (recursively).
+ // Parameters :
+ // Return Values :
+ // 1 on success.
+ // 0 on failure.
+ // --------------------------------------------------------------------------------
+ public function privFileDescrExpand(&$p_filedescr_list, &$p_options)
+ {
+ $v_result = 1;
+
+ // ----- Create a result list
+ $v_result_list = array();
+
+ // ----- Look each entry
+ for ($i = 0; $i < sizeof($p_filedescr_list); $i++) {
+
+ // ----- Get filedescr
+ $v_descr = $p_filedescr_list[$i];
+
+ // ----- Reduce the filename
+ $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
+ $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
+
+ // ----- Look for real file or folder
+ if (file_exists($v_descr['filename'])) {
+ if (@is_file($v_descr['filename'])) {
+ $v_descr['type'] = 'file';
+ } elseif (@is_dir($v_descr['filename'])) {
+ $v_descr['type'] = 'folder';
+ } elseif (@is_link($v_descr['filename'])) {
+ // skip
+ continue;
+ } else {
+ // skip
+ continue;
+ }
+
+ // ----- Look for string added as file
+ } elseif (isset($v_descr['content'])) {
+ $v_descr['type'] = 'virtual_file';
+
+ // ----- Missing file
+ } else {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '" . $v_descr['filename'] . "' does not exist");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Calculate the stored filename
+ $this->privCalculateStoredFilename($v_descr, $p_options);
+
+ // ----- Add the descriptor in result list
+ $v_result_list[sizeof($v_result_list)] = $v_descr;
+
+ // ----- Look for folder
+ if ($v_descr['type'] == 'folder') {
+ // ----- List of items in folder
+ $v_dirlist_descr = array();
+ $v_dirlist_nb = 0;
+ if ($v_folder_handler = @opendir($v_descr['filename'])) {
+ while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
+
+ // ----- Skip '.' and '..'
+ if (($v_item_handler == '.') || ($v_item_handler == '..')) {
+ continue;
+ }
+
+ // ----- Compose the full filename
+ $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'] . '/' . $v_item_handler;
+
+ // ----- Look for different stored filename
+ // Because the name of the folder was changed, the name of the
+ // files/sub-folders also change
+ if (($v_descr['stored_filename'] != $v_descr['filename']) && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
+ if ($v_descr['stored_filename'] != '') {
+ $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'] . '/' . $v_item_handler;
+ } else {
+ $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
+ }
+ }
+
+ $v_dirlist_nb++;
+ }
+
+ @closedir($v_folder_handler);
+ } else {
+ // TBC : unable to open folder in read mode
+ }
+
+ // ----- Expand each element of the list
+ if ($v_dirlist_nb != 0) {
+ // ----- Expand
+ if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
+ return $v_result;
+ }
+
+ // ----- Concat the resulting list
+ $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
+ } else {
+ }
+
+ // ----- Free local array
+ unset($v_dirlist_descr);
+ }
}
- // ----- Calculate the size of the central header
- $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
+ // ----- Get the result list
+ $p_filedescr_list = $v_result_list;
- // ----- Create the central dir footer
- if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
- // ----- Reset the file list
- unset($v_header_list);
- $v_temp_zip->privCloseFd();
- $this->privCloseFd();
- @unlink($v_zip_temp_name);
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privCreate()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
+ {
+ $v_result = 1;
+ $v_list_detail = array();
+
+ // ----- Magic quotes trick
+ $this->privDisableMagicQuotes();
+
+ // ----- Open the file in write mode
+ if (($v_result = $this->privOpenFd('wb')) != 1) {
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Add the list of files
+ $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
+
+ // ----- Close
+ $this->privCloseFd();
+
+ // ----- Magic quotes trick
+ $this->privSwapBackMagicQuotes();
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privAdd()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
+ {
+ $v_result = 1;
+ $v_list_detail = array();
+
+ // ----- Look if the archive exists or is empty
+ if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0)) {
+
+ // ----- Do a create
+ $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
+
+ // ----- Return
+ return $v_result;
+ }
+ // ----- Magic quotes trick
+ $this->privDisableMagicQuotes();
+
+ // ----- Open the zip file
+ if (($v_result = $this->privOpenFd('rb')) != 1) {
+ // ----- Magic quotes trick
+ $this->privSwapBackMagicQuotes();
// ----- Return
return $v_result;
}
+ // ----- Read the central directory informations
+ $v_central_dir = array();
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) {
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result;
+ }
+
+ // ----- Go to beginning of File
+ @rewind($this->zip_fd);
+
+ // ----- Creates a temporay file
+ $v_zip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.tmp';
+
+ // ----- Open the temporary file in write mode
+ if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) {
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_zip_temp_name . '\' in binary write mode');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Copy the files from the archive to the temporary file
+ // TBC : Here I should better append the file and go back to erase the central dir
+ $v_size = $v_central_dir['offset'];
+ while ($v_size != 0) {
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = fread($this->zip_fd, $v_read_size);
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+ $v_size -= $v_read_size;
+ }
+
+ // ----- Swap the file descriptor
+ // Here is a trick : I swap the temporary fd with the zip fd, in order to use
+ // the following methods on the temporary fil and not the real archive
+ $v_swap = $this->zip_fd;
+ $this->zip_fd = $v_zip_temp_fd;
+ $v_zip_temp_fd = $v_swap;
+
+ // ----- Add the files
+ $v_header_list = array();
+ if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) {
+ fclose($v_zip_temp_fd);
+ $this->privCloseFd();
+ @unlink($v_zip_temp_name);
+ $this->privSwapBackMagicQuotes();
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Store the offset of the central dir
+ $v_offset = @ftell($this->zip_fd);
+
+ // ----- Copy the block of file headers from the old archive
+ $v_size = $v_central_dir['size'];
+ while ($v_size != 0) {
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
+ @fwrite($this->zip_fd, $v_buffer, $v_read_size);
+ $v_size -= $v_read_size;
+ }
+
+ // ----- Create the Central Dir files header
+ for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++) {
+ // ----- Create the file header
+ if ($v_header_list[$i]['status'] == 'ok') {
+ if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
+ fclose($v_zip_temp_fd);
+ $this->privCloseFd();
+ @unlink($v_zip_temp_name);
+ $this->privSwapBackMagicQuotes();
+
+ // ----- Return
+ return $v_result;
+ }
+ $v_count++;
+ }
+
+ // ----- Transform the header to a 'usable' info
+ $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
+ }
+
+ // ----- Zip file comment
+ $v_comment = $v_central_dir['comment'];
+ if (isset($p_options[PCLZIP_OPT_COMMENT])) {
+ $v_comment = $p_options[PCLZIP_OPT_COMMENT];
+ }
+ if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
+ $v_comment = $v_comment . $p_options[PCLZIP_OPT_ADD_COMMENT];
+ }
+ if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
+ $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT] . $v_comment;
+ }
+
+ // ----- Calculate the size of the central header
+ $v_size = @ftell($this->zip_fd) - $v_offset;
+
+ // ----- Create the central dir footer
+ if (($v_result = $this->privWriteCentralHeader($v_count + $v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1) {
+ // ----- Reset the file list
+ unset($v_header_list);
+ $this->privSwapBackMagicQuotes();
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Swap back the file descriptor
+ $v_swap = $this->zip_fd;
+ $this->zip_fd = $v_zip_temp_fd;
+ $v_zip_temp_fd = $v_swap;
+
// ----- Close
- $v_temp_zip->privCloseFd();
$this->privCloseFd();
+ // ----- Close the temporary file
+ @fclose($v_zip_temp_fd);
+
+ // ----- Magic quotes trick
+ $this->privSwapBackMagicQuotes();
+
// ----- Delete the zip file
// TBC : I should test the result ...
@unlink($this->zipname);
@@ -4954,544 +2269,2964 @@
//@rename($v_zip_temp_name, $this->zipname);
PclZipUtilRename($v_zip_temp_name, $this->zipname);
- // ----- Destroy the temporary archive
- unset($v_temp_zip);
+ // ----- Return
+ return $v_result;
}
+ // --------------------------------------------------------------------------------
- // ----- Remove every files : reset the file
- else if ($v_central_dir['entries'] != 0) {
+ // --------------------------------------------------------------------------------
+ // Function : privOpenFd()
+ // Description :
+ // Parameters :
+ // --------------------------------------------------------------------------------
+ public function privOpenFd($p_mode)
+ {
+ $v_result = 1;
+
+ // ----- Look if already open
+ if ($this->zip_fd != 0) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \'' . $this->zipname . '\' already open');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Open the zip file
+ if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \'' . $this->zipname . '\' in ' . $p_mode . ' mode');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privCloseFd()
+ // Description :
+ // Parameters :
+ // --------------------------------------------------------------------------------
+ public function privCloseFd()
+ {
+ $v_result = 1;
+
+ if ($this->zip_fd != 0) {
+ @fclose($this->zip_fd);
+ }
+ $this->zip_fd = 0;
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privAddList()
+ // Description :
+ // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
+ // different from the real path of the file. This is usefull if you want to have PclTar
+ // running in any directory, and memorize relative path from an other directory.
+ // Parameters :
+ // $p_list : An array containing the file or directory names to add in the tar
+ // $p_result_list : list of added files with their properties (specially the status field)
+ // $p_add_dir : Path to add in the filename path archived
+ // $p_remove_dir : Path to remove in the filename path archived
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
+ public function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
+ {
+ $v_result = 1;
+
+ // ----- Add the files
+ $v_header_list = array();
+ if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1) {
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Store the offset of the central dir
+ $v_offset = @ftell($this->zip_fd);
+
+ // ----- Create the Central Dir files header
+ for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++) {
+ // ----- Create the file header
+ if ($v_header_list[$i]['status'] == 'ok') {
+ if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
+ // ----- Return
+ return $v_result;
+ }
+ $v_count++;
+ }
+
+ // ----- Transform the header to a 'usable' info
+ $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
+ }
+
+ // ----- Zip file comment
+ $v_comment = '';
+ if (isset($p_options[PCLZIP_OPT_COMMENT])) {
+ $v_comment = $p_options[PCLZIP_OPT_COMMENT];
+ }
+
+ // ----- Calculate the size of the central header
+ $v_size = @ftell($this->zip_fd) - $v_offset;
+
+ // ----- Create the central dir footer
+ if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1) {
+ // ----- Reset the file list
+ unset($v_header_list);
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privAddFileList()
+ // Description :
+ // Parameters :
+ // $p_filedescr_list : An array containing the file description
+ // or directory names to add in the zip
+ // $p_result_list : list of added files with their properties (specially the status field)
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
+ {
+ $v_result = 1;
+ $v_header = array();
+
+ // ----- Recuperate the current number of elt in list
+ $v_nb = sizeof($p_result_list);
+
+ // ----- Loop on the files
+ for ($j = 0; ($j < sizeof($p_filedescr_list)) && ($v_result == 1); $j++) {
+ // ----- Format the filename
+ $p_filedescr_list[$j]['filename'] = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
+
+ // ----- Skip empty file names
+ // TBC : Can this be possible ? not checked in DescrParseAtt ?
+ if ($p_filedescr_list[$j]['filename'] == "") {
+ continue;
+ }
+
+ // ----- Check the filename
+ if (($p_filedescr_list[$j]['type'] != 'virtual_file') && (!file_exists($p_filedescr_list[$j]['filename']))) {
+ PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '" . $p_filedescr_list[$j]['filename'] . "' does not exist");
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Look if it is a file or a dir with no all path remove option
+ // or a dir with all its path removed
+ // if ( (is_file($p_filedescr_list[$j]['filename']))
+ // || ( is_dir($p_filedescr_list[$j]['filename'])
+ if (($p_filedescr_list[$j]['type'] == 'file') || ($p_filedescr_list[$j]['type'] == 'virtual_file') || (($p_filedescr_list[$j]['type'] == 'folder') && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]) || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
+
+ // ----- Add the file
+ $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header, $p_options);
+ if ($v_result != 1) {
+ return $v_result;
+ }
+
+ // ----- Store the file infos
+ $p_result_list[$v_nb++] = $v_header;
+ }
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privAddFile()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privAddFile($p_filedescr, &$p_header, &$p_options)
+ {
+ $v_result = 1;
+
+ // ----- Working variable
+ $p_filename = $p_filedescr['filename'];
+
+ // TBC : Already done in the fileAtt check ... ?
+ if ($p_filename == "") {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Look for a stored different filename
+ /* TBC : Removed
+ if (isset($p_filedescr['stored_filename'])) {
+ $v_stored_filename = $p_filedescr['stored_filename'];
+ } else {
+ $v_stored_filename = $p_filedescr['stored_filename'];
+ }
+ */
+
+ // ----- Set the file properties
+ clearstatcache();
+ $p_header['version'] = 20;
+ $p_header['version_extracted'] = 10;
+ $p_header['flag'] = 0;
+ $p_header['compression'] = 0;
+ $p_header['crc'] = 0;
+ $p_header['compressed_size'] = 0;
+ $p_header['filename_len'] = strlen($p_filename);
+ $p_header['extra_len'] = 0;
+ $p_header['disk'] = 0;
+ $p_header['internal'] = 0;
+ $p_header['offset'] = 0;
+ $p_header['filename'] = $p_filename;
+ // TBC : Removed $p_header['stored_filename'] = $v_stored_filename;
+ $p_header['stored_filename'] = $p_filedescr['stored_filename'];
+ $p_header['extra'] = '';
+ $p_header['status'] = 'ok';
+ $p_header['index'] = -1;
+
+ // ----- Look for regular file
+ if ($p_filedescr['type'] == 'file') {
+ $p_header['external'] = 0x00000000;
+ $p_header['size'] = filesize($p_filename);
+
+ // ----- Look for regular folder
+ } elseif ($p_filedescr['type'] == 'folder') {
+ $p_header['external'] = 0x00000010;
+ $p_header['mtime'] = filemtime($p_filename);
+ $p_header['size'] = filesize($p_filename);
+
+ // ----- Look for virtual file
+ } elseif ($p_filedescr['type'] == 'virtual_file') {
+ $p_header['external'] = 0x00000000;
+ $p_header['size'] = strlen($p_filedescr['content']);
+ }
+
+ // ----- Look for filetime
+ if (isset($p_filedescr['mtime'])) {
+ $p_header['mtime'] = $p_filedescr['mtime'];
+ } elseif ($p_filedescr['type'] == 'virtual_file') {
+ $p_header['mtime'] = time();
+ } else {
+ $p_header['mtime'] = filemtime($p_filename);
+ }
+
+ // ------ Look for file comment
+ if (isset($p_filedescr['comment'])) {
+ $p_header['comment_len'] = strlen($p_filedescr['comment']);
+ $p_header['comment'] = $p_filedescr['comment'];
+ } else {
+ $p_header['comment_len'] = 0;
+ $p_header['comment'] = '';
+ }
+
+ // ----- Look for pre-add callback
+ if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
+
+ // ----- Generate a local information
+ $v_local_header = array();
+ $this->privConvertHeader2FileInfo($p_header, $v_local_header);
+
+ // ----- Call the callback
+ // Here I do not use call_user_func() because I need to send a reference to the
+ // header.
+ // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
+ $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
+ if ($v_result == 0) {
+ // ----- Change the file status
+ $p_header['status'] = "skipped";
+ $v_result = 1;
+ }
+
+ // ----- Update the informations
+ // Only some fields can be modified
+ if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
+ $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
+ }
+ }
+
+ // ----- Look for empty stored filename
+ if ($p_header['stored_filename'] == "") {
+ $p_header['status'] = "filtered";
+ }
+
+ // ----- Check the path length
+ if (strlen($p_header['stored_filename']) > 0xFF) {
+ $p_header['status'] = 'filename_too_long';
+ }
+
+ // ----- Look if no error, or file not skipped
+ if ($p_header['status'] == 'ok') {
+
+ // ----- Look for a file
+ if ($p_filedescr['type'] == 'file') {
+ // ----- Look for using temporary file to zip
+ if ((!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])))) {
+ $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
+ if ($v_result < PCLZIP_ERR_NO_ERROR) {
+ return $v_result;
+ }
+
+ // ----- Use "in memory" zip algo
+ } else {
+
+ // ----- Open the source file
+ if (($v_file = @fopen($p_filename, "rb")) == 0) {
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Read the file content
+ $v_content = @fread($v_file, $p_header['size']);
+
+ // ----- Close the file
+ @fclose($v_file);
+
+ // ----- Calculate the CRC
+ $p_header['crc'] = @crc32($v_content);
+
+ // ----- Look for no compression
+ if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
+ // ----- Set header parameters
+ $p_header['compressed_size'] = $p_header['size'];
+ $p_header['compression'] = 0;
+
+ // ----- Look for normal compression
+ } else {
+ // ----- Compress the content
+ $v_content = @gzdeflate($v_content);
+
+ // ----- Set header parameters
+ $p_header['compressed_size'] = strlen($v_content);
+ $p_header['compression'] = 8;
+ }
+
+ // ----- Call the header generation
+ if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
+ @fclose($v_file);
+
+ return $v_result;
+ }
+
+ // ----- Write the compressed (or not) content
+ @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
+
+ }
+
+ // ----- Look for a virtual file (a file from string)
+ } elseif ($p_filedescr['type'] == 'virtual_file') {
+
+ $v_content = $p_filedescr['content'];
+
+ // ----- Calculate the CRC
+ $p_header['crc'] = @crc32($v_content);
+
+ // ----- Look for no compression
+ if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
+ // ----- Set header parameters
+ $p_header['compressed_size'] = $p_header['size'];
+ $p_header['compression'] = 0;
+
+ // ----- Look for normal compression
+ } else {
+ // ----- Compress the content
+ $v_content = @gzdeflate($v_content);
+
+ // ----- Set header parameters
+ $p_header['compressed_size'] = strlen($v_content);
+ $p_header['compression'] = 8;
+ }
+
+ // ----- Call the header generation
+ if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
+ @fclose($v_file);
+
+ return $v_result;
+ }
+
+ // ----- Write the compressed (or not) content
+ @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
+
+ // ----- Look for a directory
+ } elseif ($p_filedescr['type'] == 'folder') {
+ // ----- Look for directory last '/'
+ if (@substr($p_header['stored_filename'], -1) != '/') {
+ $p_header['stored_filename'] .= '/';
+ }
+
+ // ----- Set the file properties
+ $p_header['size'] = 0;
+ //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked
+ $p_header['external'] = 0x00000010; // Value for a folder : to be checked
+
+ // ----- Call the header generation
+ if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
+ return $v_result;
+ }
+ }
+ }
+
+ // ----- Look for post-add callback
+ if (isset($p_options[PCLZIP_CB_POST_ADD])) {
+
+ // ----- Generate a local information
+ $v_local_header = array();
+ $this->privConvertHeader2FileInfo($p_header, $v_local_header);
+
+ // ----- Call the callback
+ // Here I do not use call_user_func() because I need to send a reference to the
+ // header.
+ // eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
+ $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
+ if ($v_result == 0) {
+ // ----- Ignored
+ $v_result = 1;
+ }
+
+ // ----- Update the informations
+ // Nothing can be modified
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privAddFileUsingTempFile()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
+ {
+ $v_result = PCLZIP_ERR_NO_ERROR;
+
+ // ----- Working variable
+ $p_filename = $p_filedescr['filename'];
+
+ // ----- Open the source file
+ if (($v_file = @fopen($p_filename, "rb")) == 0) {
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Creates a compressed temporary file
+ $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.gz';
+ if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
+ fclose($v_file);
+ PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary write mode');
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
+ $v_size = filesize($p_filename);
+ while ($v_size != 0) {
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = @fread($v_file, $v_read_size);
+ //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
+ @gzputs($v_file_compressed, $v_buffer, $v_read_size);
+ $v_size -= $v_read_size;
+ }
+
+ // ----- Close the file
+ @fclose($v_file);
+ @gzclose($v_file_compressed);
+
+ // ----- Check the minimum file size
+ if (filesize($v_gzip_temp_name) < 18) {
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \'' . $v_gzip_temp_name . '\' has invalid filesize - should be minimum 18 bytes');
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Extract the compressed attributes
+ if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary read mode');
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Read the gzip file header
+ $v_binary_data = @fread($v_file_compressed, 10);
+ $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
+
+ // ----- Check some parameters
+ $v_data_header['os'] = bin2hex($v_data_header['os']);
+
+ // ----- Read the gzip file footer
+ @fseek($v_file_compressed, filesize($v_gzip_temp_name) - 8);
+ $v_binary_data = @fread($v_file_compressed, 8);
+ $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
+
+ // ----- Set the attributes
+ $p_header['compression'] = ord($v_data_header['cm']);
+ //$p_header['mtime'] = $v_data_header['mtime'];
+ $p_header['crc'] = $v_data_footer['crc'];
+ $p_header['compressed_size'] = filesize($v_gzip_temp_name) - 18;
+
+ // ----- Close the file
+ @fclose($v_file_compressed);
+
+ // ----- Call the header generation
+ if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
+ return $v_result;
+ }
+
+ // ----- Add the compressed data
+ if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary read mode');
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
+ fseek($v_file_compressed, 10);
+ $v_size = $p_header['compressed_size'];
+ while ($v_size != 0) {
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = @fread($v_file_compressed, $v_read_size);
+ //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
+ @fwrite($this->zip_fd, $v_buffer, $v_read_size);
+ $v_size -= $v_read_size;
+ }
+
+ // ----- Close the file
+ @fclose($v_file_compressed);
+
+ // ----- Unlink the temporary file
+ @unlink($v_gzip_temp_name);
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privCalculateStoredFilename()
+ // Description :
+ // Based on file descriptor properties and global options, this method
+ // calculate the filename that will be stored in the archive.
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privCalculateStoredFilename(&$p_filedescr, &$p_options)
+ {
+ $v_result = 1;
+
+ // ----- Working variables
+ $p_filename = $p_filedescr['filename'];
+ if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
+ $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
+ } else {
+ $p_add_dir = '';
+ }
+ if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
+ $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
+ } else {
+ $p_remove_dir = '';
+ }
+ if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
+ $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
+ } else {
+ $p_remove_all_dir = 0;
+ }
+
+ // ----- Look for full name change
+ if (isset($p_filedescr['new_full_name'])) {
+ // ----- Remove drive letter if any
+ $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
+
+ // ----- Look for path and/or short name change
+ } else {
+
+ // ----- Look for short name change
+ // Its when we cahnge just the filename but not the path
+ if (isset($p_filedescr['new_short_name'])) {
+ $v_path_info = pathinfo($p_filename);
+ $v_dir = '';
+ if ($v_path_info['dirname'] != '') {
+ $v_dir = $v_path_info['dirname'] . '/';
+ }
+ $v_stored_filename = $v_dir . $p_filedescr['new_short_name'];
+ } else {
+ // ----- Calculate the stored filename
+ $v_stored_filename = $p_filename;
+ }
+
+ // ----- Look for all path to remove
+ if ($p_remove_all_dir) {
+ $v_stored_filename = basename($p_filename);
+
+ // ----- Look for partial path remove
+ } elseif ($p_remove_dir != "") {
+ if (substr($p_remove_dir, -1) != '/') {
+ $p_remove_dir .= "/";
+ }
+
+ if ((substr($p_filename, 0, 2) == "./") || (substr($p_remove_dir, 0, 2) == "./")) {
+
+ if ((substr($p_filename, 0, 2) == "./") && (substr($p_remove_dir, 0, 2) != "./")) {
+ $p_remove_dir = "./" . $p_remove_dir;
+ }
+ if ((substr($p_filename, 0, 2) != "./") && (substr($p_remove_dir, 0, 2) == "./")) {
+ $p_remove_dir = substr($p_remove_dir, 2);
+ }
+ }
+
+ $v_compare = PclZipUtilPathInclusion($p_remove_dir, $v_stored_filename);
+ if ($v_compare > 0) {
+ if ($v_compare == 2) {
+ $v_stored_filename = "";
+ } else {
+ $v_stored_filename = substr($v_stored_filename, strlen($p_remove_dir));
+ }
+ }
+ }
+
+ // ----- Remove drive letter if any
+ $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
+
+ // ----- Look for path to add
+ if ($p_add_dir != "") {
+ if (substr($p_add_dir, -1) == "/") {
+ $v_stored_filename = $p_add_dir . $v_stored_filename;
+ } else {
+ $v_stored_filename = $p_add_dir . "/" . $v_stored_filename;
+ }
+ }
+ }
+
+ // ----- Filename (reduce the path of stored name)
+ $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
+ $p_filedescr['stored_filename'] = $v_stored_filename;
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privWriteFileHeader()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privWriteFileHeader(&$p_header)
+ {
+ $v_result = 1;
+
+ // ----- Store the offset position of the file
+ $p_header['offset'] = ftell($this->zip_fd);
+
+ // ----- Transform UNIX mtime to DOS format mdate/mtime
+ $v_date = getdate($p_header['mtime']);
+ $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2;
+ $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday'];
+
+ // ----- Packed data
+ $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, $p_header['version_extracted'], $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], $p_header['compressed_size'], $p_header['size'], strlen($p_header['stored_filename']), $p_header['extra_len']);
+
+ // ----- Write the first 148 bytes of the header in the archive
+ fputs($this->zip_fd, $v_binary_data, 30);
+
+ // ----- Write the variable fields
+ if (strlen($p_header['stored_filename']) != 0) {
+ fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
+ }
+ if ($p_header['extra_len'] != 0) {
+ fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privWriteCentralFileHeader()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privWriteCentralFileHeader(&$p_header)
+ {
+ $v_result = 1;
+
+ // TBC
+ //for (reset($p_header); $key = key($p_header); next($p_header)) {
+ //}
+
+ // ----- Transform UNIX mtime to DOS format mdate/mtime
+ $v_date = getdate($p_header['mtime']);
+ $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2;
+ $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday'];
+
+ // ----- Packed data
+ $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, $p_header['version'], $p_header['version_extracted'], $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], $p_header['compressed_size'], $p_header['size'], strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'], $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']);
+
+ // ----- Write the 42 bytes of the header in the zip file
+ fputs($this->zip_fd, $v_binary_data, 46);
+
+ // ----- Write the variable fields
+ if (strlen($p_header['stored_filename']) != 0) {
+ fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
+ }
+ if ($p_header['extra_len'] != 0) {
+ fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
+ }
+ if ($p_header['comment_len'] != 0) {
+ fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privWriteCentralHeader()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
+ {
+ $v_result = 1;
+
+ // ----- Packed data
+ $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment));
+
+ // ----- Write the 22 bytes of the header in the zip file
+ fputs($this->zip_fd, $v_binary_data, 22);
+
+ // ----- Write the variable fields
+ if (strlen($p_comment) != 0) {
+ fputs($this->zip_fd, $p_comment, strlen($p_comment));
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privList()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privList(&$p_list)
+ {
+ $v_result = 1;
+
+ // ----- Magic quotes trick
+ $this->privDisableMagicQuotes();
+
+ // ----- Open the zip file
+ if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0) {
+ // ----- Magic quotes trick
+ $this->privSwapBackMagicQuotes();
+
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \'' . $this->zipname . '\' in binary read mode');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Read the central directory informations
+ $v_central_dir = array();
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) {
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result;
+ }
+
+ // ----- Go to beginning of Central Dir
+ @rewind($this->zip_fd);
+ if (@fseek($this->zip_fd, $v_central_dir['offset'])) {
+ $this->privSwapBackMagicQuotes();
+
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Read each entry
+ for ($i = 0; $i < $v_central_dir['entries']; $i++) {
+ // ----- Read the file header
+ if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) {
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result;
+ }
+ $v_header['index'] = $i;
+
+ // ----- Get the only interesting attributes
+ $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
+ unset($v_header);
+ }
+
+ // ----- Close the zip file
$this->privCloseFd();
+ // ----- Magic quotes trick
+ $this->privSwapBackMagicQuotes();
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privConvertHeader2FileInfo()
+ // Description :
+ // This function takes the file informations from the central directory
+ // entries and extract the interesting parameters that will be given back.
+ // The resulting file infos are set in the array $p_info
+ // $p_info['filename'] : Filename with full path. Given by user (add),
+ // extracted in the filesystem (extract).
+ // $p_info['stored_filename'] : Stored filename in the archive.
+ // $p_info['size'] = Size of the file.
+ // $p_info['compressed_size'] = Compressed size of the file.
+ // $p_info['mtime'] = Last modification date of the file.
+ // $p_info['comment'] = Comment associated with the file.
+ // $p_info['folder'] = true/false : indicates if the entry is a folder or not.
+ // $p_info['status'] = status of the action on the file.
+ // $p_info['crc'] = CRC of the file content.
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privConvertHeader2FileInfo($p_header, &$p_info)
+ {
+ $v_result = 1;
+
+ // ----- Get the interesting attributes
+ $v_temp_path = PclZipUtilPathReduction($p_header['filename']);
+ $p_info['filename'] = $v_temp_path;
+ $v_temp_path = PclZipUtilPathReduction($p_header['stored_filename']);
+ $p_info['stored_filename'] = $v_temp_path;
+ $p_info['size'] = $p_header['size'];
+ $p_info['compressed_size'] = $p_header['compressed_size'];
+ $p_info['mtime'] = $p_header['mtime'];
+ $p_info['comment'] = $p_header['comment'];
+ $p_info['folder'] = (($p_header['external'] & 0x00000010) == 0x00000010);
+ $p_info['index'] = $p_header['index'];
+ $p_info['status'] = $p_header['status'];
+ $p_info['crc'] = $p_header['crc'];
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privExtractByRule()
+ // Description :
+ // Extract a file or directory depending of rules (by index, by name, ...)
+ // Parameters :
+ // $p_file_list : An array where will be placed the properties of each
+ // extracted file
+ // $p_path : Path to add while writing the extracted files
+ // $p_remove_path : Path to remove (from the file memorized path) while writing the
+ // extracted files. If the path does not match the file path,
+ // the file is extracted with its memorized path.
+ // $p_remove_path does not apply to 'list' mode.
+ // $p_path and $p_remove_path are commulative.
+ // Return Values :
+ // 1 on success,0 or less on error (see error code list)
+ // --------------------------------------------------------------------------------
+ public function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
+ {
+ $v_result = 1;
+
+ // ----- Magic quotes trick
+ $this->privDisableMagicQuotes();
+
+ // ----- Check the path
+ if (($p_path == "") || ((substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../") && (substr($p_path, 1, 2) != ":/"))) {
+ $p_path = "./" . $p_path;
+ }
+
+ // ----- Reduce the path last (and duplicated) '/'
+ if (($p_path != "./") && ($p_path != "/")) {
+ // ----- Look for the path end '/'
+ while (substr($p_path, -1) == "/") {
+ $p_path = substr($p_path, 0, strlen($p_path) - 1);
+ }
+ }
+
+ // ----- Look for path to remove format (should end by /)
+ if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) {
+ $p_remove_path .= '/';
+ }
+ $p_remove_path_size = strlen($p_remove_path);
+
+ // ----- Open the zip file
+ if (($v_result = $this->privOpenFd('rb')) != 1) {
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result;
+ }
+
+ // ----- Read the central directory informations
+ $v_central_dir = array();
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) {
+ // ----- Close the zip file
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result;
+ }
+
+ // ----- Start at beginning of Central Dir
+ $v_pos_entry = $v_central_dir['offset'];
+
+ // ----- Read each entry
+ $j_start = 0;
+ for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) {
+
+ // ----- Read next Central dir entry
+ @rewind($this->zip_fd);
+ if (@fseek($this->zip_fd, $v_pos_entry)) {
+ // ----- Close the zip file
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Read the file header
+ $v_header = array();
+ if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1) {
+ // ----- Close the zip file
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result;
+ }
+
+ // ----- Store the index
+ $v_header['index'] = $i;
+
+ // ----- Store the file position
+ $v_pos_entry = ftell($this->zip_fd);
+
+ // ----- Look for the specific extract rules
+ $v_extract = false;
+
+ // ----- Look for extract by name rule
+ if ((isset($p_options[PCLZIP_OPT_BY_NAME])) && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
+
+ // ----- Look if the filename is in the list
+ for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
+
+ // ----- Look for a directory
+ if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
+
+ // ----- Look if the directory is in the filename path
+ if ((strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
+ $v_extract = true;
+ }
+
+ // ----- Look for a filename
+ } elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
+ $v_extract = true;
+ }
+ }
+ // ----- Look for extract by ereg rule
+ // ereg() is deprecated with PHP 5.3
+ /*
+ elseif ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
+ && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
+
+ if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
+ $v_extract = true;
+ }
+ }
+ */
+
+ // ----- Look for extract by preg rule
+ } elseif ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
+
+ if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
+ $v_extract = true;
+ }
+
+ // ----- Look for extract by index rule
+ } elseif ((isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
+
+ // ----- Look if the index is in the list
+ for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
+
+ if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
+ $v_extract = true;
+ }
+ if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
+ $j_start = $j + 1;
+ }
+
+ if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) {
+ break;
+ }
+ }
+
+ // ----- Look for no rule, which means extract all the archive
+ } else {
+ $v_extract = true;
+ }
+
+ // ----- Check compression method
+ if (($v_extract) && (($v_header['compression'] != 8) && ($v_header['compression'] != 0))) {
+ $v_header['status'] = 'unsupported_compression';
+
+ // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
+ if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
+
+ $this->privSwapBackMagicQuotes();
+
+ PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION, "Filename '" . $v_header['stored_filename'] . "' is " . "compressed by an unsupported compression " . "method (" . $v_header['compression'] . ") ");
+
+ return PclZip::errorCode();
+ }
+ }
+
+ // ----- Check encrypted files
+ if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
+ $v_header['status'] = 'unsupported_encryption';
+
+ // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
+ if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
+
+ $this->privSwapBackMagicQuotes();
+
+ PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, "Unsupported encryption for " . " filename '" . $v_header['stored_filename'] . "'");
+
+ return PclZip::errorCode();
+ }
+ }
+
+ // ----- Look for real extraction
+ if (($v_extract) && ($v_header['status'] != 'ok')) {
+ $v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++]);
+ if ($v_result != 1) {
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result;
+ }
+
+ $v_extract = false;
+ }
+
+ // ----- Look for real extraction
+ if ($v_extract) {
+
+ // ----- Go to the file position
+ @rewind($this->zip_fd);
+ if (@fseek($this->zip_fd, $v_header['offset'])) {
+ // ----- Close the zip file
+ $this->privCloseFd();
+
+ $this->privSwapBackMagicQuotes();
+
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Look for extraction as string
+ if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
+
+ $v_string = '';
+
+ // ----- Extracting the file
+ $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
+ if ($v_result1 < 1) {
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result1;
+ }
+
+ // ----- Get the only interesting attributes
+ if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) {
+ // ----- Close the zip file
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result;
+ }
+
+ // ----- Set the file content
+ $p_file_list[$v_nb_extracted]['content'] = $v_string;
+
+ // ----- Next extracted file
+ $v_nb_extracted++;
+
+ // ----- Look for user callback abort
+ if ($v_result1 == 2) {
+ break;
+ }
+
+ // ----- Look for extraction in standard output
+ } elseif ((isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
+ // ----- Extracting the file in standard output
+ $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
+ if ($v_result1 < 1) {
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result1;
+ }
+
+ // ----- Get the only interesting attributes
+ if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result;
+ }
+
+ // ----- Look for user callback abort
+ if ($v_result1 == 2) {
+ break;
+ }
+
+ // ----- Look for normal extraction
+ } else {
+ // ----- Extracting the file
+ $v_result1 = $this->privExtractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_options);
+ if ($v_result1 < 1) {
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result1;
+ }
+
+ // ----- Get the only interesting attributes
+ if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
+ // ----- Close the zip file
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ return $v_result;
+ }
+
+ // ----- Look for user callback abort
+ if ($v_result1 == 2) {
+ break;
+ }
+ }
+ }
+ }
+
+ // ----- Close the zip file
+ $this->privCloseFd();
+ $this->privSwapBackMagicQuotes();
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privExtractFile()
+ // Description :
+ // Parameters :
+ // Return Values :
+ //
+ // 1 : ... ?
+ // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
+ // --------------------------------------------------------------------------------
+ public function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
+ {
+ $v_result = 1;
+
+ // ----- Read the file header
+ if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Check that the file header is coherent with $p_entry info
+ if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
+ // TBC
+ }
+
+ // ----- Look for all path to remove
+ if ($p_remove_all_path == true) {
+ // ----- Look for folder entry that not need to be extracted
+ if (($p_entry['external'] & 0x00000010) == 0x00000010) {
+
+ $p_entry['status'] = "filtered";
+
+ return $v_result;
+ }
+
+ // ----- Get the basename of the path
+ $p_entry['filename'] = basename($p_entry['filename']);
+
+ // ----- Look for path to remove
+ } elseif ($p_remove_path != "") {
+ if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2) {
+
+ // ----- Change the file status
+ $p_entry['status'] = "filtered";
+
+ // ----- Return
+ return $v_result;
+ }
+
+ $p_remove_path_size = strlen($p_remove_path);
+ if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) {
+
+ // ----- Remove the path
+ $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
+
+ }
+ }
+
+ // ----- Add the path
+ if ($p_path != '') {
+ $p_entry['filename'] = $p_path . "/" . $p_entry['filename'];
+ }
+
+ // ----- Check a base_dir_restriction
+ if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
+ $v_inclusion = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION], $p_entry['filename']);
+ if ($v_inclusion == 0) {
+
+ PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION, "Filename '" . $p_entry['filename'] . "' is " . "outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
+
+ return PclZip::errorCode();
+ }
+ }
+
+ // ----- Look for pre-extract callback
+ if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
+
+ // ----- Generate a local information
+ $v_local_header = array();
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+ // ----- Call the callback
+ // Here I do not use call_user_func() because I need to send a reference to the
+ // header.
+ // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
+ $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
+ if ($v_result == 0) {
+ // ----- Change the file status
+ $p_entry['status'] = "skipped";
+ $v_result = 1;
+ }
+
+ // ----- Look for abort result
+ if ($v_result == 2) {
+ // ----- This status is internal and will be changed in 'skipped'
+ $p_entry['status'] = "aborted";
+ $v_result = PCLZIP_ERR_USER_ABORTED;
+ }
+
+ // ----- Update the informations
+ // Only some fields can be modified
+ $p_entry['filename'] = $v_local_header['filename'];
+ }
+
+ // ----- Look if extraction should be done
+ if ($p_entry['status'] == 'ok') {
+
+ // ----- Look for specific actions while the file exist
+ if (file_exists($p_entry['filename'])) {
+
+ // ----- Look if file is a directory
+ if (is_dir($p_entry['filename'])) {
+
+ // ----- Change the file status
+ $p_entry['status'] = "already_a_directory";
+
+ // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
+ // For historical reason first PclZip implementation does not stop
+ // when this kind of error occurs.
+ if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
+
+ PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY, "Filename '" . $p_entry['filename'] . "' is " . "already used by an existing directory");
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Look if file is write protected
+ } elseif (!is_writeable($p_entry['filename'])) {
+
+ // ----- Change the file status
+ $p_entry['status'] = "write_protected";
+
+ // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
+ // For historical reason first PclZip implementation does not stop
+ // when this kind of error occurs.
+ if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
+
+ PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Filename '" . $p_entry['filename'] . "' exists " . "and is write protected");
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Look if the extracted file is older
+ } elseif (filemtime($p_entry['filename']) > $p_entry['mtime']) {
+ // ----- Change the file status
+ if ((isset($p_options[PCLZIP_OPT_REPLACE_NEWER])) && ($p_options[PCLZIP_OPT_REPLACE_NEWER] === true)) {
+ } else {
+ $p_entry['status'] = "newer_exist";
+
+ // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
+ // For historical reason first PclZip implementation does not stop
+ // when this kind of error occurs.
+ if ((isset($p_options[PCLZIP_OPT_STOP_ON_ERROR])) && ($p_options[PCLZIP_OPT_STOP_ON_ERROR] === true)) {
+
+ PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Newer version of '" . $p_entry['filename'] . "' exists " . "and option PCLZIP_OPT_REPLACE_NEWER is not selected");
+
+ return PclZip::errorCode();
+ }
+ }
+ } else {
+ }
+
+ // ----- Check the directory availability and create it if necessary
+ } else {
+ if ((($p_entry['external'] & 0x00000010) == 0x00000010) || (substr($p_entry['filename'], -1) == '/')) {
+ $v_dir_to_check = $p_entry['filename'];
+ } elseif (!strstr($p_entry['filename'], "/")) {
+ $v_dir_to_check = "";
+ } else {
+ $v_dir_to_check = dirname($p_entry['filename']);
+ }
+
+ if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external'] & 0x00000010) == 0x00000010))) != 1) {
+
+ // ----- Change the file status
+ $p_entry['status'] = "path_creation_fail";
+
+ // ----- Return
+ //return $v_result;
+ $v_result = 1;
+ }
+ }
+ }
+
+ // ----- Look if extraction should be done
+ if ($p_entry['status'] == 'ok') {
+
+ // ----- Do the extraction (if not a folder)
+ if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) {
+ // ----- Look for not compressed file
+ if ($p_entry['compression'] == 0) {
+
+ // ----- Opening destination file
+ if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
+
+ // ----- Change the file status
+ $p_entry['status'] = "write_error";
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
+ $v_size = $p_entry['compressed_size'];
+ while ($v_size != 0) {
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = @fread($this->zip_fd, $v_read_size);
+ /* Try to speed up the code
+ $v_binary_data = pack('a'.$v_read_size, $v_buffer);
+ @fwrite($v_dest_file, $v_binary_data, $v_read_size);
+ */
+ @fwrite($v_dest_file, $v_buffer, $v_read_size);
+ $v_size -= $v_read_size;
+ }
+
+ // ----- Closing the destination file
+ fclose($v_dest_file);
+
+ // ----- Change the file mtime
+ touch($p_entry['filename'], $p_entry['mtime']);
+
+ } else {
+ // ----- TBC
+ // Need to be finished
+ if (($p_entry['flag'] & 1) == 1) {
+ PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \'' . $p_entry['filename'] . '\' is encrypted. Encrypted files are not supported.');
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Look for using temporary file to unzip
+ if ((!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON]) || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]) && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])))) {
+ $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
+ if ($v_result < PCLZIP_ERR_NO_ERROR) {
+ return $v_result;
+ }
+
+ // ----- Look for extract in memory
+ } else {
+
+ // ----- Read the compressed file in a buffer (one shot)
+ $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
+
+ // ----- Decompress the file
+ $v_file_content = @gzinflate($v_buffer);
+ unset($v_buffer);
+ if ($v_file_content === false) {
+
+ // ----- Change the file status
+ // TBC
+ $p_entry['status'] = "error";
+
+ return $v_result;
+ }
+
+ // ----- Opening destination file
+ if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
+
+ // ----- Change the file status
+ $p_entry['status'] = "write_error";
+
+ return $v_result;
+ }
+
+ // ----- Write the uncompressed data
+ @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
+ unset($v_file_content);
+
+ // ----- Closing the destination file
+ @fclose($v_dest_file);
+
+ }
+
+ // ----- Change the file mtime
+ @touch($p_entry['filename'], $p_entry['mtime']);
+ }
+
+ // ----- Look for chmod option
+ if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
+
+ // ----- Change the mode of the file
+ @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
+ }
+
+ }
+ }
+
+ // ----- Change abort status
+ if ($p_entry['status'] == "aborted") {
+ $p_entry['status'] = "skipped";
+
+ // ----- Look for post-extract callback
+ } elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
+
+ // ----- Generate a local information
+ $v_local_header = array();
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+ // ----- Call the callback
+ // Here I do not use call_user_func() because I need to send a reference to the
+ // header.
+ // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
+ $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
+
+ // ----- Look for abort result
+ if ($v_result == 2) {
+ $v_result = PCLZIP_ERR_USER_ABORTED;
+ }
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privExtractFileUsingTempFile()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privExtractFileUsingTempFile(&$p_entry, &$p_options)
+ {
+ $v_result = 1;
+
+ // ----- Creates a temporary file
+ $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.gz';
+ if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
+ fclose($v_file);
+ PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary write mode');
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Write gz file format header
+ $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
+ @fwrite($v_dest_file, $v_binary_data, 10);
+
+ // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
+ $v_size = $p_entry['compressed_size'];
+ while ($v_size != 0) {
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = @fread($this->zip_fd, $v_read_size);
+ //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
+ @fwrite($v_dest_file, $v_buffer, $v_read_size);
+ $v_size -= $v_read_size;
+ }
+
+ // ----- Write gz file format footer
+ $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);
+ @fwrite($v_dest_file, $v_binary_data, 8);
+
+ // ----- Close the temporary file
+ @fclose($v_dest_file);
+
+ // ----- Opening destination file
+ if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
+ $p_entry['status'] = "write_error";
+
+ return $v_result;
+ }
+
+ // ----- Open the temporary gz file
+ if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
+ @fclose($v_dest_file);
+ $p_entry['status'] = "read_error";
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_gzip_temp_name . '\' in binary read mode');
+
+ return PclZip::errorCode();
+ }
+
+ // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
+ $v_size = $p_entry['size'];
+ while ($v_size != 0) {
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = @gzread($v_src_file, $v_read_size);
+ //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
+ @fwrite($v_dest_file, $v_buffer, $v_read_size);
+ $v_size -= $v_read_size;
+ }
+ @fclose($v_dest_file);
+ @gzclose($v_src_file);
+
+ // ----- Delete the temporary file
+ @unlink($v_gzip_temp_name);
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privExtractFileInOutput()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privExtractFileInOutput(&$p_entry, &$p_options)
+ {
+ $v_result = 1;
+
+ // ----- Read the file header
+ if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
+ return $v_result;
+ }
+
+ // ----- Check that the file header is coherent with $p_entry info
+ if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
+ // TBC
+ }
+
+ // ----- Look for pre-extract callback
+ if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
+
+ // ----- Generate a local information
+ $v_local_header = array();
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+ // ----- Call the callback
+ // Here I do not use call_user_func() because I need to send a reference to the
+ // header.
+ // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
+ $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
+ if ($v_result == 0) {
+ // ----- Change the file status
+ $p_entry['status'] = "skipped";
+ $v_result = 1;
+ }
+
+ // ----- Look for abort result
+ if ($v_result == 2) {
+ // ----- This status is internal and will be changed in 'skipped'
+ $p_entry['status'] = "aborted";
+ $v_result = PCLZIP_ERR_USER_ABORTED;
+ }
+
+ // ----- Update the informations
+ // Only some fields can be modified
+ $p_entry['filename'] = $v_local_header['filename'];
+ }
+
+ // ----- Trace
+
+ // ----- Look if extraction should be done
+ if ($p_entry['status'] == 'ok') {
+
+ // ----- Do the extraction (if not a folder)
+ if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) {
+ // ----- Look for not compressed file
+ if ($p_entry['compressed_size'] == $p_entry['size']) {
+
+ // ----- Read the file in a buffer (one shot)
+ $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
+
+ // ----- Send the file to the output
+ echo $v_buffer;
+ unset($v_buffer);
+ } else {
+
+ // ----- Read the compressed file in a buffer (one shot)
+ $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
+
+ // ----- Decompress the file
+ $v_file_content = gzinflate($v_buffer);
+ unset($v_buffer);
+
+ // ----- Send the file to the output
+ echo $v_file_content;
+ unset($v_file_content);
+ }
+ }
+ }
+
+ // ----- Change abort status
+ if ($p_entry['status'] == "aborted") {
+ $p_entry['status'] = "skipped";
+
+ // ----- Look for post-extract callback
+ } elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
+
+ // ----- Generate a local information
+ $v_local_header = array();
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+ // ----- Call the callback
+ // Here I do not use call_user_func() because I need to send a reference to the
+ // header.
+ // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
+ $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
+
+ // ----- Look for abort result
+ if ($v_result == 2) {
+ $v_result = PCLZIP_ERR_USER_ABORTED;
+ }
+ }
+
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privExtractFileAsString()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
+ {
+ $v_result = 1;
+
+ // ----- Read the file header
+ $v_header = array();
+ if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Check that the file header is coherent with $p_entry info
+ if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
+ // TBC
+ }
+
+ // ----- Look for pre-extract callback
+ if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
+
+ // ----- Generate a local information
+ $v_local_header = array();
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+ // ----- Call the callback
+ // Here I do not use call_user_func() because I need to send a reference to the
+ // header.
+ // eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
+ $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
+ if ($v_result == 0) {
+ // ----- Change the file status
+ $p_entry['status'] = "skipped";
+ $v_result = 1;
+ }
+
+ // ----- Look for abort result
+ if ($v_result == 2) {
+ // ----- This status is internal and will be changed in 'skipped'
+ $p_entry['status'] = "aborted";
+ $v_result = PCLZIP_ERR_USER_ABORTED;
+ }
+
+ // ----- Update the informations
+ // Only some fields can be modified
+ $p_entry['filename'] = $v_local_header['filename'];
+ }
+
+ // ----- Look if extraction should be done
+ if ($p_entry['status'] == 'ok') {
+
+ // ----- Do the extraction (if not a folder)
+ if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) {
+ // ----- Look for not compressed file
+ // if ($p_entry['compressed_size'] == $p_entry['size'])
+ if ($p_entry['compression'] == 0) {
+
+ // ----- Reading the file
+ $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
+ } else {
+
+ // ----- Reading the file
+ $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
+
+ // ----- Decompress the file
+ if (($p_string = @gzinflate($v_data)) === false) {
+ // TBC
+ }
+ }
+
+ // ----- Trace
+ } else {
+ // TBC : error : can not extract a folder in a string
+ }
+
+ }
+
+ // ----- Change abort status
+ if ($p_entry['status'] == "aborted") {
+ $p_entry['status'] = "skipped";
+
+ // ----- Look for post-extract callback
+ } elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
+
+ // ----- Generate a local information
+ $v_local_header = array();
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+ // ----- Swap the content to header
+ $v_local_header['content'] = $p_string;
+ $p_string = '';
+
+ // ----- Call the callback
+ // Here I do not use call_user_func() because I need to send a reference to the
+ // header.
+ // eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
+ $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
+
+ // ----- Swap back the content to header
+ $p_string = $v_local_header['content'];
+ unset($v_local_header['content']);
+
+ // ----- Look for abort result
+ if ($v_result == 2) {
+ $v_result = PCLZIP_ERR_USER_ABORTED;
+ }
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privReadFileHeader()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privReadFileHeader(&$p_header)
+ {
+ $v_result = 1;
+
+ // ----- Read the 4 bytes signature
+ $v_binary_data = @fread($this->zip_fd, 4);
+ $v_data = unpack('Vid', $v_binary_data);
+
+ // ----- Check signature
+ if ($v_data['id'] != 0x04034b50) {
+
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Read the first 42 bytes of the header
+ $v_binary_data = fread($this->zip_fd, 26);
+
+ // ----- Look for invalid block size
+ if (strlen($v_binary_data) != 26) {
+ $p_header['filename'] = "";
+ $p_header['status'] = "invalid_header";
+
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : " . strlen($v_binary_data));
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Extract the values
+ $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
+
+ // ----- Get filename
+ $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
+
+ // ----- Get extra_fields
+ if ($v_data['extra_len'] != 0) {
+ $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
+ } else {
+ $p_header['extra'] = '';
+ }
+
+ // ----- Extract properties
+ $p_header['version_extracted'] = $v_data['version'];
+ $p_header['compression'] = $v_data['compression'];
+ $p_header['size'] = $v_data['size'];
+ $p_header['compressed_size'] = $v_data['compressed_size'];
+ $p_header['crc'] = $v_data['crc'];
+ $p_header['flag'] = $v_data['flag'];
+ $p_header['filename_len'] = $v_data['filename_len'];
+
+ // ----- Recuperate date in UNIX format
+ $p_header['mdate'] = $v_data['mdate'];
+ $p_header['mtime'] = $v_data['mtime'];
+ if ($p_header['mdate'] && $p_header['mtime']) {
+ // ----- Extract time
+ $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
+ $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
+ $v_seconde = ($p_header['mtime'] & 0x001F) * 2;
+
+ // ----- Extract date
+ $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
+ $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
+ $v_day = $p_header['mdate'] & 0x001F;
+
+ // ----- Get UNIX date format
+ $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
+
+ } else {
+ $p_header['mtime'] = time();
+ }
+
+ // TBC
+ //for (reset($v_data); $key = key($v_data); next($v_data)) {
+ //}
+
+ // ----- Set the stored filename
+ $p_header['stored_filename'] = $p_header['filename'];
+
+ // ----- Set the status field
+ $p_header['status'] = "ok";
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privReadCentralFileHeader()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privReadCentralFileHeader(&$p_header)
+ {
+ $v_result = 1;
+
+ // ----- Read the 4 bytes signature
+ $v_binary_data = @fread($this->zip_fd, 4);
+ $v_data = unpack('Vid', $v_binary_data);
+
+ // ----- Check signature
+ if ($v_data['id'] != 0x02014b50) {
+
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Read the first 42 bytes of the header
+ $v_binary_data = fread($this->zip_fd, 42);
+
+ // ----- Look for invalid block size
+ if (strlen($v_binary_data) != 42) {
+ $p_header['filename'] = "";
+ $p_header['status'] = "invalid_header";
+
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : " . strlen($v_binary_data));
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Extract the values
+ $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
+
+ // ----- Get filename
+ if ($p_header['filename_len'] != 0) {
+ $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
+ } else {
+ $p_header['filename'] = '';
+ }
+
+ // ----- Get extra
+ if ($p_header['extra_len'] != 0) {
+ $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
+ } else {
+ $p_header['extra'] = '';
+ }
+
+ // ----- Get comment
+ if ($p_header['comment_len'] != 0) {
+ $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
+ } else {
+ $p_header['comment'] = '';
+ }
+
+ // ----- Extract properties
+
+ // ----- Recuperate date in UNIX format
+ //if ($p_header['mdate'] && $p_header['mtime'])
+ // TBC : bug : this was ignoring time with 0/0/0
+ if (1) {
+ // ----- Extract time
+ $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
+ $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
+ $v_seconde = ($p_header['mtime'] & 0x001F) * 2;
+
+ // ----- Extract date
+ $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
+ $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
+ $v_day = $p_header['mdate'] & 0x001F;
+
+ // ----- Get UNIX date format
+ $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
+
+ } else {
+ $p_header['mtime'] = time();
+ }
+
+ // ----- Set the stored filename
+ $p_header['stored_filename'] = $p_header['filename'];
+
+ // ----- Set default status to ok
+ $p_header['status'] = 'ok';
+
+ // ----- Look if it is a directory
+ if (substr($p_header['filename'], -1) == '/') {
+ //$p_header['external'] = 0x41FF0010;
+ $p_header['external'] = 0x00000010;
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privCheckFileHeaders()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // 1 on success,
+ // 0 on error;
+ // --------------------------------------------------------------------------------
+ public function privCheckFileHeaders(&$p_local_header, &$p_central_header)
+ {
+ $v_result = 1;
+
+ // ----- Check the static values
+ // TBC
+ if ($p_local_header['filename'] != $p_central_header['filename']) {
+ }
+ if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
+ }
+ if ($p_local_header['flag'] != $p_central_header['flag']) {
+ }
+ if ($p_local_header['compression'] != $p_central_header['compression']) {
+ }
+ if ($p_local_header['mtime'] != $p_central_header['mtime']) {
+ }
+ if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
+ }
+
+ // ----- Look for flag bit 3
+ if (($p_local_header['flag'] & 8) == 8) {
+ $p_local_header['size'] = $p_central_header['size'];
+ $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
+ $p_local_header['crc'] = $p_central_header['crc'];
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privReadEndCentralDir()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privReadEndCentralDir(&$p_central_dir)
+ {
+ $v_result = 1;
+
+ // ----- Go to the end of the zip file
+ $v_size = filesize($this->zipname);
+ @fseek($this->zip_fd, $v_size);
+ if (@ftell($this->zip_fd) != $v_size) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \'' . $this->zipname . '\'');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- First try : look if this is an archive with no commentaries (most of the time)
+ // in this case the end of central dir is at 22 bytes of the file end
+ $v_found = 0;
+ if ($v_size > 26) {
+ @fseek($this->zip_fd, $v_size - 22);
+ if (($v_pos = @ftell($this->zip_fd)) != ($v_size - 22)) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \'' . $this->zipname . '\'');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Read for bytes
+ $v_binary_data = @fread($this->zip_fd, 4);
+ $v_data = @unpack('Vid', $v_binary_data);
+
+ // ----- Check signature
+ if ($v_data['id'] == 0x06054b50) {
+ $v_found = 1;
+ }
+
+ $v_pos = ftell($this->zip_fd);
+ }
+
+ // ----- Go back to the maximum possible size of the Central Dir End Record
+ if (!$v_found) {
+ $v_maximum_size = 65557; // 0xFFFF + 22;
+ if ($v_maximum_size > $v_size) {
+ $v_maximum_size = $v_size;
+ }
+ @fseek($this->zip_fd, $v_size - $v_maximum_size);
+ if (@ftell($this->zip_fd) != ($v_size - $v_maximum_size)) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \'' . $this->zipname . '\'');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Read byte per byte in order to find the signature
+ $v_pos = ftell($this->zip_fd);
+ $v_bytes = 0x00000000;
+ while ($v_pos < $v_size) {
+ // ----- Read a byte
+ $v_byte = @fread($this->zip_fd, 1);
+
+ // ----- Add the byte
+ //$v_bytes = ($v_bytes << 8) | Ord($v_byte);
+ // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
+ // Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
+ $v_bytes = (($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
+
+ // ----- Compare the bytes
+ if ($v_bytes == 0x504b0506) {
+ $v_pos++;
+ break;
+ }
+
+ $v_pos++;
+ }
+
+ // ----- Look if not found end of central dir
+ if ($v_pos == $v_size) {
+
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+ }
+
+ // ----- Read the first 18 bytes of the header
+ $v_binary_data = fread($this->zip_fd, 18);
+
+ // ----- Look for invalid block size
+ if (strlen($v_binary_data) != 18) {
+
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : " . strlen($v_binary_data));
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Extract the values
+ $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
+
+ // ----- Check the global size
+ if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
+
+ // ----- Removed in release 2.2 see readme file
+ // The check of the file size is a little too strict.
+ // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
+ // While decrypted, zip has training 0 bytes
+ if (0) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'The central dir is not at the end of the archive.' . ' Some trailing bytes exists after the archive.');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+ }
+
+ // ----- Get comment
+ if ($v_data['comment_size'] != 0) {
+ $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
+ } else {
+ $p_central_dir['comment'] = '';
+ }
+
+ $p_central_dir['entries'] = $v_data['entries'];
+ $p_central_dir['disk_entries'] = $v_data['disk_entries'];
+ $p_central_dir['offset'] = $v_data['offset'];
+ $p_central_dir['size'] = $v_data['size'];
+ $p_central_dir['disk'] = $v_data['disk'];
+ $p_central_dir['disk_start'] = $v_data['disk_start'];
+
+ // TBC
+ //for (reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
+ //}
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privDeleteByRule()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privDeleteByRule(&$p_result_list, &$p_options)
+ {
+ $v_result = 1;
+ $v_list_detail = array();
+
+ // ----- Open the zip file
+ if (($v_result = $this->privOpenFd('rb')) != 1) {
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Read the central directory informations
+ $v_central_dir = array();
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) {
+ $this->privCloseFd();
+
+ return $v_result;
+ }
+
+ // ----- Go to beginning of File
+ @rewind($this->zip_fd);
+
+ // ----- Scan all the files
+ // ----- Start at beginning of Central Dir
+ $v_pos_entry = $v_central_dir['offset'];
+ @rewind($this->zip_fd);
+ if (@fseek($this->zip_fd, $v_pos_entry)) {
+ // ----- Close the zip file
+ $this->privCloseFd();
+
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Read each entry
+ $v_header_list = array();
+ $j_start = 0;
+ for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) {
+
+ // ----- Read the file header
+ $v_header_list[$v_nb_extracted] = array();
+ if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) {
+ // ----- Close the zip file
+ $this->privCloseFd();
+
+ return $v_result;
+ }
+
+ // ----- Store the index
+ $v_header_list[$v_nb_extracted]['index'] = $i;
+
+ // ----- Look for the specific extract rules
+ $v_found = false;
+
+ // ----- Look for extract by name rule
+ if ((isset($p_options[PCLZIP_OPT_BY_NAME])) && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
+
+ // ----- Look if the filename is in the list
+ for ($j = 0; ($j < sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
+
+ // ----- Look for a directory
+ if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
+
+ // ----- Look if the directory is in the filename path
+ if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
+ $v_found = true;
+ } elseif ((($v_header_list[$v_nb_extracted]['external'] & 0x00000010) == 0x00000010) /* Indicates a folder */ && ($v_header_list[$v_nb_extracted]['stored_filename'] . '/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
+ $v_found = true;
+ }
+
+ // ----- Look for a filename
+ } elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
+ $v_found = true;
+ }
+ }
+
+ // ----- Look for extract by ereg rule
+ // ereg() is deprecated with PHP 5.3
+ /*
+ elseif ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
+ && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
+
+ if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
+ $v_found = true;
+ }
+ }
+ */
+
+ // ----- Look for extract by preg rule
+ } elseif ((isset($p_options[PCLZIP_OPT_BY_PREG])) && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
+
+ if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
+ $v_found = true;
+ }
+
+ // ----- Look for extract by index rule
+ } elseif ((isset($p_options[PCLZIP_OPT_BY_INDEX])) && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
+
+ // ----- Look if the index is in the list
+ for ($j = $j_start; ($j < sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
+
+ if (($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
+ $v_found = true;
+ }
+ if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
+ $j_start = $j + 1;
+ }
+
+ if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) {
+ break;
+ }
+ }
+ } else {
+ $v_found = true;
+ }
+
+ // ----- Look for deletion
+ if ($v_found) {
+ unset($v_header_list[$v_nb_extracted]);
+ } else {
+ $v_nb_extracted++;
+ }
+ }
+
+ // ----- Look if something need to be deleted
+ if ($v_nb_extracted > 0) {
+
+ // ----- Creates a temporay file
+ $v_zip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.tmp';
+
+ // ----- Creates a temporary zip archive
+ $v_temp_zip = new PclZip($v_zip_temp_name);
+
+ // ----- Open the temporary zip file in write mode
+ if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
+ $this->privCloseFd();
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Look which file need to be kept
+ for ($i = 0; $i < sizeof($v_header_list); $i++) {
+
+ // ----- Calculate the position of the header
+ @rewind($this->zip_fd);
+ if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
+ // ----- Close the zip file
+ $this->privCloseFd();
+ $v_temp_zip->privCloseFd();
+ @unlink($v_zip_temp_name);
+
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Read the file header
+ $v_local_header = array();
+ if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
+ // ----- Close the zip file
+ $this->privCloseFd();
+ $v_temp_zip->privCloseFd();
+ @unlink($v_zip_temp_name);
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Check that local file header is same as central file header
+ if ($this->privCheckFileHeaders($v_local_header, $v_header_list[$i]) != 1) {
+ // TBC
+ }
+ unset($v_local_header);
+
+ // ----- Write the file header
+ if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
+ // ----- Close the zip file
+ $this->privCloseFd();
+ $v_temp_zip->privCloseFd();
+ @unlink($v_zip_temp_name);
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Read/write the data block
+ if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
+ // ----- Close the zip file
+ $this->privCloseFd();
+ $v_temp_zip->privCloseFd();
+ @unlink($v_zip_temp_name);
+
+ // ----- Return
+ return $v_result;
+ }
+ }
+
+ // ----- Store the offset of the central dir
+ $v_offset = @ftell($v_temp_zip->zip_fd);
+
+ // ----- Re-Create the Central Dir files header
+ for ($i = 0; $i < sizeof($v_header_list); $i++) {
+ // ----- Create the file header
+ if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
+ $v_temp_zip->privCloseFd();
+ $this->privCloseFd();
+ @unlink($v_zip_temp_name);
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Transform the header to a 'usable' info
+ $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
+ }
+
+ // ----- Zip file comment
+ $v_comment = '';
+ if (isset($p_options[PCLZIP_OPT_COMMENT])) {
+ $v_comment = $p_options[PCLZIP_OPT_COMMENT];
+ }
+
+ // ----- Calculate the size of the central header
+ $v_size = @ftell($v_temp_zip->zip_fd) - $v_offset;
+
+ // ----- Create the central dir footer
+ if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
+ // ----- Reset the file list
+ unset($v_header_list);
+ $v_temp_zip->privCloseFd();
+ $this->privCloseFd();
+ @unlink($v_zip_temp_name);
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Close
+ $v_temp_zip->privCloseFd();
+ $this->privCloseFd();
+
+ // ----- Delete the zip file
+ // TBC : I should test the result ...
+ @unlink($this->zipname);
+
+ // ----- Rename the temporary file
+ // TBC : I should test the result ...
+ //@rename($v_zip_temp_name, $this->zipname);
+ PclZipUtilRename($v_zip_temp_name, $this->zipname);
+
+ // ----- Destroy the temporary archive
+ unset($v_temp_zip);
+
+ // ----- Remove every files : reset the file
+ } elseif ($v_central_dir['entries'] != 0) {
+ $this->privCloseFd();
+
+ if (($v_result = $this->privOpenFd('wb')) != 1) {
+ return $v_result;
+ }
+
+ if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
+ return $v_result;
+ }
+
+ $this->privCloseFd();
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privDirCheck()
+ // Description :
+ // Check if a directory exists, if not it creates it and all the parents directory
+ // which may be useful.
+ // Parameters :
+ // $p_dir : Directory path to check.
+ // Return Values :
+ // 1 : OK
+ // -1 : Unable to create directory
+ // --------------------------------------------------------------------------------
+ public function privDirCheck($p_dir, $p_is_dir = false)
+ {
+ $v_result = 1;
+
+ // ----- Remove the final '/'
+ if (($p_is_dir) && (substr($p_dir, -1) == '/')) {
+ $p_dir = substr($p_dir, 0, strlen($p_dir) - 1);
+ }
+
+ // ----- Check the directory availability
+ if ((is_dir($p_dir)) || ($p_dir == "")) {
+ return 1;
+ }
+
+ // ----- Extract parent directory
+ $p_parent_dir = dirname($p_dir);
+
+ // ----- Just a check
+ if ($p_parent_dir != $p_dir) {
+ // ----- Look for parent directory
+ if ($p_parent_dir != "") {
+ if (($v_result = $this->privDirCheck($p_parent_dir)) != 1) {
+ return $v_result;
+ }
+ }
+ }
+
+ // ----- Create the directory
+ if (!@mkdir($p_dir, 0777)) {
+ // ----- Error log
+ PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privMerge()
+ // Description :
+ // If $p_archive_to_add does not exist, the function exit with a success result.
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privMerge(&$p_archive_to_add)
+ {
+ $v_result = 1;
+
+ // ----- Look if the archive_to_add exists
+ if (!is_file($p_archive_to_add->zipname)) {
+
+ // ----- Nothing to merge, so merge is a success
+ $v_result = 1;
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Look if the archive exists
+ if (!is_file($this->zipname)) {
+
+ // ----- Do a duplicate
+ $v_result = $this->privDuplicate($p_archive_to_add->zipname);
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Open the zip file
+ if (($v_result = $this->privOpenFd('rb')) != 1) {
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Read the central directory informations
+ $v_central_dir = array();
+ if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) {
+ $this->privCloseFd();
+
+ return $v_result;
+ }
+
+ // ----- Go to beginning of File
+ @rewind($this->zip_fd);
+
+ // ----- Open the archive_to_add file
+ if (($v_result = $p_archive_to_add->privOpenFd('rb')) != 1) {
+ $this->privCloseFd();
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Read the central directory informations
+ $v_central_dir_to_add = array();
+ if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1) {
+ $this->privCloseFd();
+ $p_archive_to_add->privCloseFd();
+
+ return $v_result;
+ }
+
+ // ----- Go to beginning of File
+ @rewind($p_archive_to_add->zip_fd);
+
+ // ----- Creates a temporay file
+ $v_zip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.tmp';
+
+ // ----- Open the temporary file in write mode
+ if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) {
+ $this->privCloseFd();
+ $p_archive_to_add->privCloseFd();
+
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \'' . $v_zip_temp_name . '\' in binary write mode');
+
+ // ----- Return
+ return PclZip::errorCode();
+ }
+
+ // ----- Copy the files from the archive to the temporary file
+ // TBC : Here I should better append the file and go back to erase the central dir
+ $v_size = $v_central_dir['offset'];
+ while ($v_size != 0) {
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = fread($this->zip_fd, $v_read_size);
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+ $v_size -= $v_read_size;
+ }
+
+ // ----- Copy the files from the archive_to_add into the temporary file
+ $v_size = $v_central_dir_to_add['offset'];
+ while ($v_size != 0) {
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+ $v_size -= $v_read_size;
+ }
+
+ // ----- Store the offset of the central dir
+ $v_offset = @ftell($v_zip_temp_fd);
+
+ // ----- Copy the block of file headers from the old archive
+ $v_size = $v_central_dir['size'];
+ while ($v_size != 0) {
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = @fread($this->zip_fd, $v_read_size);
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+ $v_size -= $v_read_size;
+ }
+
+ // ----- Copy the block of file headers from the archive_to_add
+ $v_size = $v_central_dir_to_add['size'];
+ while ($v_size != 0) {
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
+ @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
+ $v_size -= $v_read_size;
+ }
+
+ // ----- Merge the file comments
+ $v_comment = $v_central_dir['comment'] . ' ' . $v_central_dir_to_add['comment'];
+
+ // ----- Calculate the size of the (new) central header
+ $v_size = @ftell($v_zip_temp_fd) - $v_offset;
+
+ // ----- Swap the file descriptor
+ // Here is a trick : I swap the temporary fd with the zip fd, in order to use
+ // the following methods on the temporary fil and not the real archive fd
+ $v_swap = $this->zip_fd;
+ $this->zip_fd = $v_zip_temp_fd;
+ $v_zip_temp_fd = $v_swap;
+
+ // ----- Create the central dir footer
+ if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries'] + $v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1) {
+ $this->privCloseFd();
+ $p_archive_to_add->privCloseFd();
+ @fclose($v_zip_temp_fd);
+ $this->zip_fd = null;
+
+ // ----- Reset the file list
+ unset($v_header_list);
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Swap back the file descriptor
+ $v_swap = $this->zip_fd;
+ $this->zip_fd = $v_zip_temp_fd;
+ $v_zip_temp_fd = $v_swap;
+
+ // ----- Close
+ $this->privCloseFd();
+ $p_archive_to_add->privCloseFd();
+
+ // ----- Close the temporary file
+ @fclose($v_zip_temp_fd);
+
+ // ----- Delete the zip file
+ // TBC : I should test the result ...
+ @unlink($this->zipname);
+
+ // ----- Rename the temporary file
+ // TBC : I should test the result ...
+ //@rename($v_zip_temp_name, $this->zipname);
+ PclZipUtilRename($v_zip_temp_name, $this->zipname);
+
+ // ----- Return
+ return $v_result;
+ }
+ // --------------------------------------------------------------------------------
+
+ // --------------------------------------------------------------------------------
+ // Function : privDuplicate()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privDuplicate($p_archive_filename)
+ {
+ $v_result = 1;
+
+ // ----- Look if the $p_archive_filename exists
+ if (!is_file($p_archive_filename)) {
+
+ // ----- Nothing to duplicate, so duplicate is a success.
+ $v_result = 1;
+
+ // ----- Return
+ return $v_result;
+ }
+
+ // ----- Open the zip file
if (($v_result = $this->privOpenFd('wb')) != 1) {
- return $v_result;
+ // ----- Return
+ return $v_result;
}
- if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
- return $v_result;
+ // ----- Open the temporary file in write mode
+ if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) {
+ $this->privCloseFd();
+
+ PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \'' . $p_archive_filename . '\' in binary write mode');
+
+ // ----- Return
+ return PclZip::errorCode();
}
+ // ----- Copy the files from the archive to the temporary file
+ // TBC : Here I should better append the file and go back to erase the central dir
+ $v_size = filesize($p_archive_filename);
+ while ($v_size != 0) {
+ $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = fread($v_zip_temp_fd, $v_read_size);
+ @fwrite($this->zip_fd, $v_buffer, $v_read_size);
+ $v_size -= $v_read_size;
+ }
+
+ // ----- Close
$this->privCloseFd();
+
+ // ----- Close the temporary file
+ @fclose($v_zip_temp_fd);
+
+ // ----- Return
+ return $v_result;
}
+ // --------------------------------------------------------------------------------
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privDirCheck()
- // Description :
- // Check if a directory exists, if not it creates it and all the parents directory
- // which may be useful.
- // Parameters :
- // $p_dir : Directory path to check.
- // Return Values :
- // 1 : OK
- // -1 : Unable to create directory
- // --------------------------------------------------------------------------------
- function privDirCheck($p_dir, $p_is_dir=false)
- {
- $v_result = 1;
-
-
- // ----- Remove the final '/'
- if (($p_is_dir) && (substr($p_dir, -1)=='/'))
+ // --------------------------------------------------------------------------------
+ // Function : privErrorLog()
+ // Description :
+ // Parameters :
+ // --------------------------------------------------------------------------------
+ public function privErrorLog($p_error_code = 0, $p_error_string = '')
{
- $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
- }
-
- // ----- Check the directory availability
- if ((is_dir($p_dir)) || ($p_dir == ""))
- {
- return 1;
- }
-
- // ----- Extract parent directory
- $p_parent_dir = dirname($p_dir);
-
- // ----- Just a check
- if ($p_parent_dir != $p_dir)
- {
- // ----- Look for parent directory
- if ($p_parent_dir != "")
- {
- if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
- {
- return $v_result;
+ if (PCLZIP_ERROR_EXTERNAL == 1) {
+ PclError($p_error_code, $p_error_string);
+ } else {
+ $this->error_code = $p_error_code;
+ $this->error_string = $p_error_string;
}
- }
}
+ // --------------------------------------------------------------------------------
- // ----- Create the directory
- if (!@mkdir($p_dir, 0777))
+ // --------------------------------------------------------------------------------
+ // Function : privErrorReset()
+ // Description :
+ // Parameters :
+ // --------------------------------------------------------------------------------
+ public function privErrorReset()
{
- // ----- Error log
- PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
-
- // ----- Return
- return PclZip::errorCode();
+ if (PCLZIP_ERROR_EXTERNAL == 1) {
+ PclErrorReset();
+ } else {
+ $this->error_code = 0;
+ $this->error_string = '';
+ }
}
+ // --------------------------------------------------------------------------------
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privMerge()
- // Description :
- // If $p_archive_to_add does not exist, the function exit with a success result.
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privMerge(&$p_archive_to_add)
- {
- $v_result=1;
-
- // ----- Look if the archive_to_add exists
- if (!is_file($p_archive_to_add->zipname))
+ // --------------------------------------------------------------------------------
+ // Function : privDisableMagicQuotes()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privDisableMagicQuotes()
{
+ $v_result = 1;
- // ----- Nothing to merge, so merge is a success
- $v_result = 1;
+ // ----- Look if function exists
+ if ((!function_exists("get_magic_quotes_runtime")) || (!function_exists("set_magic_quotes_runtime"))) {
+ return $v_result;
+ }
- // ----- Return
- return $v_result;
+ // ----- Look if already done
+ if ($this->magic_quotes_status != -1) {
+ return $v_result;
+ }
+
+ // ----- Get and memorize the magic_quote value
+ $this->magic_quotes_status = @get_magic_quotes_runtime();
+
+ // ----- Disable magic_quotes
+ if ($this->magic_quotes_status == 1) {
+ @set_magic_quotes_runtime(0);
+ }
+
+ // ----- Return
+ return $v_result;
}
+ // --------------------------------------------------------------------------------
- // ----- Look if the archive exists
- if (!is_file($this->zipname))
+ // --------------------------------------------------------------------------------
+ // Function : privSwapBackMagicQuotes()
+ // Description :
+ // Parameters :
+ // Return Values :
+ // --------------------------------------------------------------------------------
+ public function privSwapBackMagicQuotes()
{
+ $v_result = 1;
- // ----- Do a duplicate
- $v_result = $this->privDuplicate($p_archive_to_add->zipname);
+ // ----- Look if function exists
+ if ((!function_exists("get_magic_quotes_runtime")) || (!function_exists("set_magic_quotes_runtime"))) {
+ return $v_result;
+ }
- // ----- Return
- return $v_result;
+ // ----- Look if something to do
+ if ($this->magic_quotes_status != -1) {
+ return $v_result;
+ }
+
+ // ----- Swap back magic_quotes
+ if ($this->magic_quotes_status == 1) {
+ @set_magic_quotes_runtime($this->magic_quotes_status);
+ }
+
+ // ----- Return
+ return $v_result;
}
+ // --------------------------------------------------------------------------------
+}
- // ----- Open the zip file
- if (($v_result=$this->privOpenFd('rb')) != 1)
- {
- // ----- Return
- return $v_result;
- }
+// End of class
+// --------------------------------------------------------------------------------
- // ----- Read the central directory informations
- $v_central_dir = array();
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
- {
- $this->privCloseFd();
- return $v_result;
- }
-
- // ----- Go to beginning of File
- @rewind($this->zip_fd);
-
- // ----- Open the archive_to_add file
- if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
- {
- $this->privCloseFd();
-
- // ----- Return
- return $v_result;
- }
-
- // ----- Read the central directory informations
- $v_central_dir_to_add = array();
- if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
- {
- $this->privCloseFd();
- $p_archive_to_add->privCloseFd();
-
- return $v_result;
- }
-
- // ----- Go to beginning of File
- @rewind($p_archive_to_add->zip_fd);
-
- // ----- Creates a temporay file
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
-
- // ----- Open the temporary file in write mode
- if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
- {
- $this->privCloseFd();
- $p_archive_to_add->privCloseFd();
-
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Copy the files from the archive to the temporary file
- // TBC : Here I should better append the file and go back to erase the central dir
- $v_size = $v_central_dir['offset'];
- while ($v_size != 0)
- {
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = fread($this->zip_fd, $v_read_size);
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
- $v_size -= $v_read_size;
- }
-
- // ----- Copy the files from the archive_to_add into the temporary file
- $v_size = $v_central_dir_to_add['offset'];
- while ($v_size != 0)
- {
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
- $v_size -= $v_read_size;
- }
-
- // ----- Store the offset of the central dir
- $v_offset = @ftell($v_zip_temp_fd);
-
- // ----- Copy the block of file headers from the old archive
- $v_size = $v_central_dir['size'];
- while ($v_size != 0)
- {
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = @fread($this->zip_fd, $v_read_size);
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
- $v_size -= $v_read_size;
- }
-
- // ----- Copy the block of file headers from the archive_to_add
- $v_size = $v_central_dir_to_add['size'];
- while ($v_size != 0)
- {
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
- $v_size -= $v_read_size;
- }
-
- // ----- Merge the file comments
- $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
-
- // ----- Calculate the size of the (new) central header
- $v_size = @ftell($v_zip_temp_fd)-$v_offset;
-
- // ----- Swap the file descriptor
- // Here is a trick : I swap the temporary fd with the zip fd, in order to use
- // the following methods on the temporary fil and not the real archive fd
- $v_swap = $this->zip_fd;
- $this->zip_fd = $v_zip_temp_fd;
- $v_zip_temp_fd = $v_swap;
-
- // ----- Create the central dir footer
- if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
- {
- $this->privCloseFd();
- $p_archive_to_add->privCloseFd();
- @fclose($v_zip_temp_fd);
- $this->zip_fd = null;
-
- // ----- Reset the file list
- unset($v_header_list);
-
- // ----- Return
- return $v_result;
- }
-
- // ----- Swap back the file descriptor
- $v_swap = $this->zip_fd;
- $this->zip_fd = $v_zip_temp_fd;
- $v_zip_temp_fd = $v_swap;
-
- // ----- Close
- $this->privCloseFd();
- $p_archive_to_add->privCloseFd();
-
- // ----- Close the temporary file
- @fclose($v_zip_temp_fd);
-
- // ----- Delete the zip file
- // TBC : I should test the result ...
- @unlink($this->zipname);
-
- // ----- Rename the temporary file
- // TBC : I should test the result ...
- //@rename($v_zip_temp_name, $this->zipname);
- PclZipUtilRename($v_zip_temp_name, $this->zipname);
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privDuplicate()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privDuplicate($p_archive_filename)
- {
- $v_result=1;
-
- // ----- Look if the $p_archive_filename exists
- if (!is_file($p_archive_filename))
- {
-
- // ----- Nothing to duplicate, so duplicate is a success.
- $v_result = 1;
-
- // ----- Return
- return $v_result;
- }
-
- // ----- Open the zip file
- if (($v_result=$this->privOpenFd('wb')) != 1)
- {
- // ----- Return
- return $v_result;
- }
-
- // ----- Open the temporary file in write mode
- if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
- {
- $this->privCloseFd();
-
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
-
- // ----- Return
- return PclZip::errorCode();
- }
-
- // ----- Copy the files from the archive to the temporary file
- // TBC : Here I should better append the file and go back to erase the central dir
- $v_size = filesize($p_archive_filename);
- while ($v_size != 0)
- {
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = fread($v_zip_temp_fd, $v_read_size);
- @fwrite($this->zip_fd, $v_buffer, $v_read_size);
- $v_size -= $v_read_size;
- }
-
- // ----- Close
- $this->privCloseFd();
-
- // ----- Close the temporary file
- @fclose($v_zip_temp_fd);
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privErrorLog()
- // Description :
- // Parameters :
- // --------------------------------------------------------------------------------
- function privErrorLog($p_error_code=0, $p_error_string='')
- {
- if (PCLZIP_ERROR_EXTERNAL == 1) {
- PclError($p_error_code, $p_error_string);
- }
- else {
- $this->error_code = $p_error_code;
- $this->error_string = $p_error_string;
- }
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privErrorReset()
- // Description :
- // Parameters :
- // --------------------------------------------------------------------------------
- function privErrorReset()
- {
- if (PCLZIP_ERROR_EXTERNAL == 1) {
- PclErrorReset();
- }
- else {
- $this->error_code = 0;
- $this->error_string = '';
- }
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privDisableMagicQuotes()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privDisableMagicQuotes()
- {
- $v_result=1;
-
- // ----- Look if function exists
- if ( (!function_exists("get_magic_quotes_runtime"))
- || (!function_exists("set_magic_quotes_runtime"))) {
- return $v_result;
- }
-
- // ----- Look if already done
- if ($this->magic_quotes_status != -1) {
- return $v_result;
- }
-
- // ----- Get and memorize the magic_quote value
- $this->magic_quotes_status = @get_magic_quotes_runtime();
-
- // ----- Disable magic_quotes
- if ($this->magic_quotes_status == 1) {
- @set_magic_quotes_runtime(0);
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : privSwapBackMagicQuotes()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function privSwapBackMagicQuotes()
- {
- $v_result=1;
-
- // ----- Look if function exists
- if ( (!function_exists("get_magic_quotes_runtime"))
- || (!function_exists("set_magic_quotes_runtime"))) {
- return $v_result;
- }
-
- // ----- Look if something to do
- if ($this->magic_quotes_status != -1) {
- return $v_result;
- }
-
- // ----- Swap back magic_quotes
- if ($this->magic_quotes_status == 1) {
- @set_magic_quotes_runtime($this->magic_quotes_status);
- }
-
- // ----- Return
- return $v_result;
- }
- // --------------------------------------------------------------------------------
-
- }
- // End of class
- // --------------------------------------------------------------------------------
-
- // --------------------------------------------------------------------------------
- // Function : PclZipUtilPathReduction()
- // Description :
- // Parameters :
- // Return Values :
- // --------------------------------------------------------------------------------
- function PclZipUtilPathReduction($p_dir)
- {
+// --------------------------------------------------------------------------------
+// Function : PclZipUtilPathReduction()
+// Description :
+// Parameters :
+// Return Values :
+// --------------------------------------------------------------------------------
+function PclZipUtilPathReduction($p_dir)
+{
$v_result = "";
// ----- Look for not empty path
if ($p_dir != "") {
- // ----- Explode path by directory names
- $v_list = explode("/", $p_dir);
+ // ----- Explode path by directory names
+ $v_list = explode("/", $p_dir);
- // ----- Study directories from last to first
- $v_skip = 0;
- for ($i=sizeof($v_list)-1; $i>=0; $i--) {
- // ----- Look for current path
- if ($v_list[$i] == ".") {
- // ----- Ignore this directory
- // Should be the first $i=0, but no check is done
- }
- else if ($v_list[$i] == "..") {
- $v_skip++;
- }
- else if ($v_list[$i] == "") {
- // ----- First '/' i.e. root slash
- if ($i == 0) {
- $v_result = "/".$v_result;
- if ($v_skip > 0) {
- // ----- It is an invalid path, so the path is not modified
- // TBC
- $v_result = $p_dir;
- $v_skip = 0;
+ // ----- Study directories from last to first
+ $v_skip = 0;
+ for ($i = sizeof($v_list) - 1; $i >= 0; $i--) {
+ // ----- Look for current path
+ if ($v_list[$i] == ".") {
+ // ----- Ignore this directory
+ // Should be the first $i=0, but no check is done
+ } elseif ($v_list[$i] == "..") {
+ $v_skip++;
+ } elseif ($v_list[$i] == "") {
+ // ----- First '/' i.e. root slash
+ if ($i == 0) {
+ $v_result = "/" . $v_result;
+ if ($v_skip > 0) {
+ // ----- It is an invalid path, so the path is not modified
+ // TBC
+ $v_result = $p_dir;
+ $v_skip = 0;
+ }
+
+ // ----- Last '/' i.e. indicates a directory
+ } elseif ($i == (sizeof($v_list) - 1)) {
+ $v_result = $v_list[$i];
+
+ // ----- Double '/' inside the path
+ } else {
+ // ----- Ignore only the double '//' in path,
+ // but not the first and last '/'
+ }
+ } else {
+ // ----- Look for item to skip
+ if ($v_skip > 0) {
+ $v_skip--;
+ } else {
+ $v_result = $v_list[$i] . ($i != (sizeof($v_list) - 1) ? "/" . $v_result : "");
+ }
}
- }
- // ----- Last '/' i.e. indicates a directory
- else if ($i == (sizeof($v_list)-1)) {
- $v_result = $v_list[$i];
- }
- // ----- Double '/' inside the path
- else {
- // ----- Ignore only the double '//' in path,
- // but not the first and last '/'
- }
}
- else {
- // ----- Look for item to skip
- if ($v_skip > 0) {
- $v_skip--;
- }
- else {
- $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
- }
- }
- }
- // ----- Look for skip
- if ($v_skip > 0) {
- while ($v_skip > 0) {
- $v_result = '../'.$v_result;
- $v_skip--;
+ // ----- Look for skip
+ if ($v_skip > 0) {
+ while ($v_skip > 0) {
+ $v_result = '../' . $v_result;
+ $v_skip--;
+ }
}
- }
}
// ----- Return
return $v_result;
- }
- // --------------------------------------------------------------------------------
+}
+// --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : PclZipUtilPathInclusion()
- // Description :
- // This function indicates if the path $p_path is under the $p_dir tree. Or,
- // said in an other way, if the file or sub-dir $p_path is inside the dir
- // $p_dir.
- // The function indicates also if the path is exactly the same as the dir.
- // This function supports path with duplicated '/' like '//', but does not
- // support '.' or '..' statements.
- // Parameters :
- // Return Values :
- // 0 if $p_path is not inside directory $p_dir
- // 1 if $p_path is inside directory $p_dir
- // 2 if $p_path is exactly the same as $p_dir
- // --------------------------------------------------------------------------------
- function PclZipUtilPathInclusion($p_dir, $p_path)
- {
+// --------------------------------------------------------------------------------
+// Function : PclZipUtilPathInclusion()
+// Description :
+// This function indicates if the path $p_path is under the $p_dir tree. Or,
+// said in an other way, if the file or sub-dir $p_path is inside the dir
+// $p_dir.
+// The function indicates also if the path is exactly the same as the dir.
+// This function supports path with duplicated '/' like '//', but does not
+// support '.' or '..' statements.
+// Parameters :
+// Return Values :
+// 0 if $p_path is not inside directory $p_dir
+// 1 if $p_path is inside directory $p_dir
+// 2 if $p_path is exactly the same as $p_dir
+// --------------------------------------------------------------------------------
+function PclZipUtilPathInclusion($p_dir, $p_path)
+{
$v_result = 1;
// ----- Look for path beginning by ./
- if ( ($p_dir == '.')
- || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
- $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
+ if (($p_dir == '.') || ((strlen($p_dir) >= 2) && (substr($p_dir, 0, 2) == './'))) {
+ $p_dir = PclZipUtilTranslateWinPath(getcwd(), false) . '/' . substr($p_dir, 1);
}
- if ( ($p_path == '.')
- || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
- $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
+ if (($p_path == '.') || ((strlen($p_path) >= 2) && (substr($p_path, 0, 2) == './'))) {
+ $p_path = PclZipUtilTranslateWinPath(getcwd(), false) . '/' . substr($p_path, 1);
}
// ----- Explode dir and path by directory separator
- $v_list_dir = explode("/", $p_dir);
- $v_list_dir_size = sizeof($v_list_dir);
- $v_list_path = explode("/", $p_path);
+ $v_list_dir = explode("/", $p_dir);
+ $v_list_dir_size = sizeof($v_list_dir);
+ $v_list_path = explode("/", $p_path);
$v_list_path_size = sizeof($v_list_path);
// ----- Study directories paths
@@ -5499,193 +5234,182 @@
$j = 0;
while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
- // ----- Look for empty dir (path reduction)
- if ($v_list_dir[$i] == '') {
+ // ----- Look for empty dir (path reduction)
+ if ($v_list_dir[$i] == '') {
+ $i++;
+ continue;
+ }
+ if ($v_list_path[$j] == '') {
+ $j++;
+ continue;
+ }
+
+ // ----- Compare the items
+ if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ($v_list_path[$j] != '')) {
+ $v_result = 0;
+ }
+
+ // ----- Next items
$i++;
- continue;
- }
- if ($v_list_path[$j] == '') {
$j++;
- continue;
- }
-
- // ----- Compare the items
- if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
- $v_result = 0;
- }
-
- // ----- Next items
- $i++;
- $j++;
}
// ----- Look if everything seems to be the same
if ($v_result) {
- // ----- Skip all the empty items
- while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
- while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
+ // ----- Skip all the empty items
+ while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) {
+ $j++;
+ }
+ while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) {
+ $i++;
+ }
- if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
- // ----- There are exactly the same
- $v_result = 2;
- }
- else if ($i < $v_list_dir_size) {
- // ----- The path is shorter than the dir
- $v_result = 0;
- }
+ if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
+ // ----- There are exactly the same
+ $v_result = 2;
+ } elseif ($i < $v_list_dir_size) {
+ // ----- The path is shorter than the dir
+ $v_result = 0;
+ }
}
// ----- Return
return $v_result;
- }
- // --------------------------------------------------------------------------------
+}
+// --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : PclZipUtilCopyBlock()
- // Description :
- // Parameters :
- // $p_mode : read/write compression mode
- // 0 : src & dest normal
- // 1 : src gzip, dest normal
- // 2 : src normal, dest gzip
- // 3 : src & dest gzip
- // Return Values :
- // --------------------------------------------------------------------------------
- function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
- {
+// --------------------------------------------------------------------------------
+// Function : PclZipUtilCopyBlock()
+// Description :
+// Parameters :
+// $p_mode : read/write compression mode
+// 0 : src & dest normal
+// 1 : src gzip, dest normal
+// 2 : src normal, dest gzip
+// 3 : src & dest gzip
+// Return Values :
+// --------------------------------------------------------------------------------
+function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode = 0)
+{
$v_result = 1;
- if ($p_mode==0)
- {
- while ($p_size != 0)
- {
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = @fread($p_src, $v_read_size);
- @fwrite($p_dest, $v_buffer, $v_read_size);
- $p_size -= $v_read_size;
- }
- }
- else if ($p_mode==1)
- {
- while ($p_size != 0)
- {
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = @gzread($p_src, $v_read_size);
- @fwrite($p_dest, $v_buffer, $v_read_size);
- $p_size -= $v_read_size;
- }
- }
- else if ($p_mode==2)
- {
- while ($p_size != 0)
- {
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = @fread($p_src, $v_read_size);
- @gzwrite($p_dest, $v_buffer, $v_read_size);
- $p_size -= $v_read_size;
- }
- }
- else if ($p_mode==3)
- {
- while ($p_size != 0)
- {
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
- $v_buffer = @gzread($p_src, $v_read_size);
- @gzwrite($p_dest, $v_buffer, $v_read_size);
- $p_size -= $v_read_size;
- }
+ if ($p_mode == 0) {
+ while ($p_size != 0) {
+ $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = @fread($p_src, $v_read_size);
+ @fwrite($p_dest, $v_buffer, $v_read_size);
+ $p_size -= $v_read_size;
+ }
+ } elseif ($p_mode == 1) {
+ while ($p_size != 0) {
+ $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = @gzread($p_src, $v_read_size);
+ @fwrite($p_dest, $v_buffer, $v_read_size);
+ $p_size -= $v_read_size;
+ }
+ } elseif ($p_mode == 2) {
+ while ($p_size != 0) {
+ $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = @fread($p_src, $v_read_size);
+ @gzwrite($p_dest, $v_buffer, $v_read_size);
+ $p_size -= $v_read_size;
+ }
+ } elseif ($p_mode == 3) {
+ while ($p_size != 0) {
+ $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
+ $v_buffer = @gzread($p_src, $v_read_size);
+ @gzwrite($p_dest, $v_buffer, $v_read_size);
+ $p_size -= $v_read_size;
+ }
}
// ----- Return
return $v_result;
- }
- // --------------------------------------------------------------------------------
+}
+// --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : PclZipUtilRename()
- // Description :
- // This function tries to do a simple rename() function. If it fails, it
- // tries to copy the $p_src file in a new $p_dest file and then unlink the
- // first one.
- // Parameters :
- // $p_src : Old filename
- // $p_dest : New filename
- // Return Values :
- // 1 on success, 0 on failure.
- // --------------------------------------------------------------------------------
- function PclZipUtilRename($p_src, $p_dest)
- {
+// --------------------------------------------------------------------------------
+// Function : PclZipUtilRename()
+// Description :
+// This function tries to do a simple rename() function. If it fails, it
+// tries to copy the $p_src file in a new $p_dest file and then unlink the
+// first one.
+// Parameters :
+// $p_src : Old filename
+// $p_dest : New filename
+// Return Values :
+// 1 on success, 0 on failure.
+// --------------------------------------------------------------------------------
+function PclZipUtilRename($p_src, $p_dest)
+{
$v_result = 1;
// ----- Try to rename the files
if (!@rename($p_src, $p_dest)) {
- // ----- Try to copy & unlink the src
- if (!@copy($p_src, $p_dest)) {
- $v_result = 0;
- }
- else if (!@unlink($p_src)) {
- $v_result = 0;
- }
+ // ----- Try to copy & unlink the src
+ if (!@copy($p_src, $p_dest)) {
+ $v_result = 0;
+ } elseif (!@unlink($p_src)) {
+ $v_result = 0;
+ }
}
// ----- Return
return $v_result;
- }
- // --------------------------------------------------------------------------------
+}
+// --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : PclZipUtilOptionText()
- // Description :
- // Translate option value in text. Mainly for debug purpose.
- // Parameters :
- // $p_option : the option value.
- // Return Values :
- // The option text value.
- // --------------------------------------------------------------------------------
- function PclZipUtilOptionText($p_option)
- {
+// --------------------------------------------------------------------------------
+// Function : PclZipUtilOptionText()
+// Description :
+// Translate option value in text. Mainly for debug purpose.
+// Parameters :
+// $p_option : the option value.
+// Return Values :
+// The option text value.
+// --------------------------------------------------------------------------------
+function PclZipUtilOptionText($p_option)
+{
$v_list = get_defined_constants();
for (reset($v_list); $v_key = key($v_list); next($v_list)) {
$v_prefix = substr($v_key, 0, 10);
- if (( ($v_prefix == 'PCLZIP_OPT')
- || ($v_prefix == 'PCLZIP_CB_')
- || ($v_prefix == 'PCLZIP_ATT'))
- && ($v_list[$v_key] == $p_option)) {
- return $v_key;
+ if ((($v_prefix == 'PCLZIP_OPT') || ($v_prefix == 'PCLZIP_CB_') || ($v_prefix == 'PCLZIP_ATT')) && ($v_list[$v_key] == $p_option)) {
+ return $v_key;
}
}
$v_result = 'Unknown';
return $v_result;
- }
- // --------------------------------------------------------------------------------
+}
+// --------------------------------------------------------------------------------
- // --------------------------------------------------------------------------------
- // Function : PclZipUtilTranslateWinPath()
- // Description :
- // Translate windows path by replacing '\' by '/' and optionally removing
- // drive letter.
- // Parameters :
- // $p_path : path to translate.
- // $p_remove_disk_letter : true | false
- // Return Values :
- // The path translated.
- // --------------------------------------------------------------------------------
- function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
- {
+// --------------------------------------------------------------------------------
+// Function : PclZipUtilTranslateWinPath()
+// Description :
+// Translate windows path by replacing '\' by '/' and optionally removing
+// drive letter.
+// Parameters :
+// $p_path : path to translate.
+// $p_remove_disk_letter : true | false
+// Return Values :
+// The path translated.
+// --------------------------------------------------------------------------------
+function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter = true)
+{
if (stristr(php_uname(), 'windows')) {
- // ----- Look for potential disk letter
- if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
- $p_path = substr($p_path, $v_position+1);
- }
- // ----- Change potential windows directory separator
- if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
- $p_path = strtr($p_path, '\\', '/');
- }
+ // ----- Look for potential disk letter
+ if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
+ $p_path = substr($p_path, $v_position + 1);
+ }
+ // ----- Change potential windows directory separator
+ if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) {
+ $p_path = strtr($p_path, '\\', '/');
+ }
}
+
return $p_path;
- }
- // --------------------------------------------------------------------------------
+}
+// --------------------------------------------------------------------------------
diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php
index 4dc4af4e..d73f6c33 100644
--- a/src/PhpWord/Shared/ZipArchive.php
+++ b/src/PhpWord/Shared/ZipArchive.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,7 +37,7 @@ use PhpOffice\PhpWord\Settings;
class ZipArchive
{
/** @const int Flags for open method */
- const CREATE = 1; // Emulate \ZipArchive::CREATE
+ const CREATE = 1; // Emulate \ZipArchive::CREATE
const OVERWRITE = 8; // Emulate \ZipArchive::OVERWRITE
/**
@@ -150,10 +150,10 @@ class ZipArchive
/**
* Close the active archive
*
- * @return bool
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
*
+ * @return bool
+ *
* @codeCoverageIgnore Can't find any test case. Uncomment when found.
*/
public function close()
@@ -183,9 +183,9 @@ class ZipArchive
if (!$this->usePclzip) {
return $this->zip->extractTo($destination, $entries);
- } else {
- return $this->pclzipExtractTo($destination, $entries);
}
+
+ return $this->pclzipExtractTo($destination, $entries);
}
/**
@@ -301,6 +301,7 @@ class ZipArchive
// Extract all files
if (is_null($entries)) {
$result = $zip->extract(PCLZIP_OPT_PATH, $destination);
+
return ($result > 0) ? true : false;
}
@@ -360,9 +361,9 @@ class ZipArchive
$list = $zip->listContent();
if (isset($list[$index])) {
return $list[$index]['filename'];
- } else {
- return false;
}
+
+ return false;
}
/**
diff --git a/src/PhpWord/SimpleType/Jc.php b/src/PhpWord/SimpleType/Jc.php
index 5c399a16..1a5d33ad 100644
--- a/src/PhpWord/SimpleType/Jc.php
+++ b/src/PhpWord/SimpleType/Jc.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,7 +28,7 @@ use PhpOffice\PhpWord\Shared\AbstractEnum;
* @since 0.13.0
*
* @see \PhpOffice\PhpWord\SimpleType\JcTable For table alignment modes available since ISO/IEC-29500:2008.
- * @link http://www.datypic.com/sc/ooxml/t-w_ST_Jc.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_ST_Jc.html
*
* @codeCoverageIgnore
*/
diff --git a/src/PhpWord/SimpleType/JcTable.php b/src/PhpWord/SimpleType/JcTable.php
index 865b25a8..e1af89ad 100644
--- a/src/PhpWord/SimpleType/JcTable.php
+++ b/src/PhpWord/SimpleType/JcTable.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/SimpleType/NumberFormat.php b/src/PhpWord/SimpleType/NumberFormat.php
index 9d24a2b3..480d8539 100644
--- a/src/PhpWord/SimpleType/NumberFormat.php
+++ b/src/PhpWord/SimpleType/NumberFormat.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/SimpleType/Zoom.php b/src/PhpWord/SimpleType/Zoom.php
index 3b78fdf9..111e4ea1 100644
--- a/src/PhpWord/SimpleType/Zoom.php
+++ b/src/PhpWord/SimpleType/Zoom.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Style.php b/src/PhpWord/Style.php
index 57d9d692..1939aaba 100644
--- a/src/PhpWord/Style.php
+++ b/src/PhpWord/Style.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -126,8 +126,6 @@ class Style
* Reset styles.
*
* @since 0.10.0
- *
- * @return void
*/
public static function resetStyles()
{
@@ -165,9 +163,9 @@ class Style
{
if (isset(self::$styles[$styleName])) {
return self::$styles[$styleName];
- } else {
- return null;
}
+
+ return null;
}
/**
diff --git a/src/PhpWord/Style/AbstractStyle.php b/src/PhpWord/Style/AbstractStyle.php
index e2b6dce9..76ebd591 100644
--- a/src/PhpWord/Style/AbstractStyle.php
+++ b/src/PhpWord/Style/AbstractStyle.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -138,10 +138,11 @@ abstract class AbstractStyle
{
if ($substyleObject !== null) {
$method = "get{$substyleProperty}";
+
return $substyleObject->$method();
- } else {
- return null;
}
+
+ return null;
}
/**
@@ -242,12 +243,12 @@ abstract class AbstractStyle
protected function setIntVal($value, $default = null)
{
if (is_string($value) && (preg_match('/[^\d]/', $value) == 0)) {
- $value = intval($value);
+ $value = (int) $value;
}
if (!is_numeric($value)) {
$value = $default;
} else {
- $value = intval($value);
+ $value = (int) $value;
}
return $value;
@@ -263,7 +264,7 @@ abstract class AbstractStyle
protected function setFloatVal($value, $default = null)
{
if (is_string($value) && (preg_match('/[^\d\.\,]/', $value) == 0)) {
- $value = floatval($value);
+ $value = (float) $value;
}
if (!is_numeric($value)) {
$value = $default;
@@ -279,14 +280,13 @@ abstract class AbstractStyle
* @param array $enum
* @param mixed $default
*
- * @return mixed
- *
* @throws \InvalidArgumentException
+ * @return mixed
*/
protected function setEnumVal($value = null, $enum = array(), $default = null)
{
if ($value != null && trim($value) != '' && !empty($enum) && !in_array($value, $enum)) {
- throw new \InvalidArgumentException("Invalid style value: {$value} Options:".join(',', $enum));
+ throw new \InvalidArgumentException("Invalid style value: {$value} Options:" . implode(',', $enum));
} elseif ($value === null || trim($value) == '') {
$value = $default;
}
diff --git a/src/PhpWord/Style/Border.php b/src/PhpWord/Style/Border.php
index d3bc2e57..5c62afcd 100644
--- a/src/PhpWord/Style/Border.php
+++ b/src/PhpWord/Style/Border.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -81,7 +81,7 @@ class Border extends AbstractStyle
/**
* Get border size
*
- * @return integer[]
+ * @return int[]
*/
public function getBorderSize()
{
diff --git a/src/PhpWord/Style/Cell.php b/src/PhpWord/Style/Cell.php
index 7bab8b56..0c4ca2e1 100644
--- a/src/PhpWord/Style/Cell.php
+++ b/src/PhpWord/Style/Cell.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -72,7 +72,7 @@ class Cell extends Border
/**
* colspan
*
- * @var integer
+ * @var int
*/
private $gridSpan;
@@ -150,9 +150,9 @@ class Cell extends Border
{
if ($this->shading !== null) {
return $this->shading->getFill();
- } else {
- return null;
}
+
+ return null;
}
/**
@@ -169,7 +169,7 @@ class Cell extends Border
/**
* Get grid span (colspan).
*
- * @return integer
+ * @return int
*/
public function getGridSpan()
{
diff --git a/src/PhpWord/Style/Chart.php b/src/PhpWord/Style/Chart.php
index 8e1f4b61..694fcddc 100644
--- a/src/PhpWord/Style/Chart.php
+++ b/src/PhpWord/Style/Chart.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -24,7 +24,6 @@ namespace PhpOffice\PhpWord\Style;
*/
class Chart extends AbstractStyle
{
-
/**
* Width (in EMU)
*
diff --git a/src/PhpWord/Style/Extrusion.php b/src/PhpWord/Style/Extrusion.php
index d8c5e65f..11c03eda 100644
--- a/src/PhpWord/Style/Extrusion.php
+++ b/src/PhpWord/Style/Extrusion.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,7 +20,7 @@ namespace PhpOffice\PhpWord\Style;
/**
* 3D extrusion style
*
- * @link http://www.schemacentral.com/sc/ooxml/t-o_CT_Extrusion.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-o_CT_Extrusion.html
* @since 0.12.0
*/
class Extrusion extends AbstractStyle
diff --git a/src/PhpWord/Style/Fill.php b/src/PhpWord/Style/Fill.php
index cf6ffb41..9b473009 100644
--- a/src/PhpWord/Style/Fill.php
+++ b/src/PhpWord/Style/Fill.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,9 +20,9 @@ namespace PhpOffice\PhpWord\Style;
/**
* Fill style
*
- * There are still lot of interesting things for this style that can be added, including gradient. See @link.
+ * There are still lot of interesting things for this style that can be added, including gradient. See @see .
*
- * @link http://www.schemacentral.com/sc/ooxml/t-v_CT_Fill.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-v_CT_Fill.html
* @since 0.12.0
*/
class Fill extends AbstractStyle
diff --git a/src/PhpWord/Style/Font.php b/src/PhpWord/Style/Font.php
index 19f2758d..76b03ac6 100644
--- a/src/PhpWord/Style/Font.php
+++ b/src/PhpWord/Style/Font.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -162,7 +162,7 @@ class Font extends AbstractStyle
* Small caps
*
* @var bool
- * @link http://www.schemacentral.com/sc/ooxml/e-w_smallCaps-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_smallCaps-1.html
*/
private $smallCaps = false;
@@ -170,7 +170,7 @@ class Font extends AbstractStyle
* All caps
*
* @var bool
- * @link http://www.schemacentral.com/sc/ooxml/e-w_caps-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_caps-1.html
*/
private $allCaps = false;
@@ -186,7 +186,7 @@ class Font extends AbstractStyle
*
* @var int
* @since 0.12.0
- * @link http://www.schemacentral.com/sc/ooxml/e-w_w-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_w-1.html
*/
private $scale;
@@ -195,7 +195,7 @@ class Font extends AbstractStyle
*
* @var int|float
* @since 0.12.0
- * @link http://www.schemacentral.com/sc/ooxml/e-w_spacing-2.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_spacing-2.html
*/
private $spacing;
@@ -204,7 +204,7 @@ class Font extends AbstractStyle
*
* @var int|float
* @since 0.12.0
- * @link http://www.schemacentral.com/sc/ooxml/e-w_kern-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_kern-1.html
*/
private $kerning;
@@ -224,12 +224,12 @@ class Font extends AbstractStyle
/**
* Right to left languages
- * @var boolean
+ * @var bool
*/
private $rtl = false;
/**
- * Languages
+ * Languages
* @var \PhpOffice\PhpWord\Style\Language
*/
private $lang;
@@ -812,7 +812,7 @@ class Font extends AbstractStyle
$value = new Language($value);
}
$this->setObjectVal($value, 'Language', $this->lang);
-
+
return $this;
}
diff --git a/src/PhpWord/Style/Frame.php b/src/PhpWord/Style/Frame.php
index 0a99146b..a8e1c69d 100644
--- a/src/PhpWord/Style/Frame.php
+++ b/src/PhpWord/Style/Frame.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Style/Image.php b/src/PhpWord/Style/Image.php
index f2c88b5f..c3f1863c 100644
--- a/src/PhpWord/Style/Image.php
+++ b/src/PhpWord/Style/Image.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Style;
/**
diff --git a/src/PhpWord/Style/Indentation.php b/src/PhpWord/Style/Indentation.php
index 0408929b..9621714c 100644
--- a/src/PhpWord/Style/Indentation.php
+++ b/src/PhpWord/Style/Indentation.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,7 +20,7 @@ namespace PhpOffice\PhpWord\Style;
/**
* Paragraph indentation style
*
- * @link http://www.schemacentral.com/sc/ooxml/t-w_CT_Ind.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-w_CT_Ind.html
* @since 0.10.0
*/
class Indentation extends AbstractStyle
diff --git a/src/PhpWord/Style/Language.php b/src/PhpWord/Style/Language.php
index 4e9220fd..e09421e0 100644
--- a/src/PhpWord/Style/Language.php
+++ b/src/PhpWord/Style/Language.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Style;
/**
@@ -25,7 +26,6 @@ namespace PhpOffice\PhpWord\Style;
*/
final class Language extends AbstractStyle
{
-
const EN_US = 'en-US';
const EN_US_ID = 1033;
@@ -89,7 +89,8 @@ final class Language extends AbstractStyle
private $bidirectional;
/**
- *
+ * Constructor
+ *
* @param string|null $latin
* @param string|null $eastAsia
* @param string|null $bidirectional
@@ -118,6 +119,7 @@ final class Language extends AbstractStyle
{
$this->validateLocale($latin);
$this->latin = $latin;
+
return $this;
}
@@ -142,6 +144,7 @@ final class Language extends AbstractStyle
public function setLangId($langId)
{
$this->langId = $langId;
+
return $this;
}
@@ -166,6 +169,7 @@ final class Language extends AbstractStyle
{
$this->validateLocale($eastAsia);
$this->eastAsia = $eastAsia;
+
return $this;
}
@@ -190,6 +194,7 @@ final class Language extends AbstractStyle
{
$this->validateLocale($bidirectional);
$this->bidirectional = $bidirectional;
+
return $this;
}
@@ -205,9 +210,9 @@ final class Language extends AbstractStyle
/**
* Validates that the language passed is in the format xx-xx
- *
+ *
* @param string $locale
- * @return boolean
+ * @return bool
*/
private function validateLocale($locale)
{
diff --git a/src/PhpWord/Style/Line.php b/src/PhpWord/Style/Line.php
index f8cc4026..16d15950 100644
--- a/src/PhpWord/Style/Line.php
+++ b/src/PhpWord/Style/Line.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Style;
/**
@@ -55,7 +56,7 @@ class Line extends Image
/**
* flip Line
*
- * @var boolean
+ * @var bool
*/
private $flip = false;
@@ -104,7 +105,7 @@ class Line extends Image
/**
* Get flip
*
- * @return boolean
+ * @return bool
*/
public function isFlip()
{
@@ -114,7 +115,7 @@ class Line extends Image
/**
* Set flip
*
- * @param boolean $value
+ * @param bool $value
* @return self
*/
public function setFlip($value = false)
@@ -143,7 +144,7 @@ class Line extends Image
public function setConnectorType($value = null)
{
$enum = array(
- self::CONNECTOR_TYPE_STRAIGHT
+ self::CONNECTOR_TYPE_STRAIGHT,
);
$this->connectorType = $this->setEnumVal($value, $enum, $this->connectorType);
@@ -216,7 +217,7 @@ class Line extends Image
{
$enum = array(
self::ARROW_STYLE_BLOCK, self::ARROW_STYLE_CLASSIC, self::ARROW_STYLE_DIAMOND,
- self::ARROW_STYLE_OPEN, self::ARROW_STYLE_OVAL
+ self::ARROW_STYLE_OPEN, self::ARROW_STYLE_OVAL,
);
$this->beginArrow = $this->setEnumVal($value, $enum, $this->beginArrow);
@@ -243,7 +244,7 @@ class Line extends Image
{
$enum = array(
self::ARROW_STYLE_BLOCK, self::ARROW_STYLE_CLASSIC, self::ARROW_STYLE_DIAMOND,
- self::ARROW_STYLE_OPEN, self::ARROW_STYLE_OVAL
+ self::ARROW_STYLE_OPEN, self::ARROW_STYLE_OVAL,
);
$this->endArrow = $this->setEnumVal($value, $enum, $this->endArrow);
@@ -271,7 +272,7 @@ class Line extends Image
$enum = array(
self::DASH_STYLE_DASH, self::DASH_STYLE_DASH_DOT, self::DASH_STYLE_LONG_DASH,
self::DASH_STYLE_LONG_DASH_DOT, self::DASH_STYLE_LONG_DASH_DOT_DOT, self::DASH_STYLE_ROUND_DOT,
- self::DASH_STYLE_SQUARE_DOT
+ self::DASH_STYLE_SQUARE_DOT,
);
$this->dash = $this->setEnumVal($value, $enum, $this->dash);
diff --git a/src/PhpWord/Style/LineNumbering.php b/src/PhpWord/Style/LineNumbering.php
index e125f477..b5f3c263 100644
--- a/src/PhpWord/Style/LineNumbering.php
+++ b/src/PhpWord/Style/LineNumbering.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,14 +20,14 @@ namespace PhpOffice\PhpWord\Style;
/**
* Line numbering style
*
- * @link http://www.schemacentral.com/sc/ooxml/t-w_CT_LineNumber.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-w_CT_LineNumber.html
* @since 0.10.0
*/
class LineNumbering extends AbstractStyle
{
/** @const string Line numbering restart setting http://www.schemacentral.com/sc/ooxml/a-w_restart-1.html */
- const LINE_NUMBERING_CONTINUOUS = 'continuous';
- const LINE_NUMBERING_NEW_PAGE = 'newPage';
+ const LINE_NUMBERING_CONTINUOUS = 'continuous';
+ const LINE_NUMBERING_NEW_PAGE = 'newPage';
const LINE_NUMBERING_NEW_SECTION = 'newSection';
/**
@@ -55,7 +55,7 @@ class LineNumbering extends AbstractStyle
* Line numbering restart setting continuous|newPage|newSection
*
* @var string
- * @link http://www.schemacentral.com/sc/ooxml/a-w_restart-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/a-w_restart-1.html
*/
private $restart;
diff --git a/src/PhpWord/Style/ListItem.php b/src/PhpWord/Style/ListItem.php
index 61a8349b..444341dc 100644
--- a/src/PhpWord/Style/ListItem.php
+++ b/src/PhpWord/Style/ListItem.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -38,7 +38,7 @@ class ListItem extends AbstractStyle
/**
* Legacy list type
*
- * @var integer
+ * @var int
*/
private $listType;
@@ -53,7 +53,7 @@ class ListItem extends AbstractStyle
/**
* Numbering definition instance ID
*
- * @var integer
+ * @var int
* @since 0.10.0
*/
private $numId;
@@ -75,7 +75,7 @@ class ListItem extends AbstractStyle
/**
* Get List Type
*
- * @return integer
+ * @return int
*/
public function getListType()
{
@@ -85,7 +85,7 @@ class ListItem extends AbstractStyle
/**
* Set legacy list type for version < 0.10.0
*
- * @param integer $value
+ * @param int $value
* @return self
*/
public function setListType($value = self::TYPE_BULLET_FILLED)
@@ -93,7 +93,7 @@ class ListItem extends AbstractStyle
$enum = array(
self::TYPE_SQUARE_FILLED, self::TYPE_BULLET_FILLED,
self::TYPE_BULLET_EMPTY, self::TYPE_NUMBER,
- self::TYPE_NUMBER_NESTED, self::TYPE_ALPHANUM
+ self::TYPE_NUMBER_NESTED, self::TYPE_ALPHANUM,
);
$this->listType = $this->setEnumVal($value, $enum, $this->listType);
$this->getListTypeStyle();
@@ -132,7 +132,7 @@ class ListItem extends AbstractStyle
/**
* Get numbering Id
*
- * @return integer
+ * @return int
*/
public function getNumId()
{
@@ -151,6 +151,7 @@ class ListItem extends AbstractStyle
$numStyle = "PHPWordList{$this->listType}";
if (Style::getStyle($numStyle) !== null) {
$this->setNumStyle($numStyle);
+
return;
}
@@ -160,7 +161,7 @@ class ListItem extends AbstractStyle
// Legacy level information
$listTypeStyles = array(
self::TYPE_SQUARE_FILLED => array(
- 'type' => 'hybridMultilevel',
+ 'type' => 'hybridMultilevel',
'levels' => array(
0 => '1, bullet, , left, 720, 720, 360, Wingdings, default',
1 => '1, bullet, o, left, 1440, 1440, 360, Courier New, default',
@@ -174,7 +175,7 @@ class ListItem extends AbstractStyle
),
),
self::TYPE_BULLET_FILLED => array(
- 'type' => 'hybridMultilevel',
+ 'type' => 'hybridMultilevel',
'levels' => array(
0 => '1, bullet, , left, 720, 720, 360, Symbol, default',
1 => '1, bullet, o, left, 1440, 1440, 360, Courier New, default',
@@ -188,7 +189,7 @@ class ListItem extends AbstractStyle
),
),
self::TYPE_BULLET_EMPTY => array(
- 'type' => 'hybridMultilevel',
+ 'type' => 'hybridMultilevel',
'levels' => array(
0 => '1, bullet, o, left, 720, 720, 360, Courier New, default',
1 => '1, bullet, o, left, 1440, 1440, 360, Courier New, default',
@@ -202,7 +203,7 @@ class ListItem extends AbstractStyle
),
),
self::TYPE_NUMBER => array(
- 'type' => 'hybridMultilevel',
+ 'type' => 'hybridMultilevel',
'levels' => array(
0 => '1, decimal, %1., left, 720, 720, 360, , default',
1 => '1, bullet, o, left, 1440, 1440, 360, Courier New, default',
@@ -216,7 +217,7 @@ class ListItem extends AbstractStyle
),
),
self::TYPE_NUMBER_NESTED => array(
- 'type' => 'multilevel',
+ 'type' => 'multilevel',
'levels' => array(
0 => '1, decimal, %1., left, 360, 360, 360, , ',
1 => '1, decimal, %1.%2., left, 792, 792, 432, , ',
@@ -230,7 +231,7 @@ class ListItem extends AbstractStyle
),
),
self::TYPE_ALPHANUM => array(
- 'type' => 'multilevel',
+ 'type' => 'multilevel',
'levels' => array(
0 => '1, decimal, %1., left, 720, 720, 360, , ',
1 => '1, lowerLetter, %2., left, 1440, 1440, 360, , ',
diff --git a/src/PhpWord/Style/Numbering.php b/src/PhpWord/Style/Numbering.php
index 0d4fd85d..80ed5dca 100644
--- a/src/PhpWord/Style/Numbering.php
+++ b/src/PhpWord/Style/Numbering.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,9 +20,9 @@ namespace PhpOffice\PhpWord\Style;
/**
* Numbering style
*
- * @link http://www.schemacentral.com/sc/ooxml/e-w_numbering.html
- * @link http://www.schemacentral.com/sc/ooxml/e-w_abstractNum-1.html
- * @link http://www.schemacentral.com/sc/ooxml/e-w_num-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_numbering.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_abstractNum-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_num-1.html
* @since 0.10.0
*/
class Numbering extends AbstractStyle
@@ -31,7 +31,7 @@ class Numbering extends AbstractStyle
* Numbering definition instance ID
*
* @var int
- * @link http://www.schemacentral.com/sc/ooxml/e-w_num-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_num-1.html
*/
private $numId;
@@ -39,7 +39,7 @@ class Numbering extends AbstractStyle
* Multilevel type singleLevel|multilevel|hybridMultilevel
*
* @var string
- * @link http://www.schemacentral.com/sc/ooxml/a-w_val-67.html
+ * @see http://www.schemacentral.com/sc/ooxml/a-w_val-67.html
*/
private $type;
@@ -53,7 +53,7 @@ class Numbering extends AbstractStyle
/**
* Get Id
*
- * @return integer
+ * @return int
*/
public function getNumId()
{
@@ -63,7 +63,7 @@ class Numbering extends AbstractStyle
/**
* Set Id
*
- * @param integer $value
+ * @param int $value
* @return self
*/
public function setNumId($value)
diff --git a/src/PhpWord/Style/NumberingLevel.php b/src/PhpWord/Style/NumberingLevel.php
index 9da1a2b1..33c151e4 100644
--- a/src/PhpWord/Style/NumberingLevel.php
+++ b/src/PhpWord/Style/NumberingLevel.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -23,7 +23,7 @@ use PhpOffice\PhpWord\SimpleType\NumberFormat;
/**
* Numbering level definition
*
- * @link http://www.schemacentral.com/sc/ooxml/e-w_lvl-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_lvl-1.html
* @since 0.10.0
*/
class NumberingLevel extends AbstractStyle
@@ -31,15 +31,15 @@ class NumberingLevel extends AbstractStyle
/**
* Level number, 0 to 8 (total 9 levels)
*
- * @var integer
+ * @var int
*/
private $level = 0;
/**
* Starting value w:start
*
- * @var integer
- * @link http://www.schemacentral.com/sc/ooxml/e-w_start-1.html
+ * @var int
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_start-1.html
*/
private $start = 1;
@@ -47,15 +47,15 @@ class NumberingLevel extends AbstractStyle
* Numbering format w:numFmt, one of PhpOffice\PhpWord\SimpleType\NumberFormat
*
* @var string
- * @link http://www.schemacentral.com/sc/ooxml/t-w_ST_NumberFormat.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-w_ST_NumberFormat.html
*/
private $format;
/**
* Restart numbering level symbol w:lvlRestart
*
- * @var integer
- * @link http://www.schemacentral.com/sc/ooxml/e-w_lvlRestart-1.html
+ * @var int
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_lvlRestart-1.html
*/
private $restart;
@@ -63,7 +63,7 @@ class NumberingLevel extends AbstractStyle
* Related paragraph style
*
* @var string
- * @link http://www.schemacentral.com/sc/ooxml/e-w_pStyle-2.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_pStyle-2.html
*/
private $pStyle;
@@ -71,7 +71,7 @@ class NumberingLevel extends AbstractStyle
* Content between numbering symbol and paragraph text w:suff
*
* @var string tab|space|nothing
- * @link http://www.schemacentral.com/sc/ooxml/e-w_suff-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_suff-1.html
*/
private $suffix = 'tab';
@@ -79,7 +79,7 @@ class NumberingLevel extends AbstractStyle
* Numbering level text e.g. %1 for nonbullet or bullet character
*
* @var string
- * @link http://www.schemacentral.com/sc/ooxml/e-w_lvlText-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_lvlText-1.html
*/
private $text;
@@ -93,21 +93,21 @@ class NumberingLevel extends AbstractStyle
/**
* Left
*
- * @var integer
+ * @var int
*/
private $left;
/**
* Hanging
*
- * @var integer
+ * @var int
*/
private $hanging;
/**
* Tab position
*
- * @var integer
+ * @var int
*/
private $tabPos;
@@ -122,14 +122,14 @@ class NumberingLevel extends AbstractStyle
* Hint default|eastAsia|cs
*
* @var string
- * @link http://www.schemacentral.com/sc/ooxml/a-w_hint-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/a-w_hint-1.html
*/
private $hint;
/**
* Get level
*
- * @return integer
+ * @return int
*/
public function getLevel()
{
@@ -139,19 +139,20 @@ class NumberingLevel extends AbstractStyle
/**
* Set level
*
- * @param integer $value
+ * @param int $value
* @return self
*/
public function setLevel($value)
{
$this->level = $this->setIntVal($value, $this->level);
+
return $this;
}
/**
* Get start
*
- * @return integer
+ * @return int
*/
public function getStart()
{
@@ -161,12 +162,13 @@ class NumberingLevel extends AbstractStyle
/**
* Set start
*
- * @param integer $value
+ * @param int $value
* @return self
*/
public function setStart($value)
{
$this->start = $this->setIntVal($value, $this->start);
+
return $this;
}
@@ -189,13 +191,14 @@ class NumberingLevel extends AbstractStyle
public function setFormat($value)
{
$this->format = $this->setEnumVal($value, NumberFormat::values(), $this->format);
+
return $this;
}
/**
* Get restart
*
- * @return integer
+ * @return int
*/
public function getRestart()
{
@@ -205,12 +208,13 @@ class NumberingLevel extends AbstractStyle
/**
* Set restart
*
- * @param integer $value
+ * @param int $value
* @return self
*/
public function setRestart($value)
{
$this->restart = $this->setIntVal($value, $this->restart);
+
return $this;
}
@@ -233,6 +237,7 @@ class NumberingLevel extends AbstractStyle
public function setPStyle($value)
{
$this->pStyle = $value;
+
return $this;
}
@@ -256,6 +261,7 @@ class NumberingLevel extends AbstractStyle
{
$enum = array('tab', 'space', 'nothing');
$this->suffix = $this->setEnumVal($value, $enum, $this->suffix);
+
return $this;
}
@@ -278,6 +284,7 @@ class NumberingLevel extends AbstractStyle
public function setText($value)
{
$this->text = $value;
+
return $this;
}
@@ -336,7 +343,7 @@ class NumberingLevel extends AbstractStyle
/**
* Get left
*
- * @return integer
+ * @return int
*/
public function getLeft()
{
@@ -346,19 +353,20 @@ class NumberingLevel extends AbstractStyle
/**
* Set left
*
- * @param integer $value
+ * @param int $value
* @return self
*/
public function setLeft($value)
{
$this->left = $this->setIntVal($value, $this->left);
+
return $this;
}
/**
* Get hanging
*
- * @return integer
+ * @return int
*/
public function getHanging()
{
@@ -368,19 +376,20 @@ class NumberingLevel extends AbstractStyle
/**
* Set hanging
*
- * @param integer $value
+ * @param int $value
* @return self
*/
public function setHanging($value)
{
$this->hanging = $this->setIntVal($value, $this->hanging);
+
return $this;
}
/**
* Get tab
*
- * @return integer
+ * @return int
*/
public function getTabPos()
{
@@ -390,12 +399,13 @@ class NumberingLevel extends AbstractStyle
/**
* Set tab
*
- * @param integer $value
+ * @param int $value
* @return self
*/
public function setTabPos($value)
{
$this->tabPos = $this->setIntVal($value, $this->tabPos);
+
return $this;
}
@@ -418,6 +428,7 @@ class NumberingLevel extends AbstractStyle
public function setFont($value)
{
$this->font = $value;
+
return $this;
}
diff --git a/src/PhpWord/Style/Outline.php b/src/PhpWord/Style/Outline.php
index 8628c4c5..fb7e028a 100644
--- a/src/PhpWord/Style/Outline.php
+++ b/src/PhpWord/Style/Outline.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,8 +20,8 @@ namespace PhpOffice\PhpWord\Style;
/**
* Outline defines the line/border of the object
*
- * @link http://www.schemacentral.com/sc/ooxml/t-v_CT_Stroke.html
- * @link http://www.w3.org/TR/1998/NOTE-VML-19980513#_Toc416858395
+ * @see http://www.schemacentral.com/sc/ooxml/t-v_CT_Stroke.html
+ * @see http://www.w3.org/TR/1998/NOTE-VML-19980513#_Toc416858395
* @since 0.12.0
*/
class Outline extends AbstractStyle
@@ -29,7 +29,7 @@ class Outline extends AbstractStyle
/**
* Line style constants
*
- * @link http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeLineStyle.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeLineStyle.html
* @const string
*/
const LINE_SINGLE = 'single';
@@ -41,7 +41,7 @@ class Outline extends AbstractStyle
/**
* Line style constants
*
- * @link http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeEndCap.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeEndCap.html
* @const string
*/
const ENDCAP_FLAT = 'flat';
@@ -51,7 +51,7 @@ class Outline extends AbstractStyle
/**
* Arrowhead type constants
*
- * @link http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeArrowType.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeArrowType.html
* @const string
*/
const ARROW_NONE = 'none';
@@ -100,7 +100,7 @@ class Outline extends AbstractStyle
* End cap
*
* @var string
- * @link http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeEndCap.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-v_ST_StrokeEndCap.html
*/
private $endCap;
@@ -226,7 +226,7 @@ class Outline extends AbstractStyle
public function setLine($value = null)
{
$enum = array(self::LINE_SINGLE, self::LINE_THIN_THIN, self::LINE_THIN_THICK,
- self::LINE_THICK_THIN, self::LINE_THICK_BETWEEN_THIN);
+ self::LINE_THICK_THIN, self::LINE_THICK_BETWEEN_THIN, );
$this->line = $this->setEnumVal($value, $enum, null);
return $this;
@@ -275,7 +275,7 @@ class Outline extends AbstractStyle
public function setStartArrow($value = null)
{
$enum = array(self::ARROW_NONE, self::ARROW_BLOCK, self::ARROW_CLASSIC,
- self::ARROW_OVAL, self::ARROW_DIAMOND, self::ARROW_OPEN);
+ self::ARROW_OVAL, self::ARROW_DIAMOND, self::ARROW_OPEN, );
$this->startArrow = $this->setEnumVal($value, $enum, null);
return $this;
@@ -300,7 +300,7 @@ class Outline extends AbstractStyle
public function setEndArrow($value = null)
{
$enum = array(self::ARROW_NONE, self::ARROW_BLOCK, self::ARROW_CLASSIC,
- self::ARROW_OVAL, self::ARROW_DIAMOND, self::ARROW_OPEN);
+ self::ARROW_OVAL, self::ARROW_DIAMOND, self::ARROW_OPEN, );
$this->endArrow = $this->setEnumVal($value, $enum, null);
return $this;
diff --git a/src/PhpWord/Style/Paper.php b/src/PhpWord/Style/Paper.php
index eb0bcd77..2fbf59d2 100644
--- a/src/PhpWord/Style/Paper.php
+++ b/src/PhpWord/Style/Paper.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Style/Paragraph.php b/src/PhpWord/Style/Paragraph.php
index 169f2cda..f665048b 100644
--- a/src/PhpWord/Style/Paragraph.php
+++ b/src/PhpWord/Style/Paragraph.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -46,7 +46,7 @@ use PhpOffice\PhpWord\SimpleType\Jc;
* - Borders
* - Background
*
- * @link http://www.schemacentral.com/sc/ooxml/t-w_CT_PPr.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-w_CT_PPr.html
*/
class Paragraph extends Border
{
@@ -157,7 +157,7 @@ class Paragraph extends Border
* @var \PhpOffice\PhpWord\Style\Shading
*/
private $shading;
-
+
/**
* Ignore Spacing Above and Below When Using Identical Styles
*
@@ -420,7 +420,7 @@ class Paragraph extends Border
/**
* Get space before paragraph
*
- * @return integer
+ * @return int
*/
public function getSpaceBefore()
{
@@ -441,7 +441,7 @@ class Paragraph extends Border
/**
* Get space after paragraph
*
- * @return integer
+ * @return int
*/
public function getSpaceAfter()
{
@@ -495,22 +495,22 @@ class Paragraph extends Border
*
* @param int|float|string $lineHeight
*
- * @return self
- *
* @throws \PhpOffice\PhpWord\Exception\InvalidStyleException
+ * @return self
*/
public function setLineHeight($lineHeight)
{
if (is_string($lineHeight)) {
- $lineHeight = floatval(preg_replace('/[^0-9\.\,]/', '', $lineHeight));
+ $lineHeight = (float) (preg_replace('/[^0-9\.\,]/', '', $lineHeight));
}
- if ((!is_integer($lineHeight) && !is_float($lineHeight)) || !$lineHeight) {
+ if ((!is_int($lineHeight) && !is_float($lineHeight)) || !$lineHeight) {
throw new InvalidStyleException('Line height must be a valid number');
}
$this->lineHeight = $lineHeight;
$this->setSpacing($lineHeight * self::LINE_HEIGHT);
+
return $this;
}
@@ -767,7 +767,7 @@ class Paragraph extends Border
public function setContextualSpacing($contextualSpacing)
{
$this->contextualSpacing = $contextualSpacing;
-
+
return $this;
}
diff --git a/src/PhpWord/Style/Row.php b/src/PhpWord/Style/Row.php
index 5be03b69..b56c6f5f 100644
--- a/src/PhpWord/Style/Row.php
+++ b/src/PhpWord/Style/Row.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Style/Section.php b/src/PhpWord/Style/Section.php
index be8a3aad..476846f5 100644
--- a/src/PhpWord/Style/Section.php
+++ b/src/PhpWord/Style/Section.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -48,7 +48,7 @@ class Section extends Border
* Page Orientation
*
* @var string
- * @link http://www.schemacentral.com/sc/ooxml/a-w_orient-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/a-w_orient-1.html
*/
private $orientation = self::ORIENTATION_PORTRAIT;
@@ -105,7 +105,7 @@ class Section extends Border
* Page gutter spacing
*
* @var int|float
- * @link http://www.schemacentral.com/sc/ooxml/e-w_pgMar-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_pgMar-1.html
*/
private $gutter = self::DEFAULT_GUTTER;
@@ -162,7 +162,7 @@ class Section extends Border
* Line numbering
*
* @var \PhpOffice\PhpWord\Style\LineNumbering
- * @link http://www.schemacentral.com/sc/ooxml/e-w_lnNumType-1.html
+ * @see http://www.schemacentral.com/sc/ooxml/e-w_lnNumType-1.html
*/
private $lineNumbering;
@@ -504,6 +504,7 @@ class Section extends Border
public function setPageNumberingStart($pageNumberingStart = null)
{
$this->pageNumberingStart = $pageNumberingStart;
+
return $this;
}
@@ -572,6 +573,7 @@ class Section extends Border
public function setBreakType($value = null)
{
$this->breakType = $value;
+
return $this;
}
diff --git a/src/PhpWord/Style/Shading.php b/src/PhpWord/Style/Shading.php
index ab4fce82..eeb055b2 100644
--- a/src/PhpWord/Style/Shading.php
+++ b/src/PhpWord/Style/Shading.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,7 +20,7 @@ namespace PhpOffice\PhpWord\Style;
/**
* Shading style
*
- * @link http://www.schemacentral.com/sc/ooxml/t-w_CT_Shd.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-w_CT_Shd.html
* @since 0.10.0
*/
class Shading extends AbstractStyle
@@ -29,7 +29,7 @@ class Shading extends AbstractStyle
* Pattern constants (partly)
*
* @const string
- * @link http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html
*/
const PATTERN_CLEAR = 'clear'; // No pattern
const PATTERN_SOLID = 'solid'; // 100% fill pattern
@@ -43,7 +43,7 @@ class Shading extends AbstractStyle
* Shading pattern
*
* @var string
- * @link http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-w_ST_Shd.html
*/
private $pattern = self::PATTERN_CLEAR;
@@ -91,7 +91,7 @@ class Shading extends AbstractStyle
{
$enum = array(
self::PATTERN_CLEAR, self::PATTERN_SOLID, self::PATTERN_HSTRIPE,
- self::PATTERN_VSTRIPE, self::PATTERN_DSTRIPE, self::PATTERN_HCROSS, self::PATTERN_DCROSS
+ self::PATTERN_VSTRIPE, self::PATTERN_DSTRIPE, self::PATTERN_HCROSS, self::PATTERN_DCROSS,
);
$this->pattern = $this->setEnumVal($value, $enum, $this->pattern);
diff --git a/src/PhpWord/Style/Shadow.php b/src/PhpWord/Style/Shadow.php
index f8f693a9..71d1e3e0 100644
--- a/src/PhpWord/Style/Shadow.php
+++ b/src/PhpWord/Style/Shadow.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,7 +20,7 @@ namespace PhpOffice\PhpWord\Style;
/**
* Shadow style
*
- * @link http://www.schemacentral.com/sc/ooxml/t-v_CT_Shadow.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-v_CT_Shadow.html
* @since 0.12.0
*/
class Shadow extends AbstractStyle
diff --git a/src/PhpWord/Style/Shape.php b/src/PhpWord/Style/Shape.php
index 01b61588..fc84241d 100644
--- a/src/PhpWord/Style/Shape.php
+++ b/src/PhpWord/Style/Shape.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Style/Spacing.php b/src/PhpWord/Style/Spacing.php
index 8d7cfeb2..e0eee374 100644
--- a/src/PhpWord/Style/Spacing.php
+++ b/src/PhpWord/Style/Spacing.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -20,7 +20,7 @@ namespace PhpOffice\PhpWord\Style;
/**
* Spacing between lines and above/below paragraph style
*
- * @link http://www.schemacentral.com/sc/ooxml/t-w_CT_Spacing.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-w_CT_Spacing.html
* @since 0.10.0
*/
class Spacing extends AbstractStyle
diff --git a/src/PhpWord/Style/TOC.php b/src/PhpWord/Style/TOC.php
index eb4b2253..938e6de1 100644
--- a/src/PhpWord/Style/TOC.php
+++ b/src/PhpWord/Style/TOC.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Style/Tab.php b/src/PhpWord/Style/Tab.php
index 33e518c8..09e49e02 100644
--- a/src/PhpWord/Style/Tab.php
+++ b/src/PhpWord/Style/Tab.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -27,25 +27,25 @@ class Tab extends AbstractStyle
*
* @const string
*/
- const TAB_STOP_CLEAR = 'clear';
- const TAB_STOP_LEFT = 'left';
- const TAB_STOP_CENTER = 'center';
- const TAB_STOP_RIGHT = 'right';
+ const TAB_STOP_CLEAR = 'clear';
+ const TAB_STOP_LEFT = 'left';
+ const TAB_STOP_CENTER = 'center';
+ const TAB_STOP_RIGHT = 'right';
const TAB_STOP_DECIMAL = 'decimal';
- const TAB_STOP_BAR = 'bar';
- const TAB_STOP_NUM = 'num';
+ const TAB_STOP_BAR = 'bar';
+ const TAB_STOP_NUM = 'num';
/**
* Tab leader types
*
* @const string
*/
- const TAB_LEADER_NONE = 'none';
- const TAB_LEADER_DOT = 'dot';
- const TAB_LEADER_HYPHEN = 'hyphen';
+ const TAB_LEADER_NONE = 'none';
+ const TAB_LEADER_DOT = 'dot';
+ const TAB_LEADER_HYPHEN = 'hyphen';
const TAB_LEADER_UNDERSCORE = 'underscore';
- const TAB_LEADER_HEAVY = 'heavy';
- const TAB_LEADER_MIDDLEDOT = 'middleDot';
+ const TAB_LEADER_HEAVY = 'heavy';
+ const TAB_LEADER_MIDDLEDOT = 'middleDot';
/**
* Tab stop type
@@ -73,19 +73,19 @@ class Tab extends AbstractStyle
* must conform to the values put forth in the schema. If they do not
* they will be changed to default values.
*
- * @param string $type Defaults to 'clear' if value is not possible.
- * @param int $position Must be numeric; otherwise defaults to 0.
- * @param string $leader Defaults to null if value is not possible.
+ * @param string $type Defaults to 'clear' if value is not possible
+ * @param int $position Must be numeric; otherwise defaults to 0
+ * @param string $leader Defaults to null if value is not possible
*/
public function __construct($type = null, $position = 0, $leader = null)
{
$stopTypes = array(
- self::TAB_STOP_CLEAR, self::TAB_STOP_LEFT,self::TAB_STOP_CENTER,
- self::TAB_STOP_RIGHT, self::TAB_STOP_DECIMAL, self::TAB_STOP_BAR, self::TAB_STOP_NUM
+ self::TAB_STOP_CLEAR, self::TAB_STOP_LEFT, self::TAB_STOP_CENTER,
+ self::TAB_STOP_RIGHT, self::TAB_STOP_DECIMAL, self::TAB_STOP_BAR, self::TAB_STOP_NUM,
);
$leaderTypes = array(
self::TAB_LEADER_NONE, self::TAB_LEADER_DOT, self::TAB_LEADER_HYPHEN,
- self::TAB_LEADER_UNDERSCORE, self::TAB_LEADER_HEAVY, self::TAB_LEADER_MIDDLEDOT
+ self::TAB_LEADER_UNDERSCORE, self::TAB_LEADER_HEAVY, self::TAB_LEADER_MIDDLEDOT,
);
$this->type = $this->setEnumVal($type, $stopTypes, $this->type);
diff --git a/src/PhpWord/Style/Table.php b/src/PhpWord/Style/Table.php
index a542af7b..a3d454f3 100644
--- a/src/PhpWord/Style/Table.php
+++ b/src/PhpWord/Style/Table.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -133,15 +133,7 @@ class Table extends Border
if ($firstRowStyle !== null && is_array($firstRowStyle)) {
$this->firstRowStyle = clone $this;
$this->firstRowStyle->isFirstRow = true;
- unset($this->firstRowStyle->firstRowStyle);
- unset($this->firstRowStyle->borderInsideHSize);
- unset($this->firstRowStyle->borderInsideHColor);
- unset($this->firstRowStyle->borderInsideVSize);
- unset($this->firstRowStyle->borderInsideVColor);
- unset($this->firstRowStyle->cellMarginTop);
- unset($this->firstRowStyle->cellMarginLeft);
- unset($this->firstRowStyle->cellMarginRight);
- unset($this->firstRowStyle->cellMarginBottom);
+ unset($this->firstRowStyle->firstRowStyle, $this->firstRowStyle->borderInsideHSize, $this->firstRowStyle->borderInsideHColor, $this->firstRowStyle->borderInsideVSize, $this->firstRowStyle->borderInsideVColor, $this->firstRowStyle->cellMarginTop, $this->firstRowStyle->cellMarginLeft, $this->firstRowStyle->cellMarginRight, $this->firstRowStyle->cellMarginBottom);
$this->firstRowStyle->setStyleByArray($firstRowStyle);
}
@@ -190,7 +182,7 @@ class Table extends Border
/**
* Get TLRBHV Border Size
*
- * @return integer[]
+ * @return int[]
*/
public function getBorderSize()
{
@@ -428,7 +420,7 @@ class Table extends Border
/**
* Get cell margin
*
- * @return integer[]
+ * @return int[]
*/
public function getCellMargin()
{
@@ -436,7 +428,7 @@ class Table extends Border
$this->cellMarginTop,
$this->cellMarginLeft,
$this->cellMarginRight,
- $this->cellMarginBottom
+ $this->cellMarginBottom,
);
}
diff --git a/src/PhpWord/Style/TextBox.php b/src/PhpWord/Style/TextBox.php
index 6783cd18..91adc0af 100644
--- a/src/PhpWord/Style/TextBox.php
+++ b/src/PhpWord/Style/TextBox.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -70,7 +70,6 @@ class TextBox extends Image
* Set margin top.
*
* @param int $value
- * @return void
*/
public function setInnerMarginTop($value = null)
{
@@ -91,7 +90,6 @@ class TextBox extends Image
* Set margin left.
*
* @param int $value
- * @return void
*/
public function setInnerMarginLeft($value = null)
{
@@ -112,7 +110,6 @@ class TextBox extends Image
* Set margin right.
*
* @param int $value
- * @return void
*/
public function setInnerMarginRight($value = null)
{
@@ -133,7 +130,6 @@ class TextBox extends Image
* Set margin bottom.
*
* @param int $value
- * @return void
*/
public function setInnerMarginBottom($value = null)
{
@@ -154,7 +150,6 @@ class TextBox extends Image
* Set TLRB cell margin.
*
* @param int $value Margin in twips
- * @return void
*/
public function setInnerMargin($value = null)
{
@@ -167,7 +162,7 @@ class TextBox extends Image
/**
* Get cell margin
*
- * @return integer[]
+ * @return int[]
*/
public function getInnerMargin()
{
@@ -197,7 +192,6 @@ class TextBox extends Image
* Set border size.
*
* @param int $value Size in points
- * @return void
*/
public function setBorderSize($value = null)
{
@@ -218,7 +212,6 @@ class TextBox extends Image
* Set border color.
*
* @param string $value
- * @return void
*/
public function setBorderColor($value = null)
{
diff --git a/src/PhpWord/Template.php b/src/PhpWord/Template.php
index 87ccd8ed..a4769927 100644
--- a/src/PhpWord/Template.php
+++ b/src/PhpWord/Template.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
index 2f6d6258..c46038ee 100644
--- a/src/PhpWord/TemplateProcessor.php
+++ b/src/PhpWord/TemplateProcessor.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,35 +37,35 @@ class TemplateProcessor
protected $zipClass;
/**
- * @var string Temporary document filename (with path).
+ * @var string Temporary document filename (with path)
*/
protected $tempDocumentFilename;
/**
- * Content of main document part (in XML format) of the temporary document.
+ * Content of main document part (in XML format) of the temporary document
*
* @var string
*/
protected $tempDocumentMainPart;
/**
- * Content of headers (in XML format) of the temporary document.
+ * Content of headers (in XML format) of the temporary document
*
* @var string[]
*/
protected $tempDocumentHeaders = array();
/**
- * Content of footers (in XML format) of the temporary document.
+ * Content of footers (in XML format) of the temporary document
*
* @var string[]
*/
protected $tempDocumentFooters = array();
/**
- * @since 0.12.0 Throws CreateTemporaryFileException and CopyFileException instead of Exception.
+ * @since 0.12.0 Throws CreateTemporaryFileException and CopyFileException instead of Exception
*
- * @param string $documentTemplate The fully qualified template filename.
+ * @param string $documentTemplate The fully qualified template filename
*
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
* @throws \PhpOffice\PhpWord\Exception\CopyFileException
@@ -107,9 +107,9 @@ class TemplateProcessor
* @param string $xml
* @param \XSLTProcessor $xsltProcessor
*
- * @return string
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ *
+ * @return string
*/
protected function transformSingleXml($xml, $xsltProcessor)
{
@@ -155,8 +155,6 @@ class TemplateProcessor
* @param array $xslOptions
* @param string $xslOptionsUri
*
- * @return void
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function applyXslStyleSheet($xslDomDocument, $xslOptions = array(), $xslOptionsUri = '')
@@ -204,9 +202,7 @@ class TemplateProcessor
/**
* @param mixed $search
* @param mixed $replace
- * @param integer $limit
- *
- * @return void
+ * @param int $limit
*/
public function setValue($search, $replace, $limit = self::MAXIMUM_REPLACEMENTS_DEFAULT)
{
@@ -260,9 +256,7 @@ class TemplateProcessor
* Clone a table row in a template document.
*
* @param string $search
- * @param integer $numberOfClones
- *
- * @return void
+ * @param int $numberOfClones
*
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
@@ -274,7 +268,7 @@ class TemplateProcessor
$tagPos = strpos($this->tempDocumentMainPart, $search);
if (!$tagPos) {
- throw new Exception("Can not clone row, template variable not found or variable contains markup.");
+ throw new Exception('Can not clone row, template variable not found or variable contains markup.');
}
$rowStart = $this->findRowStart($tagPos);
@@ -319,8 +313,8 @@ class TemplateProcessor
* Clone a block.
*
* @param string $blockname
- * @param integer $clones
- * @param boolean $replace
+ * @param int $clones
+ * @param bool $replace
*
* @return string|null
*/
@@ -357,8 +351,6 @@ class TemplateProcessor
*
* @param string $blockname
* @param string $replacement
- *
- * @return void
*/
public function replaceBlock($blockname, $replacement)
{
@@ -381,8 +373,6 @@ class TemplateProcessor
* Delete a block of text.
*
* @param string $blockname
- *
- * @return void
*/
public function deleteBlock($blockname)
{
@@ -392,9 +382,9 @@ class TemplateProcessor
/**
* Saves the result document.
*
- * @return string
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ *
+ * @return string
*/
public function save()
{
@@ -422,8 +412,6 @@ class TemplateProcessor
* @since 0.8.0
*
* @param string $fileName
- *
- * @return void
*/
public function saveAs($fileName)
{
@@ -447,7 +435,7 @@ class TemplateProcessor
* Finds parts of broken macros and sticks them together.
* Macros, while being edited, could be implicitly broken by some of the word processors.
*
- * @param string $documentPart The document part in XML representation.
+ * @param string $documentPart The document part in XML representation
*
* @return string
*/
@@ -472,7 +460,7 @@ class TemplateProcessor
* @param mixed $search
* @param mixed $replace
* @param string $documentPartXML
- * @param integer $limit
+ * @param int $limit
*
* @return string
*/
@@ -481,10 +469,10 @@ class TemplateProcessor
// Note: we can't use the same function for both cases here, because of performance considerations.
if (self::MAXIMUM_REPLACEMENTS_DEFAULT === $limit) {
return str_replace($search, $replace, $documentPartXML);
- } else {
- $regExpEscaper = new RegExp();
- return preg_replace($regExpEscaper->escape($search), $replace, $documentPartXML, $limit);
}
+ $regExpEscaper = new RegExp();
+
+ return preg_replace($regExpEscaper->escape($search), $replace, $documentPartXML, $limit);
}
/**
@@ -504,7 +492,7 @@ class TemplateProcessor
/**
* Get the name of the header file for $index.
*
- * @param integer $index
+ * @param int $index
*
* @return string
*/
@@ -524,7 +512,7 @@ class TemplateProcessor
/**
* Get the name of the footer file for $index.
*
- * @param integer $index
+ * @param int $index
*
* @return string
*/
@@ -536,11 +524,11 @@ class TemplateProcessor
/**
* Find the start position of the nearest table row before $offset.
*
- * @param integer $offset
- *
- * @return integer
+ * @param int $offset
*
* @throws \PhpOffice\PhpWord\Exception\Exception
+ *
+ * @return int
*/
protected function findRowStart($offset)
{
@@ -559,9 +547,9 @@ class TemplateProcessor
/**
* Find the end position of the nearest table row after $offset.
*
- * @param integer $offset
+ * @param int $offset
*
- * @return integer
+ * @return int
*/
protected function findRowEnd($offset)
{
@@ -571,8 +559,8 @@ class TemplateProcessor
/**
* Get a slice of a string.
*
- * @param integer $startPosition
- * @param integer $endPosition
+ * @param int $startPosition
+ * @param int $endPosition
*
* @return string
*/
diff --git a/src/PhpWord/Writer/AbstractWriter.php b/src/PhpWord/Writer/AbstractWriter.php
index 78ec5acd..09a00990 100644
--- a/src/PhpWord/Writer/AbstractWriter.php
+++ b/src/PhpWord/Writer/AbstractWriter.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -96,17 +96,15 @@ abstract class AbstractWriter implements WriterInterface
/**
* Get PhpWord object
*
- * @return \PhpOffice\PhpWord\PhpWord
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ * @return \PhpOffice\PhpWord\PhpWord
*/
public function getPhpWord()
{
if (!is_null($this->phpWord)) {
return $this->phpWord;
- } else {
- throw new Exception("No PhpWord assigned.");
}
+ throw new Exception('No PhpWord assigned.');
}
/**
@@ -118,6 +116,7 @@ abstract class AbstractWriter implements WriterInterface
public function setPhpWord(PhpWord $phpWord = null)
{
$this->phpWord = $phpWord;
+
return $this;
}
@@ -131,9 +130,9 @@ abstract class AbstractWriter implements WriterInterface
{
if ($partName != '' && isset($this->writerParts[strtolower($partName)])) {
return $this->writerParts[strtolower($partName)];
- } else {
- return null;
}
+
+ return null;
}
/**
@@ -152,9 +151,8 @@ abstract class AbstractWriter implements WriterInterface
* @param bool $value
* @param string $directory
*
- * @return self
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ * @return self
*/
public function setUseDiskCaching($value = false, $directory = null)
{
@@ -236,8 +234,6 @@ abstract class AbstractWriter implements WriterInterface
/**
* Cleanup temporary file.
*
- * @return void
- *
* @throws \PhpOffice\PhpWord\Exception\CopyFileException
*/
protected function cleanupTempFile()
@@ -257,8 +253,6 @@ abstract class AbstractWriter implements WriterInterface
/**
* Clear temporary directory.
- *
- * @return void
*/
protected function clearTempDir()
{
@@ -272,9 +266,9 @@ abstract class AbstractWriter implements WriterInterface
*
* @param string $filename
*
- * @return \PhpOffice\PhpWord\Shared\ZipArchive
- *
* @throws \Exception
+ *
+ * @return \PhpOffice\PhpWord\Shared\ZipArchive
*/
protected function getZipArchive($filename)
{
@@ -305,9 +299,9 @@ abstract class AbstractWriter implements WriterInterface
*
* @param string $filename
*
- * @return resource
- *
* @throws \Exception
+ *
+ * @return resource
*/
protected function openFile($filename)
{
@@ -330,7 +324,6 @@ abstract class AbstractWriter implements WriterInterface
*
* @param resource $fileHandle
* @param string $content
- * @return void
*/
protected function writeFile($fileHandle, $content)
{
@@ -344,7 +337,6 @@ abstract class AbstractWriter implements WriterInterface
*
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
* @param mixed $elements
- * @return void
*/
protected function addFilesToPackage(ZipArchive $zip, $elements)
{
@@ -380,7 +372,6 @@ abstract class AbstractWriter implements WriterInterface
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zipPackage
* @param string $source
* @param string $target
- * @return void
*/
protected function addFileToPackage($zipPackage, $source, $target)
{
@@ -390,7 +381,7 @@ abstract class AbstractWriter implements WriterInterface
$source = substr($source, 6);
list($zipFilename, $imageFilename) = explode('#', $source);
- $zip = new ZipArchive;
+ $zip = new ZipArchive();
if ($zip->open($zipFilename) !== false) {
if ($zip->locateName($imageFilename)) {
$zip->extractTo($this->getTempDir(), $imageFilename);
@@ -411,17 +402,16 @@ abstract class AbstractWriter implements WriterInterface
* Delete directory.
*
* @param string $dir
- * @return void
*/
private function deleteDir($dir)
{
foreach (scandir($dir) as $file) {
if ($file === '.' || $file === '..') {
continue;
- } elseif (is_file($dir . "/" . $file)) {
- unlink($dir . "/" . $file);
- } elseif (is_dir($dir . "/" . $file)) {
- $this->deleteDir($dir . "/" . $file);
+ } elseif (is_file($dir . '/' . $file)) {
+ unlink($dir . '/' . $file);
+ } elseif (is_dir($dir . '/' . $file)) {
+ $this->deleteDir($dir . '/' . $file);
}
}
diff --git a/src/PhpWord/Writer/HTML.php b/src/PhpWord/Writer/HTML.php
index 5668f184..9b098dd8 100644
--- a/src/PhpWord/Writer/HTML.php
+++ b/src/PhpWord/Writer/HTML.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -30,7 +30,7 @@ class HTML extends AbstractWriter implements WriterInterface
/**
* Is the current writer creating PDF?
*
- * @var boolean
+ * @var bool
*/
protected $isPdf = false;
@@ -65,8 +65,6 @@ class HTML extends AbstractWriter implements WriterInterface
*
* @param string $filename
*
- * @return void
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function save($filename = null)
@@ -119,7 +117,6 @@ class HTML extends AbstractWriter implements WriterInterface
*
* @param int $noteId
* @param string $noteMark
- * @return void
*/
public function addNote($noteId, $noteMark)
{
diff --git a/src/PhpWord/Writer/HTML/Element/AbstractElement.php b/src/PhpWord/Writer/HTML/Element/AbstractElement.php
index 294d6de7..f6e06258 100644
--- a/src/PhpWord/Writer/HTML/Element/AbstractElement.php
+++ b/src/PhpWord/Writer/HTML/Element/AbstractElement.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -78,7 +78,6 @@ abstract class AbstractElement
* Set without paragraph.
*
* @param bool $value
- * @return void
*/
public function setWithoutP($value)
{
diff --git a/src/PhpWord/Writer/HTML/Element/Container.php b/src/PhpWord/Writer/HTML/Element/Container.php
index 88384a12..677b6173 100644
--- a/src/PhpWord/Writer/HTML/Element/Container.php
+++ b/src/PhpWord/Writer/HTML/Element/Container.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Element/Endnote.php b/src/PhpWord/Writer/HTML/Element/Endnote.php
index b049e437..c4a3e436 100644
--- a/src/PhpWord/Writer/HTML/Element/Endnote.php
+++ b/src/PhpWord/Writer/HTML/Element/Endnote.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Element/Footnote.php b/src/PhpWord/Writer/HTML/Element/Footnote.php
index b5aa0a0a..60b246f8 100644
--- a/src/PhpWord/Writer/HTML/Element/Footnote.php
+++ b/src/PhpWord/Writer/HTML/Element/Footnote.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Element/Image.php b/src/PhpWord/Writer/HTML/Element/Image.php
index 24e35957..3e516b53 100644
--- a/src/PhpWord/Writer/HTML/Element/Image.php
+++ b/src/PhpWord/Writer/HTML/Element/Image.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Element/Link.php b/src/PhpWord/Writer/HTML/Element/Link.php
index bff57cfc..bdea985a 100644
--- a/src/PhpWord/Writer/HTML/Element/Link.php
+++ b/src/PhpWord/Writer/HTML/Element/Link.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Element/ListItem.php b/src/PhpWord/Writer/HTML/Element/ListItem.php
index d8b1e4ed..02b25eb9 100644
--- a/src/PhpWord/Writer/HTML/Element/ListItem.php
+++ b/src/PhpWord/Writer/HTML/Element/ListItem.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Element/PageBreak.php b/src/PhpWord/Writer/HTML/Element/PageBreak.php
index 8b332dcf..5cab2724 100644
--- a/src/PhpWord/Writer/HTML/Element/PageBreak.php
+++ b/src/PhpWord/Writer/HTML/Element/PageBreak.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -39,6 +39,6 @@ class PageBreak extends TextBreak
return '';
}
- return "";
+ return '';
}
}
diff --git a/src/PhpWord/Writer/HTML/Element/Table.php b/src/PhpWord/Writer/HTML/Element/Table.php
index 9025f01a..c7d8670b 100644
--- a/src/PhpWord/Writer/HTML/Element/Table.php
+++ b/src/PhpWord/Writer/HTML/Element/Table.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Element/Text.php b/src/PhpWord/Writer/HTML/Element/Text.php
index 87451595..ed1ba4a3 100644
--- a/src/PhpWord/Writer/HTML/Element/Text.php
+++ b/src/PhpWord/Writer/HTML/Element/Text.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -89,7 +89,6 @@ class Text extends AbstractElement
* Set opening text.
*
* @param string $value
- * @return void
*/
public function setOpeningText($value)
{
@@ -100,7 +99,6 @@ class Text extends AbstractElement
* Set closing text.
*
* @param string $value
- * @return void
*/
public function setClosingText($value)
{
@@ -141,7 +139,7 @@ class Text extends AbstractElement
$content .= $this->closingText;
}
- $content .= "" . PHP_EOL;
+ $content .= '' . PHP_EOL;
}
return $content;
@@ -177,8 +175,6 @@ class Text extends AbstractElement
/**
* Get font style.
- *
- * @return void
*/
private function getFontStyle()
{
@@ -194,7 +190,7 @@ class Text extends AbstractElement
if ($style) {
$attribute = $fStyleIsObject ? 'style' : 'class';
$this->openingTags = "";
- $this->closingTags = "";
+ $this->closingTags = '';
}
}
}
diff --git a/src/PhpWord/Writer/HTML/Element/TextBreak.php b/src/PhpWord/Writer/HTML/Element/TextBreak.php
index 9b23d739..93ab924a 100644
--- a/src/PhpWord/Writer/HTML/Element/TextBreak.php
+++ b/src/PhpWord/Writer/HTML/Element/TextBreak.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Element/TextRun.php b/src/PhpWord/Writer/HTML/Element/TextRun.php
index 492f7597..d7461539 100644
--- a/src/PhpWord/Writer/HTML/Element/TextRun.php
+++ b/src/PhpWord/Writer/HTML/Element/TextRun.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Element/Title.php b/src/PhpWord/Writer/HTML/Element/Title.php
index 23c29938..ee8f271b 100644
--- a/src/PhpWord/Writer/HTML/Element/Title.php
+++ b/src/PhpWord/Writer/HTML/Element/Title.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Part/AbstractPart.php b/src/PhpWord/Writer/HTML/Part/AbstractPart.php
index 584e4489..7b6e0c3e 100644
--- a/src/PhpWord/Writer/HTML/Part/AbstractPart.php
+++ b/src/PhpWord/Writer/HTML/Part/AbstractPart.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,12 +35,12 @@ abstract class AbstractPart
* @var \Zend\Escaper\Escaper
*/
protected $escaper;
-
+
public function __construct()
{
$this->escaper = new Escaper();
}
-
+
/**
* @return string
*/
@@ -48,8 +48,6 @@ abstract class AbstractPart
/**
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
- *
- * @return void
*/
public function setParentWriter(AbstractWriter $writer = null)
{
@@ -57,16 +55,15 @@ abstract class AbstractPart
}
/**
- * @return \PhpOffice\PhpWord\Writer\AbstractWriter
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ *
+ * @return \PhpOffice\PhpWord\Writer\AbstractWriter
*/
public function getParentWriter()
{
if ($this->parentWriter !== null) {
return $this->parentWriter;
- } else {
- throw new Exception('No parent WriterInterface assigned.');
}
+ throw new Exception('No parent WriterInterface assigned.');
}
}
diff --git a/src/PhpWord/Writer/HTML/Part/Body.php b/src/PhpWord/Writer/HTML/Part/Body.php
index 0d852a57..eea17350 100644
--- a/src/PhpWord/Writer/HTML/Part/Body.php
+++ b/src/PhpWord/Writer/HTML/Part/Body.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -66,7 +66,7 @@ class Body extends AbstractPart
$content = '';
if (!empty($notes)) {
- $content .= "
" . PHP_EOL;
+ $content .= '
' . PHP_EOL;
foreach ($notes as $noteId => $noteMark) {
list($noteType, $noteTypeId) = explode('-', $noteMark);
$method = 'get' . ($noteType == 'endnote' ? 'Endnotes' : 'Footnotes');
diff --git a/src/PhpWord/Writer/HTML/Part/Head.php b/src/PhpWord/Writer/HTML/Part/Head.php
index fa4c3833..f4d63014 100644
--- a/src/PhpWord/Writer/HTML/Part/Head.php
+++ b/src/PhpWord/Writer/HTML/Part/Head.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -48,7 +48,7 @@ class Head extends AbstractPart
'keywords' => '',
'category' => '',
'company' => '',
- 'manager' => ''
+ 'manager' => '',
);
$title = $docProps->getTitle();
$title = ($title != '') ? $title : 'PHPWord';
@@ -60,11 +60,11 @@ class Head extends AbstractPart
$content .= '' . $title . '' . PHP_EOL;
foreach ($propertiesMapping as $key => $value) {
$value = ($value == '') ? $key : $value;
- $method = "get" . $key;
+ $method = 'get' . $key;
if ($docProps->$method() != '') {
$content .= '' . PHP_EOL;
+ . ' />' . PHP_EOL;
}
}
$content .= $this->writeStyles();
@@ -86,22 +86,22 @@ class Head extends AbstractPart
$defaultStyles = array(
'*' => array(
'font-family' => Settings::getDefaultFontName(),
- 'font-size' => Settings::getDefaultFontSize() . 'pt',
+ 'font-size' => Settings::getDefaultFontSize() . 'pt',
),
'a.NoteRef' => array(
'text-decoration' => 'none',
),
'hr' => array(
- 'height' => '1px',
- 'padding' => '0',
- 'margin' => '1em 0',
- 'border' => '0',
+ 'height' => '1px',
+ 'padding' => '0',
+ 'margin' => '1em 0',
+ 'border' => '0',
'border-top' => '1px solid #CCC',
),
'table' => array(
- 'border' => '1px solid black',
+ 'border' => '1px solid black',
'border-spacing' => '0px',
- 'width' => '100%',
+ 'width ' => '100%',
),
'td' => array(
'border' => '1px solid black',
@@ -123,11 +123,11 @@ class Head extends AbstractPart
} else {
$name = '.' . $name;
}
- $css .= "{$name} {" . $styleWriter->write() . '}' . PHP_EOL;
+ $css .= "{$name} {" . $styleWriter->write() . '}' . PHP_EOL;
} elseif ($style instanceof Paragraph) {
$styleWriter = new ParagraphStyleWriter($style);
$name = '.' . $name;
- $css .= "{$name} {" . $styleWriter->write() . '}' . PHP_EOL;
+ $css .= "{$name} {" . $styleWriter->write() . '}' . PHP_EOL;
}
}
}
diff --git a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php
index 10a0a9ad..fa27c085 100644
--- a/src/PhpWord/Writer/HTML/Style/AbstractStyle.php
+++ b/src/PhpWord/Writer/HTML/Style/AbstractStyle.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -59,7 +59,6 @@ abstract class AbstractStyle
* Set parent writer.
*
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
- * @return void
*/
public function setParentWriter($writer)
{
diff --git a/src/PhpWord/Writer/HTML/Style/Font.php b/src/PhpWord/Writer/HTML/Style/Font.php
index c202af93..cb96cf64 100644
--- a/src/PhpWord/Writer/HTML/Style/Font.php
+++ b/src/PhpWord/Writer/HTML/Style/Font.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Style/Generic.php b/src/PhpWord/Writer/HTML/Style/Generic.php
index e3d2b352..73830707 100644
--- a/src/PhpWord/Writer/HTML/Style/Generic.php
+++ b/src/PhpWord/Writer/HTML/Style/Generic.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Style/Image.php b/src/PhpWord/Writer/HTML/Style/Image.php
index 36a9feca..178b1434 100644
--- a/src/PhpWord/Writer/HTML/Style/Image.php
+++ b/src/PhpWord/Writer/HTML/Style/Image.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/HTML/Style/Paragraph.php b/src/PhpWord/Writer/HTML/Style/Paragraph.php
index 593c6dca..e264ead0 100644
--- a/src/PhpWord/Writer/HTML/Style/Paragraph.php
+++ b/src/PhpWord/Writer/HTML/Style/Paragraph.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -49,11 +49,9 @@ class Paragraph extends AbstractStyle
case Jc::LEFT:
$textAlign = 'left';
break;
-
case Jc::CENTER:
$textAlign = 'center';
break;
-
case Jc::END:
case Jc::MEDIUM_KASHIDA:
case Jc::HIGH_KASHIDA:
@@ -61,14 +59,12 @@ class Paragraph extends AbstractStyle
case Jc::RIGHT:
$textAlign = 'right';
break;
-
case Jc::BOTH:
case Jc::DISTRIBUTE:
case Jc::THAI_DISTRIBUTE:
case Jc::JUSTIFY:
$textAlign = 'justify';
break;
-
default:
$textAlign = 'left';
break;
diff --git a/src/PhpWord/Writer/ODText.php b/src/PhpWord/Writer/ODText.php
index 40bc6c2f..7158874c 100644
--- a/src/PhpWord/Writer/ODText.php
+++ b/src/PhpWord/Writer/ODText.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -63,7 +63,6 @@ class ODText extends AbstractWriter implements WriterInterface
* Save PhpWord to file.
*
* @param string $filename
- * @return void
*/
public function save($filename = null)
{
diff --git a/src/PhpWord/Writer/ODText/Element/AbstractElement.php b/src/PhpWord/Writer/ODText/Element/AbstractElement.php
index 0ca43e4f..481995ff 100644
--- a/src/PhpWord/Writer/ODText/Element/AbstractElement.php
+++ b/src/PhpWord/Writer/ODText/Element/AbstractElement.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/ODText/Element/Container.php b/src/PhpWord/Writer/ODText/Element/Container.php
index 212cd184..112e71e8 100644
--- a/src/PhpWord/Writer/ODText/Element/Container.php
+++ b/src/PhpWord/Writer/ODText/Element/Container.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/ODText/Element/Image.php b/src/PhpWord/Writer/ODText/Element/Image.php
index c6b16cfc..2c0b4727 100644
--- a/src/PhpWord/Writer/ODText/Element/Image.php
+++ b/src/PhpWord/Writer/ODText/Element/Image.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/ODText/Element/Link.php b/src/PhpWord/Writer/ODText/Element/Link.php
index cb0226a3..c996ab59 100644
--- a/src/PhpWord/Writer/ODText/Element/Link.php
+++ b/src/PhpWord/Writer/ODText/Element/Link.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/ODText/Element/Table.php b/src/PhpWord/Writer/ODText/Element/Table.php
index f6a2f845..cdc2a0e3 100644
--- a/src/PhpWord/Writer/ODText/Element/Table.php
+++ b/src/PhpWord/Writer/ODText/Element/Table.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/ODText/Element/Text.php b/src/PhpWord/Writer/ODText/Element/Text.php
index cff68481..3b06217d 100644
--- a/src/PhpWord/Writer/ODText/Element/Text.php
+++ b/src/PhpWord/Writer/ODText/Element/Text.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -47,42 +47,42 @@ class Text extends AbstractElement
if ($fStyleIsObject) {
// Don't never be the case, because I browse all sections for cleaning all styles not declared
throw new Exception('PhpWord : $fStyleIsObject wouldn\'t be an object');
- } else {
- if (!$this->withoutP) {
- $xmlWriter->startElement('text:p'); // text:p
+ }
+
+ if (!$this->withoutP) {
+ $xmlWriter->startElement('text:p'); // text:p
+ }
+ if (empty($fontStyle)) {
+ if (empty($paragraphStyle)) {
+ $xmlWriter->writeAttribute('text:style-name', 'P1');
+ } elseif (is_string($paragraphStyle)) {
+ $xmlWriter->writeAttribute('text:style-name', $paragraphStyle);
}
- if (empty($fontStyle)) {
- if (empty($paragraphStyle)) {
- $xmlWriter->writeAttribute('text:style-name', 'P1');
- } elseif (is_string($paragraphStyle)) {
- $xmlWriter->writeAttribute('text:style-name', $paragraphStyle);
- }
- if (Settings::isOutputEscapingEnabled()) {
- $xmlWriter->text($element->getText());
- } else {
- $xmlWriter->writeRaw($element->getText());
- }
+ if (Settings::isOutputEscapingEnabled()) {
+ $xmlWriter->text($element->getText());
} else {
- if (empty($paragraphStyle)) {
- $xmlWriter->writeAttribute('text:style-name', 'Standard');
- } elseif (is_string($paragraphStyle)) {
- $xmlWriter->writeAttribute('text:style-name', $paragraphStyle);
- }
- // text:span
- $xmlWriter->startElement('text:span');
- if (is_string($fontStyle)) {
- $xmlWriter->writeAttribute('text:style-name', $fontStyle);
- }
- if (Settings::isOutputEscapingEnabled()) {
- $xmlWriter->text($element->getText());
- } else {
- $xmlWriter->writeRaw($element->getText());
- }
- $xmlWriter->endElement();
+ $xmlWriter->writeRaw($element->getText());
}
- if (!$this->withoutP) {
- $xmlWriter->endElement(); // text:p
+ } else {
+ if (empty($paragraphStyle)) {
+ $xmlWriter->writeAttribute('text:style-name', 'Standard');
+ } elseif (is_string($paragraphStyle)) {
+ $xmlWriter->writeAttribute('text:style-name', $paragraphStyle);
}
+ // text:span
+ $xmlWriter->startElement('text:span');
+ if (is_string($fontStyle)) {
+ $xmlWriter->writeAttribute('text:style-name', $fontStyle);
+ }
+ if (Settings::isOutputEscapingEnabled()) {
+ $xmlWriter->text($element->getText());
+ } else {
+ $xmlWriter->writeRaw($element->getText());
+ }
+ $xmlWriter->endElement();
+ }
+ if (!$this->withoutP) {
+ $xmlWriter->endElement(); // text:p
}
}
}
diff --git a/src/PhpWord/Writer/ODText/Element/TextBreak.php b/src/PhpWord/Writer/ODText/Element/TextBreak.php
index b0f5009e..f7642e3b 100644
--- a/src/PhpWord/Writer/ODText/Element/TextBreak.php
+++ b/src/PhpWord/Writer/ODText/Element/TextBreak.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/ODText/Element/TextRun.php b/src/PhpWord/Writer/ODText/Element/TextRun.php
index 03717016..f5c855fe 100644
--- a/src/PhpWord/Writer/ODText/Element/TextRun.php
+++ b/src/PhpWord/Writer/ODText/Element/TextRun.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/ODText/Element/Title.php b/src/PhpWord/Writer/ODText/Element/Title.php
index b20ba944..bf9bf9d6 100644
--- a/src/PhpWord/Writer/ODText/Element/Title.php
+++ b/src/PhpWord/Writer/ODText/Element/Title.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/ODText/Part/AbstractPart.php b/src/PhpWord/Writer/ODText/Part/AbstractPart.php
index dc377e0f..74412fd4 100644
--- a/src/PhpWord/Writer/ODText/Part/AbstractPart.php
+++ b/src/PhpWord/Writer/ODText/Part/AbstractPart.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -37,7 +37,6 @@ abstract class AbstractPart extends Word2007AbstractPart
* Write common root attributes.
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
- * @return void
*/
protected function writeCommonRootAttributes(XMLWriter $xmlWriter)
{
@@ -74,7 +73,6 @@ abstract class AbstractPart extends Word2007AbstractPart
* Write font faces declaration.
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
- * @return void
*/
protected function writeFontFaces(XMLWriter $xmlWriter)
{
diff --git a/src/PhpWord/Writer/ODText/Part/Content.php b/src/PhpWord/Writer/ODText/Part/Content.php
index 61f8e7e2..8ae4dca9 100644
--- a/src/PhpWord/Writer/ODText/Part/Content.php
+++ b/src/PhpWord/Writer/ODText/Part/Content.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -111,7 +111,6 @@ class Content extends AbstractPart
* @since 0.11.0
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
- * @return void
*/
private function writeAutoStyles(XMLWriter $xmlWriter)
{
@@ -121,7 +120,6 @@ class Content extends AbstractPart
foreach ($this->autoStyles as $element => $styles) {
$writerClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . $element;
foreach ($styles as $style) {
-
/** @var \PhpOffice\PhpWord\Writer\ODText\Style\AbstractStyle $styleWriter Type hint */
$styleWriter = new $writerClass($xmlWriter, $style);
$styleWriter->write();
@@ -135,7 +133,6 @@ class Content extends AbstractPart
* Write automatic styles.
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
- * @return void
*/
private function writeTextStyles(XMLWriter $xmlWriter)
{
@@ -169,7 +166,6 @@ class Content extends AbstractPart
* Get automatic styles.
*
* @param \PhpOffice\PhpWord\PhpWord $phpWord
- * @return void
*/
private function getAutoStyles(PhpWord $phpWord)
{
@@ -192,7 +188,6 @@ class Content extends AbstractPart
* @param \PhpOffice\PhpWord\Element\AbstractContainer $container
* @param int &$paragraphStyleCount
* @param int &$fontStyleCount
- * @return void
* @todo Simplify the logic
*/
private function getContainerStyle($container, &$paragraphStyleCount, &$fontStyleCount)
@@ -226,7 +221,6 @@ class Content extends AbstractPart
* @param \PhpOffice\PhpWord\Element\Text &$element
* @param int &$paragraphStyleCount
* @param int &$fontStyleCount
- * @return void
*/
private function getElementStyle(&$element, &$paragraphStyleCount, &$fontStyleCount)
{
@@ -234,15 +228,14 @@ class Content extends AbstractPart
$paragraphStyle = $element->getParagraphStyle();
$phpWord = $this->getParentWriter()->getPhpWord();
- // Font
if ($fontStyle instanceof Font) {
+ // Font
$fontStyleCount++;
$style = $phpWord->addFontStyle("T{$fontStyleCount}", $fontStyle);
$style->setAuto();
$element->setFontStyle("T{$fontStyleCount}");
-
- // Paragraph
} elseif ($paragraphStyle instanceof Paragraph) {
+ // Paragraph
$paragraphStyleCount++;
$style = $phpWord->addParagraphStyle("P{$paragraphStyleCount}", array());
$style->setAuto();
diff --git a/src/PhpWord/Writer/ODText/Part/Manifest.php b/src/PhpWord/Writer/ODText/Part/Manifest.php
index 237c1a11..d916ccdf 100644
--- a/src/PhpWord/Writer/ODText/Part/Manifest.php
+++ b/src/PhpWord/Writer/ODText/Part/Manifest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/ODText/Part/Meta.php b/src/PhpWord/Writer/ODText/Part/Meta.php
index f16db161..72d03ae6 100644
--- a/src/PhpWord/Writer/ODText/Part/Meta.php
+++ b/src/PhpWord/Writer/ODText/Part/Meta.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -90,7 +90,6 @@ class Meta extends AbstractPart
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param string $property
* @param string $value
- * @return void
*
* @todo Handle other `$type`: double|date|dateTime|duration|boolean (4th arguments)
*/
diff --git a/src/PhpWord/Writer/ODText/Part/Mimetype.php b/src/PhpWord/Writer/ODText/Part/Mimetype.php
index 7cf78b4b..6e45b848 100644
--- a/src/PhpWord/Writer/ODText/Part/Mimetype.php
+++ b/src/PhpWord/Writer/ODText/Part/Mimetype.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/ODText/Part/Styles.php b/src/PhpWord/Writer/ODText/Part/Styles.php
index ee22aaab..e12928d3 100644
--- a/src/PhpWord/Writer/ODText/Part/Styles.php
+++ b/src/PhpWord/Writer/ODText/Part/Styles.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -64,7 +64,6 @@ class Styles extends AbstractPart
* Write default styles.
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
- * @return void
*/
private function writeDefault(XMLWriter $xmlWriter)
{
@@ -114,7 +113,6 @@ class Styles extends AbstractPart
* Write named styles.
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
- * @return void
*/
private function writeNamed(XMLWriter $xmlWriter)
{
@@ -132,11 +130,11 @@ class Styles extends AbstractPart
}
}
}
+
/**
* Write page layout styles.
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
- * @return void
*/
private function writePageLayout(XMLWriter $xmlWriter)
{
@@ -144,7 +142,7 @@ class Styles extends AbstractPart
$xmlWriter->writeAttribute('style:name', 'Mpm1');
$xmlWriter->startElement('style:page-layout-properties');
- $xmlWriter->writeAttribute('fo:page-width', "21.001cm");
+ $xmlWriter->writeAttribute('fo:page-width', '21.001cm');
$xmlWriter->writeAttribute('fo:page-height', '29.7cm');
$xmlWriter->writeAttribute('style:num-format', '1');
$xmlWriter->writeAttribute('style:print-orientation', 'portrait');
@@ -175,7 +173,6 @@ class Styles extends AbstractPart
$xmlWriter->endElement(); // style:page-layout-properties
-
$xmlWriter->startElement('style:header-style');
$xmlWriter->endElement(); // style:header-style
@@ -189,7 +186,6 @@ class Styles extends AbstractPart
* Write master style.
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
- * @return void
*/
private function writeMaster(XMLWriter $xmlWriter)
{
diff --git a/src/PhpWord/Writer/ODText/Style/AbstractStyle.php b/src/PhpWord/Writer/ODText/Style/AbstractStyle.php
index 7bc49cb3..26b9905b 100644
--- a/src/PhpWord/Writer/ODText/Style/AbstractStyle.php
+++ b/src/PhpWord/Writer/ODText/Style/AbstractStyle.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/ODText/Style/Font.php b/src/PhpWord/Writer/ODText/Style/Font.php
index 5d8e5753..50de32ad 100644
--- a/src/PhpWord/Writer/ODText/Style/Font.php
+++ b/src/PhpWord/Writer/ODText/Style/Font.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Font extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/ODText/Style/Image.php b/src/PhpWord/Writer/ODText/Style/Image.php
index 447f449c..b85d4d70 100644
--- a/src/PhpWord/Writer/ODText/Style/Image.php
+++ b/src/PhpWord/Writer/ODText/Style/Image.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Image extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/ODText/Style/Paragraph.php b/src/PhpWord/Writer/ODText/Style/Paragraph.php
index 1d821810..a047ad32 100644
--- a/src/PhpWord/Writer/ODText/Style/Paragraph.php
+++ b/src/PhpWord/Writer/ODText/Style/Paragraph.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Paragraph extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/ODText/Style/Section.php b/src/PhpWord/Writer/ODText/Style/Section.php
index 79d57adb..bef023e9 100644
--- a/src/PhpWord/Writer/ODText/Style/Section.php
+++ b/src/PhpWord/Writer/ODText/Style/Section.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Section extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
@@ -40,7 +38,7 @@ class Section extends AbstractStyle
$xmlWriter->startElement('style:style');
$xmlWriter->writeAttribute('style:name', $style->getStyleName());
- $xmlWriter->writeAttribute('style:family', "section");
+ $xmlWriter->writeAttribute('style:family', 'section');
$xmlWriter->startElement('style:section-properties');
$xmlWriter->startElement('style:columns');
diff --git a/src/PhpWord/Writer/ODText/Style/Table.php b/src/PhpWord/Writer/ODText/Style/Table.php
index ff3cc423..7d66899a 100644
--- a/src/PhpWord/Writer/ODText/Style/Table.php
+++ b/src/PhpWord/Writer/ODText/Style/Table.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Table extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/PDF.php b/src/PhpWord/Writer/PDF.php
index 5e5d9d71..45fe8f35 100644
--- a/src/PhpWord/Writer/PDF.php
+++ b/src/PhpWord/Writer/PDF.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PhpWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PhpWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -47,7 +47,7 @@ class PDF
$pdfLibraryName = Settings::getPdfRendererName();
$pdfLibraryPath = Settings::getPdfRendererPath();
if (is_null($pdfLibraryName) || is_null($pdfLibraryPath)) {
- throw new Exception("PDF rendering library or library path has not been defined.");
+ throw new Exception('PDF rendering library or library path has not been defined.');
}
$includePath = str_replace('\\', '/', get_include_path());
diff --git a/src/PhpWord/Writer/PDF/AbstractRenderer.php b/src/PhpWord/Writer/PDF/AbstractRenderer.php
index 2778aa52..7b668e0b 100644
--- a/src/PhpWord/Writer/PDF/AbstractRenderer.php
+++ b/src/PhpWord/Writer/PDF/AbstractRenderer.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PhpWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PhpWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -83,15 +83,17 @@ abstract class AbstractRenderer extends HTML
public function __construct(PhpWord $phpWord)
{
parent::__construct($phpWord);
- $includeFile = Settings::getPdfRendererPath() . '/' . $this->includeFile;
- if (file_exists($includeFile)) {
- /** @noinspection PhpIncludeInspection Dynamic includes */
- require_once $includeFile;
- } else {
- // @codeCoverageIgnoreStart
- // Can't find any test case. Uncomment when found.
- throw new Exception('Unable to load PDF Rendering library');
- // @codeCoverageIgnoreEnd
+ if ($this->includeFile != null) {
+ $includeFile = Settings::getPdfRendererPath() . '/' . $this->includeFile;
+ if (file_exists($includeFile)) {
+ /** @noinspection PhpIncludeInspection Dynamic includes */
+ require_once $includeFile;
+ } else {
+ // @codeCoverageIgnoreStart
+ // Can't find any test case. Uncomment when found.
+ throw new Exception('Unable to load PDF Rendering library');
+ // @codeCoverageIgnoreEnd
+ }
}
}
@@ -141,6 +143,7 @@ abstract class AbstractRenderer extends HTML
public function setPaperSize($value = 9)
{
$this->paperSize = $value;
+
return $this;
}
@@ -163,6 +166,7 @@ abstract class AbstractRenderer extends HTML
public function setOrientation($value = 'default')
{
$this->orientation = $value;
+
return $this;
}
@@ -171,9 +175,8 @@ abstract class AbstractRenderer extends HTML
*
* @param string $filename Name of the file to save as
*
- * @return resource
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ * @return resource
*/
protected function prepareForSave($filename = null)
{
@@ -194,8 +197,6 @@ abstract class AbstractRenderer extends HTML
*
* @param resource $fileHandle
*
- * @return void
- *
* @throws Exception
*/
protected function restoreStateAfterSave($fileHandle)
diff --git a/src/PhpWord/Writer/PDF/DomPDF.php b/src/PhpWord/Writer/PDF/DomPDF.php
index e31f3aae..be282d20 100644
--- a/src/PhpWord/Writer/PDF/DomPDF.php
+++ b/src/PhpWord/Writer/PDF/DomPDF.php
@@ -10,19 +10,20 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PhpWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PhpWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\Writer\PDF;
+use Dompdf\Dompdf as DompdfLib;
use PhpOffice\PhpWord\Writer\WriterInterface;
/**
* DomPDF writer
*
- * @link https://github.com/dompdf/dompdf
+ * @see https://github.com/dompdf/dompdf
* @since 0.10.0
*/
class DomPDF extends AbstractRenderer implements WriterInterface
@@ -32,13 +33,12 @@ class DomPDF extends AbstractRenderer implements WriterInterface
*
* @var string
*/
- protected $includeFile = 'dompdf_config.inc.php';
+ protected $includeFile = null;
/**
* Save PhpWord to file.
*
* @param string $filename Name of the file to save as
- * @return void
*/
public function save($filename = null)
{
@@ -49,9 +49,9 @@ class DomPDF extends AbstractRenderer implements WriterInterface
$orientation = 'portrait';
// Create PDF
- $pdf = new \DOMPDF();
- $pdf->set_paper(strtolower($paperSize), $orientation);
- $pdf->load_html($this->getContent());
+ $pdf = new DompdfLib();
+ $pdf->setPaper(strtolower($paperSize), $orientation);
+ $pdf->loadHtml(str_replace(PHP_EOL, '', $this->getContent()));
$pdf->render();
// Write to file
diff --git a/src/PhpWord/Writer/PDF/MPDF.php b/src/PhpWord/Writer/PDF/MPDF.php
index 028ffac7..80c2eccf 100644
--- a/src/PhpWord/Writer/PDF/MPDF.php
+++ b/src/PhpWord/Writer/PDF/MPDF.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PhpWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PhpWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -22,7 +22,7 @@ use PhpOffice\PhpWord\Writer\WriterInterface;
/**
* MPDF writer
*
- * @link http://www.mpdf1.com/
+ * @see http://www.mpdf1.com/
* @since 0.11.0
*/
class MPDF extends AbstractRenderer implements WriterInterface
@@ -38,7 +38,6 @@ class MPDF extends AbstractRenderer implements WriterInterface
* Save PhpWord to file.
*
* @param string $filename Name of the file to save as
- * @return void
*/
public function save($filename = null)
{
diff --git a/src/PhpWord/Writer/PDF/TCPDF.php b/src/PhpWord/Writer/PDF/TCPDF.php
index e1e19006..3b82511a 100644
--- a/src/PhpWord/Writer/PDF/TCPDF.php
+++ b/src/PhpWord/Writer/PDF/TCPDF.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PhpWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PhpWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -24,7 +24,7 @@ use PhpOffice\PhpWord\Writer\WriterInterface;
*
* @deprecated 0.13.0 Use `DomPDF` or `MPDF` instead.
*
- * @link http://www.tcpdf.org/
+ * @see http://www.tcpdf.org/
* @since 0.11.0
*/
class TCPDF extends AbstractRenderer implements WriterInterface
diff --git a/src/PhpWord/Writer/RTF.php b/src/PhpWord/Writer/RTF.php
index 887b1c67..7756253a 100644
--- a/src/PhpWord/Writer/RTF.php
+++ b/src/PhpWord/Writer/RTF.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -58,9 +58,6 @@ class RTF extends AbstractWriter implements WriterInterface
* Save content to file.
*
* @param string $filename
- *
- * @return void
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
public function save($filename = null)
@@ -121,7 +118,6 @@ class RTF extends AbstractWriter implements WriterInterface
* Set last paragraph style.
*
* @param mixed $value
- * @return void
*/
public function setLastParagraphStyle($value = '')
{
diff --git a/src/PhpWord/Writer/RTF/Element/AbstractElement.php b/src/PhpWord/Writer/RTF/Element/AbstractElement.php
index 289733dc..1013ee36 100644
--- a/src/PhpWord/Writer/RTF/Element/AbstractElement.php
+++ b/src/PhpWord/Writer/RTF/Element/AbstractElement.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -59,8 +59,6 @@ abstract class AbstractElement extends HTMLAbstractElement
/**
* Get font and paragraph styles.
- *
- * @return void
*/
protected function getStyles()
{
@@ -112,6 +110,7 @@ abstract class AbstractElement extends HTMLAbstractElement
$styleWriter = new ParagraphStyleWriter($this->paragraphStyle);
$styleWriter->setNestedLevel($this->element->getNestedLevel());
+
return $styleWriter->write();
}
@@ -125,9 +124,9 @@ abstract class AbstractElement extends HTMLAbstractElement
{
if (Settings::isOutputEscapingEnabled()) {
return $this->escaper->escape($text);
- } else {
- return CommonText::toUnicode($text); // todo: replace with `return $text;` later.
}
+
+ return CommonText::toUnicode($text); // todo: replace with `return $text;` later.
}
/**
diff --git a/src/PhpWord/Writer/RTF/Element/Container.php b/src/PhpWord/Writer/RTF/Element/Container.php
index 7a1b0b07..4850c8bf 100644
--- a/src/PhpWord/Writer/RTF/Element/Container.php
+++ b/src/PhpWord/Writer/RTF/Element/Container.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/RTF/Element/Image.php b/src/PhpWord/Writer/RTF/Element/Image.php
index e950d30b..fb96baff 100644
--- a/src/PhpWord/Writer/RTF/Element/Image.php
+++ b/src/PhpWord/Writer/RTF/Element/Image.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/RTF/Element/Link.php b/src/PhpWord/Writer/RTF/Element/Link.php
index f106d57d..91a75720 100644
--- a/src/PhpWord/Writer/RTF/Element/Link.php
+++ b/src/PhpWord/Writer/RTF/Element/Link.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/RTF/Element/ListItem.php b/src/PhpWord/Writer/RTF/Element/ListItem.php
index b2ba612d..e628bffd 100644
--- a/src/PhpWord/Writer/RTF/Element/ListItem.php
+++ b/src/PhpWord/Writer/RTF/Element/ListItem.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/RTF/Element/PageBreak.php b/src/PhpWord/Writer/RTF/Element/PageBreak.php
index ac2bb8ec..0adbe06e 100644
--- a/src/PhpWord/Writer/RTF/Element/PageBreak.php
+++ b/src/PhpWord/Writer/RTF/Element/PageBreak.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/RTF/Element/Table.php b/src/PhpWord/Writer/RTF/Element/Table.php
index c65d7248..d0bc0845 100644
--- a/src/PhpWord/Writer/RTF/Element/Table.php
+++ b/src/PhpWord/Writer/RTF/Element/Table.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/RTF/Element/Text.php b/src/PhpWord/Writer/RTF/Element/Text.php
index b5a28adf..2fac0520 100644
--- a/src/PhpWord/Writer/RTF/Element/Text.php
+++ b/src/PhpWord/Writer/RTF/Element/Text.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/RTF/Element/TextBreak.php b/src/PhpWord/Writer/RTF/Element/TextBreak.php
index 0f76aea2..2009fcff 100644
--- a/src/PhpWord/Writer/RTF/Element/TextBreak.php
+++ b/src/PhpWord/Writer/RTF/Element/TextBreak.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/RTF/Element/TextRun.php b/src/PhpWord/Writer/RTF/Element/TextRun.php
index f63f338d..d4e56765 100644
--- a/src/PhpWord/Writer/RTF/Element/TextRun.php
+++ b/src/PhpWord/Writer/RTF/Element/TextRun.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/RTF/Element/Title.php b/src/PhpWord/Writer/RTF/Element/Title.php
index 894f52cc..18bad9fd 100644
--- a/src/PhpWord/Writer/RTF/Element/Title.php
+++ b/src/PhpWord/Writer/RTF/Element/Title.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/RTF/Part/AbstractPart.php b/src/PhpWord/Writer/RTF/Part/AbstractPart.php
index 04fb4cfd..7569a105 100644
--- a/src/PhpWord/Writer/RTF/Part/AbstractPart.php
+++ b/src/PhpWord/Writer/RTF/Part/AbstractPart.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -48,8 +48,6 @@ abstract class AbstractPart
/**
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
- *
- * @return void
*/
public function setParentWriter(AbstractWriter $writer = null)
{
@@ -57,16 +55,14 @@ abstract class AbstractPart
}
/**
- * @return \PhpOffice\PhpWord\Writer\AbstractWriter
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ * @return \PhpOffice\PhpWord\Writer\AbstractWriter
*/
public function getParentWriter()
{
if ($this->parentWriter !== null) {
return $this->parentWriter;
- } else {
- throw new Exception('No parent WriterInterface assigned.');
}
+ throw new Exception('No parent WriterInterface assigned.');
}
}
diff --git a/src/PhpWord/Writer/RTF/Part/Document.php b/src/PhpWord/Writer/RTF/Part/Document.php
index 97b2f1b6..465872ea 100644
--- a/src/PhpWord/Writer/RTF/Part/Document.php
+++ b/src/PhpWord/Writer/RTF/Part/Document.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -25,7 +25,7 @@ use PhpOffice\PhpWord\Writer\RTF\Style\Section as SectionStyleWriter;
* RTF document part writer
*
* @since 0.11.0
- * @link http://www.biblioscape.com/rtf15_spec.htm#Heading24
+ * @see http://www.biblioscape.com/rtf15_spec.htm#Heading24
*/
class Document extends AbstractPart
{
@@ -54,9 +54,13 @@ class Document extends AbstractPart
{
$docProps = $this->getParentWriter()->getPhpWord()->getDocInfo();
$properties = array('title', 'subject', 'category', 'keywords', 'comment',
- 'author', 'operator', 'creatim', 'revtim', 'company', 'manager');
- $mapping = array('comment' => 'description', 'author' => 'creator', 'operator' => 'lastModifiedBy',
- 'creatim' => 'created', 'revtim' => 'modified');
+ 'author', 'operator', 'creatim', 'revtim', 'company', 'manager', );
+ $mapping = array(
+ 'comment' => 'description',
+ 'author' => 'creator',
+ 'operator' => 'lastModifiedBy',
+ 'creatim' => 'created',
+ 'revtim' => 'modified', );
$dateFields = array('creatim', 'revtim');
$content = '';
diff --git a/src/PhpWord/Writer/RTF/Part/Header.php b/src/PhpWord/Writer/RTF/Part/Header.php
index 56a50349..73f1351f 100644
--- a/src/PhpWord/Writer/RTF/Part/Header.php
+++ b/src/PhpWord/Writer/RTF/Part/Header.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,7 +33,7 @@ use PhpOffice\PhpWord\Style\Font;
* - List table (not supported yet)
*
* @since 0.11.0
- * @link http://www.biblioscape.com/rtf15_spec.htm#Heading6
+ * @see http://www.biblioscape.com/rtf15_spec.htm#Heading6
*/
class Header extends AbstractPart
{
@@ -181,8 +181,6 @@ class Header extends AbstractPart
/**
* Register all fonts and colors in both named and inline styles to appropriate header table.
- *
- * @return void
*/
private function registerFont()
{
@@ -213,7 +211,6 @@ class Header extends AbstractPart
* Register border colors.
*
* @param \PhpOffice\PhpWord\Style\Border $style
- * @return void
*/
private function registerBorderColor($style)
{
@@ -229,7 +226,6 @@ class Header extends AbstractPart
* Register fonts and colors.
*
* @param \PhpOffice\PhpWord\Style\AbstractStyle $style
- * @return void
*/
private function registerFontItems($style)
{
@@ -249,7 +245,6 @@ class Header extends AbstractPart
* @param array &$table
* @param string $value
* @param string $default
- * @return void
*/
private function registerTableItem(&$table, $value, $default = null)
{
diff --git a/src/PhpWord/Writer/RTF/Style/AbstractStyle.php b/src/PhpWord/Writer/RTF/Style/AbstractStyle.php
index 417be9cf..80523610 100644
--- a/src/PhpWord/Writer/RTF/Style/AbstractStyle.php
+++ b/src/PhpWord/Writer/RTF/Style/AbstractStyle.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/RTF/Style/Border.php b/src/PhpWord/Writer/RTF/Style/Border.php
index 9f7ee2c0..e63d767f 100644
--- a/src/PhpWord/Writer/RTF/Style/Border.php
+++ b/src/PhpWord/Writer/RTF/Style/Border.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -103,8 +103,7 @@ class Border extends AbstractStyle
/**
* Set sizes.
*
- * @param integer[] $value
- * @return void
+ * @param int[] $value
*/
public function setSizes($value)
{
@@ -115,7 +114,6 @@ class Border extends AbstractStyle
* Set colors.
*
* @param string[] $value
- * @return void
*/
public function setColors($value)
{
diff --git a/src/PhpWord/Writer/RTF/Style/Font.php b/src/PhpWord/Writer/RTF/Style/Font.php
index 6567ec33..3338368a 100644
--- a/src/PhpWord/Writer/RTF/Style/Font.php
+++ b/src/PhpWord/Writer/RTF/Style/Font.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -62,7 +62,7 @@ class Font extends AbstractStyle
$content .= $this->getValueIf($style->isSuperScript(), '\super');
$content .= $this->getValueIf($style->isSubScript(), '\sub');
- return $content . ' ';
+ return $content . ' ';
}
/**
@@ -70,7 +70,6 @@ class Font extends AbstractStyle
*
*
* @param int $value
- * @return void
*/
public function setNameIndex($value = 0)
{
@@ -81,7 +80,6 @@ class Font extends AbstractStyle
* Set font color index.
*
* @param int $value
- * @return void
*/
public function setColorIndex($value = 0)
{
diff --git a/src/PhpWord/Writer/RTF/Style/Paragraph.php b/src/PhpWord/Writer/RTF/Style/Paragraph.php
index 046adc8c..61b61fd7 100644
--- a/src/PhpWord/Writer/RTF/Style/Paragraph.php
+++ b/src/PhpWord/Writer/RTF/Style/Paragraph.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -74,7 +74,6 @@ class Paragraph extends AbstractStyle
* Set nested level.
*
* @param int $value
- * @return void
*/
public function setNestedLevel($value)
{
diff --git a/src/PhpWord/Writer/RTF/Style/Section.php b/src/PhpWord/Writer/RTF/Style/Section.php
index dcdc0aaf..8f073716 100644
--- a/src/PhpWord/Writer/RTF/Style/Section.php
+++ b/src/PhpWord/Writer/RTF/Style/Section.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007.php b/src/PhpWord/Writer/Word2007.php
index bb7b521f..fcef982f 100644
--- a/src/PhpWord/Writer/Word2007.php
+++ b/src/PhpWord/Writer/Word2007.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -92,7 +92,6 @@ class Word2007 extends AbstractWriter implements WriterInterface
* Save document by name.
*
* @param string $filename
- * @return void
*/
public function save($filename = null)
{
@@ -170,7 +169,6 @@ class Word2007 extends AbstractWriter implements WriterInterface
*
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
* @param string $docPart
- * @return void
*/
private function addHeaderFooterMedia(ZipArchive $zip, $docPart)
{
@@ -197,16 +195,15 @@ class Word2007 extends AbstractWriter implements WriterInterface
* @param \PhpOffice\PhpWord\Element\Section &$section
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
* @param string $elmType header|footer
- * @param integer &$rId
- * @return void
+ * @param int &$rId
*/
private function addHeaderFooterContent(Section &$section, ZipArchive $zip, $elmType, &$rId)
{
$getFunction = $elmType == 'header' ? 'getHeaders' : 'getFooters';
$elmCount = ($section->getSectionId() - 1) * 3;
$elements = $section->$getFunction();
+ /** @var \PhpOffice\PhpWord\Element\AbstractElement $element Type hint */
foreach ($elements as &$element) {
- /** @var \PhpOffice\PhpWord\Element\AbstractElement $element Type hint */
$elmCount++;
$element->setRelationId(++$rId);
$elmFile = "{$elmType}{$elmCount}.xml"; // e.g. footer1.xml
@@ -223,9 +220,8 @@ class Word2007 extends AbstractWriter implements WriterInterface
* Add footnotes/endnotes
*
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
- * @param integer &$rId
+ * @param int &$rId
* @param string $noteType
- * @return void
*/
private function addNotes(ZipArchive $zip, &$rId, $noteType = 'footnote')
{
@@ -261,14 +257,13 @@ class Word2007 extends AbstractWriter implements WriterInterface
* Add comments
*
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
- * @param integer &$rId
- * @return void
+ * @param int &$rId
*/
private function addComments(ZipArchive $zip, &$rId)
{
$phpWord = $this->getPhpWord();
$collection = $phpWord->getComments();
- $partName = "comments";
+ $partName = 'comments';
// Add comment relations and contents
/** @var \PhpOffice\PhpWord\Collection\AbstractCollection $collection Type hint */
@@ -285,8 +280,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
* Add chart.
*
* @param \PhpOffice\PhpWord\Shared\ZipArchive $zip
- * @param integer &$rId
- * @return void
+ * @param int &$rId
*/
private function addChart(ZipArchive $zip, &$rId)
{
@@ -295,6 +289,7 @@ class Word2007 extends AbstractWriter implements WriterInterface
$collection = $phpWord->getCharts();
$index = 0;
if ($collection->countItems() > 0) {
+ /** @var \PhpOffice\PhpWord\Element\Chart $chart */
foreach ($collection->getItems() as $chart) {
$index++;
$rId++;
@@ -307,7 +302,6 @@ class Word2007 extends AbstractWriter implements WriterInterface
$this->relationships[] = array('target' => $filename, 'type' => 'chart', 'rID' => $rId);
// word/charts/chartN.xml
- /** @var \PhpOffice\PhpWord\Element\Chart $chart */
$chart->setRelationId($rId);
$writerPart = $this->getWriterPart('Chart');
$writerPart->setElement($chart);
@@ -320,7 +314,6 @@ class Word2007 extends AbstractWriter implements WriterInterface
* Register content types for each media.
*
* @param array $media
- * @return void
*/
private function registerContentTypes($media)
{
diff --git a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php
index 305a768e..07ffc286 100644
--- a/src/PhpWord/Writer/Word2007/Element/AbstractElement.php
+++ b/src/PhpWord/Writer/Word2007/Element/AbstractElement.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -92,7 +92,6 @@ abstract class AbstractElement
* Start w:p DOM element.
*
* @uses \PhpOffice\PhpWord\Writer\Word2007\Element\PageBreak::write()
- * @return void
*/
protected function startElementP()
{
@@ -108,8 +107,6 @@ abstract class AbstractElement
/**
* End w:p DOM element.
- *
- * @return void
*/
protected function endElementP()
{
@@ -121,8 +118,6 @@ abstract class AbstractElement
/**
* Writes the w:commentRangeStart DOM element
- *
- * @return void
*/
protected function writeCommentRangeStart()
{
@@ -139,8 +134,6 @@ abstract class AbstractElement
/**
* Writes the w:commentRangeEnd DOM element
- *
- * @return void
*/
protected function writeCommentRangeEnd()
{
@@ -171,8 +164,6 @@ abstract class AbstractElement
/**
* Write ending.
- *
- * @return void
*/
protected function writeParagraphStyle()
{
@@ -181,20 +172,16 @@ abstract class AbstractElement
/**
* Write ending.
- *
- * @return void
*/
protected function writeFontStyle()
{
$this->writeTextStyle('Font');
}
-
/**
* Write text style.
*
* @param string $styleType Font|Paragraph
- * @return void
*/
private function writeTextStyle($styleType)
{
@@ -202,12 +189,12 @@ abstract class AbstractElement
$class = "PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\{$styleType}";
$styleObject = $this->element->$method();
+ /** @var \PhpOffice\PhpWord\Writer\Word2007\Style\AbstractStyle $styleWriter Type Hint */
$styleWriter = new $class($this->xmlWriter, $styleObject);
if (method_exists($styleWriter, 'setIsInline')) {
$styleWriter->setIsInline(true);
}
- /** @var \PhpOffice\PhpWord\Writer\Word2007\Style\AbstractStyle $styleWriter */
$styleWriter->write();
}
diff --git a/src/PhpWord/Writer/Word2007/Element/Bookmark.php b/src/PhpWord/Writer/Word2007/Element/Bookmark.php
index 424fb0ab..4b0b78a7 100644
--- a/src/PhpWord/Writer/Word2007/Element/Bookmark.php
+++ b/src/PhpWord/Writer/Word2007/Element/Bookmark.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -41,7 +41,7 @@ class Bookmark extends AbstractElement
$xmlWriter->writeAttribute('w:id', $rId);
$xmlWriter->writeAttribute('w:name', $element->getName());
$xmlWriter->endElement();
-
+
$xmlWriter->startElement('w:bookmarkEnd');
$xmlWriter->writeAttribute('w:id', $rId);
$xmlWriter->endElement();
diff --git a/src/PhpWord/Writer/Word2007/Element/Chart.php b/src/PhpWord/Writer/Word2007/Element/Chart.php
index ecdde362..591799ab 100644
--- a/src/PhpWord/Writer/Word2007/Element/Chart.php
+++ b/src/PhpWord/Writer/Word2007/Element/Chart.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,8 +28,6 @@ class Chart extends AbstractElement
{
/**
* Write element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/CheckBox.php b/src/PhpWord/Writer/Word2007/Element/CheckBox.php
index 7424985c..31dcb867 100644
--- a/src/PhpWord/Writer/Word2007/Element/CheckBox.php
+++ b/src/PhpWord/Writer/Word2007/Element/CheckBox.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,8 +28,6 @@ class CheckBox extends Text
{
/**
* Write element.
- *
- * @return void
*/
public function write()
{
@@ -66,17 +64,17 @@ class CheckBox extends Text
$xmlWriter->startElement('w:instrText');
$xmlWriter->writeAttribute('xml:space', 'preserve');
$xmlWriter->text(' FORMCHECKBOX ');
- $xmlWriter->endElement();// w:instrText
+ $xmlWriter->endElement(); // w:instrText
$xmlWriter->endElement(); // w:r
$xmlWriter->startElement('w:r');
$xmlWriter->startElement('w:fldChar');
$xmlWriter->writeAttribute('w:fldCharType', 'separate');
- $xmlWriter->endElement();// w:fldChar
+ $xmlWriter->endElement(); // w:fldChar
$xmlWriter->endElement(); // w:r
$xmlWriter->startElement('w:r');
$xmlWriter->startElement('w:fldChar');
$xmlWriter->writeAttribute('w:fldCharType', 'end');
- $xmlWriter->endElement();// w:fldChar
+ $xmlWriter->endElement(); // w:fldChar
$xmlWriter->endElement(); // w:r
$xmlWriter->startElement('w:r');
diff --git a/src/PhpWord/Writer/Word2007/Element/Container.php b/src/PhpWord/Writer/Word2007/Element/Container.php
index 0efd0ebc..47dae29b 100644
--- a/src/PhpWord/Writer/Word2007/Element/Container.php
+++ b/src/PhpWord/Writer/Word2007/Element/Container.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -38,8 +38,6 @@ class Container extends AbstractElement
/**
* Write element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/Endnote.php b/src/PhpWord/Writer/Word2007/Element/Endnote.php
index 9363489e..ebfe35c1 100644
--- a/src/PhpWord/Writer/Word2007/Element/Endnote.php
+++ b/src/PhpWord/Writer/Word2007/Element/Endnote.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007/Element/Field.php b/src/PhpWord/Writer/Word2007/Element/Field.php
index 9fc45b21..75d4983f 100644
--- a/src/PhpWord/Writer/Word2007/Element/Field.php
+++ b/src/PhpWord/Writer/Word2007/Element/Field.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,13 +26,11 @@ class Field extends Text
{
/**
* Write field element.
- *
- * @return void
*/
public function write()
{
$xmlWriter = $this->getXmlWriter();
- $element = $this->getElement();
+ $element = $this->getElement();
if (!$element instanceof \PhpOffice\PhpWord\Element\Field) {
return;
}
@@ -65,7 +63,6 @@ class Field extends Text
if ($element->getText() != null) {
if ($element->getText() instanceof \PhpOffice\PhpWord\Element\TextRun) {
-
$containerWriter = new Container($xmlWriter, $element->getText(), true);
$containerWriter->write();
@@ -110,17 +107,17 @@ class Field extends Text
private function buildPropertiesAndOptions(\PhpOffice\PhpWord\Element\Field $element)
{
$propertiesAndOptions = '';
- $properties = $element->getProperties();
+ $properties = $element->getProperties();
foreach ($properties as $propkey => $propval) {
switch ($propkey) {
case 'format':
- $propertiesAndOptions.= '\* ' . $propval . ' ';
+ $propertiesAndOptions .= '\* ' . $propval . ' ';
break;
case 'numformat':
- $propertiesAndOptions.= '\# ' . $propval . ' ';
+ $propertiesAndOptions .= '\# ' . $propval . ' ';
break;
case 'dateformat':
- $propertiesAndOptions.= '\@ "' . $propval . '" ';
+ $propertiesAndOptions .= '\@ "' . $propval . '" ';
break;
}
}
@@ -129,27 +126,28 @@ class Field extends Text
foreach ($options as $option) {
switch ($option) {
case 'PreserveFormat':
- $propertiesAndOptions.= '\* MERGEFORMAT ';
+ $propertiesAndOptions .= '\* MERGEFORMAT ';
break;
case 'LunarCalendar':
- $propertiesAndOptions.= '\h ';
+ $propertiesAndOptions .= '\h ';
break;
case 'SakaEraCalendar':
- $propertiesAndOptions.= '\s ';
+ $propertiesAndOptions .= '\s ';
break;
case 'LastUsedFormat':
- $propertiesAndOptions.= '\l ';
+ $propertiesAndOptions .= '\l ';
break;
case 'Bold':
- $propertiesAndOptions.= '\b ';
+ $propertiesAndOptions .= '\b ';
break;
case 'Italic':
- $propertiesAndOptions.= '\i ';
+ $propertiesAndOptions .= '\i ';
break;
default:
- $propertiesAndOptions.= $option .' ';
+ $propertiesAndOptions .= $option . ' ';
}
}
+
return $propertiesAndOptions;
}
}
diff --git a/src/PhpWord/Writer/Word2007/Element/Footnote.php b/src/PhpWord/Writer/Word2007/Element/Footnote.php
index 53fcd6a0..65ef40c7 100644
--- a/src/PhpWord/Writer/Word2007/Element/Footnote.php
+++ b/src/PhpWord/Writer/Word2007/Element/Footnote.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,8 +33,6 @@ class Footnote extends Text
/**
* Write element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/FormField.php b/src/PhpWord/Writer/Word2007/Element/FormField.php
index 27df756f..91fb28ab 100644
--- a/src/PhpWord/Writer/Word2007/Element/FormField.php
+++ b/src/PhpWord/Writer/Word2007/Element/FormField.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -27,7 +27,7 @@ use PhpOffice\PhpWord\Settings;
* Note: DropDown is active when document protection is set to `forms`
*
* @since 0.12.0
- * @link http://www.datypic.com/sc/ooxml/t-w_CT_FFData.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_CT_FFData.html
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
*/
class FormField extends Text
@@ -37,8 +37,6 @@ class FormField extends Text
/**
* Write element.
- *
- * @return void
*/
public function write()
{
@@ -80,7 +78,7 @@ class FormField extends Text
$xmlWriter->startElement('w:instrText');
$xmlWriter->writeAttribute('xml:space', 'preserve');
$xmlWriter->text("{$instruction}");
- $xmlWriter->endElement();// w:instrText
+ $xmlWriter->endElement(); // w:instrText
$xmlWriter->endElement(); // w:r
$xmlWriter->startElement('w:r');
@@ -111,10 +109,9 @@ class FormField extends Text
/**
* Write textinput.
*
- * @link http://www.datypic.com/sc/ooxml/t-w_CT_FFTextInput.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_CT_FFTextInput.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\FormField $element
- * @return void
*/
private function writeTextInput(XMLWriter $xmlWriter, FormFieldElement $element)
{
@@ -128,10 +125,9 @@ class FormField extends Text
/**
* Write checkbox.
*
- * @link http://www.datypic.com/sc/ooxml/t-w_CT_FFCheckBox.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_CT_FFCheckBox.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\FormField $element
- * @return void
*/
private function writeCheckBox(XMLWriter $xmlWriter, FormFieldElement $element)
{
@@ -152,10 +148,9 @@ class FormField extends Text
/**
* Write dropdown.
*
- * @link http://www.datypic.com/sc/ooxml/t-w_CT_FFDDList.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_CT_FFDDList.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\FormField $element
- * @return void
*/
private function writeDropDown(XMLWriter $xmlWriter, FormFieldElement $element)
{
diff --git a/src/PhpWord/Writer/Word2007/Element/Image.php b/src/PhpWord/Writer/Word2007/Element/Image.php
index edf32739..7e33f75e 100644
--- a/src/PhpWord/Writer/Word2007/Element/Image.php
+++ b/src/PhpWord/Writer/Word2007/Element/Image.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -30,8 +30,6 @@ class Image extends AbstractElement
{
/**
* Write element.
- *
- * @return void
*/
public function write()
{
@@ -50,8 +48,6 @@ class Image extends AbstractElement
/**
* Write image element.
- *
- * @return void
*/
private function writeImage(XMLWriter $xmlWriter, ImageElement $element)
{
@@ -86,8 +82,6 @@ class Image extends AbstractElement
/**
* Write watermark element.
- *
- * @return void
*/
private function writeWatermark(XMLWriter $xmlWriter, ImageElement $element)
{
diff --git a/src/PhpWord/Writer/Word2007/Element/Line.php b/src/PhpWord/Writer/Word2007/Element/Line.php
index ebc5d395..9b1a160d 100644
--- a/src/PhpWord/Writer/Word2007/Element/Line.php
+++ b/src/PhpWord/Writer/Word2007/Element/Line.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -22,19 +22,16 @@ use PhpOffice\PhpWord\Writer\Word2007\Style\Line as LineStyleWriter;
/**
* Line element writer
- *
*/
class Line extends AbstractElement
{
/**
* Write element.
- *
- * @return void
*/
public function write()
{
$xmlWriter = $this->getXmlWriter();
- $element = $this->getElement();
+ $element = $this->getElement();
if (!$element instanceof LineElement) {
return;
}
diff --git a/src/PhpWord/Writer/Word2007/Element/Link.php b/src/PhpWord/Writer/Word2007/Element/Link.php
index 5f7ad278..8ea3f53c 100644
--- a/src/PhpWord/Writer/Word2007/Element/Link.php
+++ b/src/PhpWord/Writer/Word2007/Element/Link.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,8 +28,6 @@ class Link extends Text
{
/**
* Write link element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/ListItem.php b/src/PhpWord/Writer/Word2007/Element/ListItem.php
index 53644ffa..c1aa0ce3 100644
--- a/src/PhpWord/Writer/Word2007/Element/ListItem.php
+++ b/src/PhpWord/Writer/Word2007/Element/ListItem.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,8 +28,6 @@ class ListItem extends AbstractElement
{
/**
* Write list item element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/ListItemRun.php b/src/PhpWord/Writer/Word2007/Element/ListItemRun.php
index 1ac17a98..e6ed2b46 100644
--- a/src/PhpWord/Writer/Word2007/Element/ListItemRun.php
+++ b/src/PhpWord/Writer/Word2007/Element/ListItemRun.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,8 +28,6 @@ class ListItemRun extends AbstractElement
{
/**
* Write list item element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/Object.php b/src/PhpWord/Writer/Word2007/Element/Object.php
index fc0532cd..8231ec0c 100644
--- a/src/PhpWord/Writer/Word2007/Element/Object.php
+++ b/src/PhpWord/Writer/Word2007/Element/Object.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,8 +28,6 @@ class Object extends AbstractElement
{
/**
* Write object element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/PageBreak.php b/src/PhpWord/Writer/Word2007/Element/PageBreak.php
index 363a8c2c..04ff29d4 100644
--- a/src/PhpWord/Writer/Word2007/Element/PageBreak.php
+++ b/src/PhpWord/Writer/Word2007/Element/PageBreak.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,7 +28,6 @@ class PageBreak extends AbstractElement
* Write element.
*
* @usedby \PhpOffice\PhpWord\Writer\Word2007\Element\AbstractElement::startElementP()
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/ParagraphAlignment.php b/src/PhpWord/Writer/Word2007/Element/ParagraphAlignment.php
index 2c775d14..0dafa4a0 100644
--- a/src/PhpWord/Writer/Word2007/Element/ParagraphAlignment.php
+++ b/src/PhpWord/Writer/Word2007/Element/ParagraphAlignment.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -29,7 +29,7 @@ class ParagraphAlignment
/**
* @since 0.13.0
*
- * @param string $value Any value provided by Jc simple type.
+ * @param string $value Any value provided by Jc simple type
*
* @see \PhpOffice\PhpWord\SimpleType\Jc For the allowed values of $value parameter.
*/
diff --git a/src/PhpWord/Writer/Word2007/Element/PreserveText.php b/src/PhpWord/Writer/Word2007/Element/PreserveText.php
index 82c6f87b..92b9ea40 100644
--- a/src/PhpWord/Writer/Word2007/Element/PreserveText.php
+++ b/src/PhpWord/Writer/Word2007/Element/PreserveText.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,8 +28,6 @@ class PreserveText extends Text
{
/**
* Write preserve text element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/SDT.php b/src/PhpWord/Writer/Word2007/Element/SDT.php
index 313bf7e0..e77f87e9 100644
--- a/src/PhpWord/Writer/Word2007/Element/SDT.php
+++ b/src/PhpWord/Writer/Word2007/Element/SDT.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -24,15 +24,13 @@ use PhpOffice\PhpWord\Element\SDT as SDTElement;
* Structured document tag element writer
*
* @since 0.12.0
- * @link http://www.datypic.com/sc/ooxml/t-w_CT_SdtBlock.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtBlock.html
* @SuppressWarnings(PHPMD.UnusedPrivateMethod)
*/
class SDT extends Text
{
/**
* Write element.
- *
- * @return void
*/
public function write()
{
@@ -70,10 +68,9 @@ class SDT extends Text
/**
* Write combo box.
*
- * @link http://www.datypic.com/sc/ooxml/t-w_CT_SdtComboBox.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtComboBox.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\SDT $element
- * @return void
*/
private function writeComboBox(XMLWriter $xmlWriter, SDTElement $element)
{
@@ -90,10 +87,9 @@ class SDT extends Text
/**
* Write drop down list.
*
- * @link http://www.datypic.com/sc/ooxml/t-w_CT_SdtDropDownList.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtDropDownList.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\SDT $element
- * @return void
*/
private function writeDropDownList(XMLWriter $xmlWriter, SDTElement $element)
{
@@ -103,10 +99,9 @@ class SDT extends Text
/**
* Write date.
*
- * @link http://www.datypic.com/sc/ooxml/t-w_CT_SdtDate.html
+ * @see http://www.datypic.com/sc/ooxml/t-w_CT_SdtDate.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\SDT $element
- * @return void
*/
private function writeDate(XMLWriter $xmlWriter, SDTElement $element)
{
diff --git a/src/PhpWord/Writer/Word2007/Element/Shape.php b/src/PhpWord/Writer/Word2007/Element/Shape.php
index a589af6c..e384db06 100644
--- a/src/PhpWord/Writer/Word2007/Element/Shape.php
+++ b/src/PhpWord/Writer/Word2007/Element/Shape.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -32,8 +32,6 @@ class Shape extends AbstractElement
{
/**
* Write element.
- *
- * @return void
*/
public function write()
{
@@ -81,7 +79,6 @@ class Shape extends AbstractElement
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Shape $style
- * @return void
*/
private function writeArc(XMLWriter $xmlWriter, ShapeStyle $style)
{
@@ -96,7 +93,6 @@ class Shape extends AbstractElement
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Shape $style
- * @return void
*/
private function writeCurve(XMLWriter $xmlWriter, ShapeStyle $style)
{
@@ -112,7 +108,6 @@ class Shape extends AbstractElement
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Shape $style
- * @return void
*/
private function writeLine(XMLWriter $xmlWriter, ShapeStyle $style)
{
@@ -127,7 +122,6 @@ class Shape extends AbstractElement
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Shape $style
- * @return void
*/
private function writePolyline(XMLWriter $xmlWriter, ShapeStyle $style)
{
@@ -139,7 +133,6 @@ class Shape extends AbstractElement
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Shape $style
- * @return void
*/
private function writeRoundRect(XMLWriter $xmlWriter, ShapeStyle $style)
{
diff --git a/src/PhpWord/Writer/Word2007/Element/TOC.php b/src/PhpWord/Writer/Word2007/Element/TOC.php
index 996edb64..a679188f 100644
--- a/src/PhpWord/Writer/Word2007/Element/TOC.php
+++ b/src/PhpWord/Writer/Word2007/Element/TOC.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -34,8 +34,6 @@ class TOC extends AbstractElement
{
/**
* Write element.
- *
- * @return void
*/
public function write()
{
@@ -71,7 +69,6 @@ class TOC extends AbstractElement
* @param \PhpOffice\PhpWord\Element\TOC $element
* @param \PhpOffice\PhpWord\Element\Title $title
* @param bool $writeFieldMark
- * @return void
*/
private function writeTitle(XMLWriter $xmlWriter, TOCElement $element, $title, $writeFieldMark)
{
@@ -143,7 +140,6 @@ class TOC extends AbstractElement
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\TOC $element
* @param int $indent
- * @return void
*/
private function writeStyle(XMLWriter $xmlWriter, TOCElement $element, $indent)
{
@@ -189,7 +185,6 @@ class TOC extends AbstractElement
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\TOC $element
- * @return void
*/
private function writeFieldMark(XMLWriter $xmlWriter, TOCElement $element)
{
diff --git a/src/PhpWord/Writer/Word2007/Element/Table.php b/src/PhpWord/Writer/Word2007/Element/Table.php
index 093666ee..c0590772 100644
--- a/src/PhpWord/Writer/Word2007/Element/Table.php
+++ b/src/PhpWord/Writer/Word2007/Element/Table.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,8 +36,6 @@ class Table extends AbstractElement
{
/**
* Write element.
- *
- * @return void
*/
public function write()
{
@@ -75,7 +73,6 @@ class Table extends AbstractElement
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Table $element
- * @return void
*/
private function writeColumns(XMLWriter $xmlWriter, TableElement $element)
{
@@ -112,7 +109,6 @@ class Table extends AbstractElement
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Row $row
- * @return void
*/
private function writeRow(XMLWriter $xmlWriter, RowElement $row)
{
@@ -139,11 +135,9 @@ class Table extends AbstractElement
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Cell $cell
- * @return void
*/
private function writeCell(XMLWriter $xmlWriter, CellElement $cell)
{
-
$xmlWriter->startElement('w:tc');
// Write style
diff --git a/src/PhpWord/Writer/Word2007/Element/TableAlignment.php b/src/PhpWord/Writer/Word2007/Element/TableAlignment.php
index 45459a38..44450fd6 100644
--- a/src/PhpWord/Writer/Word2007/Element/TableAlignment.php
+++ b/src/PhpWord/Writer/Word2007/Element/TableAlignment.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -29,7 +29,7 @@ class TableAlignment
/**
* @since 0.13.0
*
- * @param string $value Any value provided by JcTable simple type.
+ * @param string $value Any value provided by JcTable simple type
*
* @see \PhpOffice\PhpWord\SimpleType\JcTable For the allowed values of $value parameter.
*/
diff --git a/src/PhpWord/Writer/Word2007/Element/Text.php b/src/PhpWord/Writer/Word2007/Element/Text.php
index 2df4892b..694a834a 100644
--- a/src/PhpWord/Writer/Word2007/Element/Text.php
+++ b/src/PhpWord/Writer/Word2007/Element/Text.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,8 +28,6 @@ class Text extends AbstractElement
{
/**
* Write text element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/TextBox.php b/src/PhpWord/Writer/Word2007/Element/TextBox.php
index e83fe0c9..3780c698 100644
--- a/src/PhpWord/Writer/Word2007/Element/TextBox.php
+++ b/src/PhpWord/Writer/Word2007/Element/TextBox.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,8 +28,6 @@ class TextBox extends Image
{
/**
* Write element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/TextBreak.php b/src/PhpWord/Writer/Word2007/Element/TextBreak.php
index a9e6f613..161a528e 100644
--- a/src/PhpWord/Writer/Word2007/Element/TextBreak.php
+++ b/src/PhpWord/Writer/Word2007/Element/TextBreak.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class TextBreak extends Text
{
/**
* Write text break element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/TextRun.php b/src/PhpWord/Writer/Word2007/Element/TextRun.php
index 1e95ab5c..9fd70b13 100644
--- a/src/PhpWord/Writer/Word2007/Element/TextRun.php
+++ b/src/PhpWord/Writer/Word2007/Element/TextRun.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class TextRun extends Text
{
/**
* Write textrun element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Element/Title.php b/src/PhpWord/Writer/Word2007/Element/Title.php
index 925d4c43..63ed94de 100644
--- a/src/PhpWord/Writer/Word2007/Element/Title.php
+++ b/src/PhpWord/Writer/Word2007/Element/Title.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,8 +28,6 @@ class Title extends AbstractElement
{
/**
* Write title element.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
index 26734aa0..0b9d8b88 100644
--- a/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
+++ b/src/PhpWord/Writer/Word2007/Part/AbstractPart.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -50,7 +50,6 @@ abstract class AbstractPart
* Set parent writer.
*
* @param \PhpOffice\PhpWord\Writer\AbstractWriter $writer
- * @return void
*/
public function setParentWriter(AbstractWriter $writer = null)
{
@@ -60,17 +59,15 @@ abstract class AbstractPart
/**
* Get parent writer
*
- * @return \PhpOffice\PhpWord\Writer\AbstractWriter
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
+ * @return \PhpOffice\PhpWord\Writer\AbstractWriter
*/
public function getParentWriter()
{
if (!is_null($this->parentWriter)) {
return $this->parentWriter;
- } else {
- throw new Exception('No parent WriterInterface assigned.');
}
+ throw new Exception('No parent WriterInterface assigned.');
}
/**
@@ -88,8 +85,8 @@ abstract class AbstractPart
}
if ($useDiskCaching) {
return new XMLWriter(XMLWriter::STORAGE_DISK, $this->parentWriter->getDiskCachingDirectory(), Settings::hasCompatibility());
- } else {
- return new XMLWriter(XMLWriter::STORAGE_MEMORY, './', Settings::hasCompatibility());
}
+
+ return new XMLWriter(XMLWriter::STORAGE_MEMORY, './', Settings::hasCompatibility());
}
}
diff --git a/src/PhpWord/Writer/Word2007/Part/Chart.php b/src/PhpWord/Writer/Word2007/Part/Chart.php
index 86045b9a..2f162108 100644
--- a/src/PhpWord/Writer/Word2007/Part/Chart.php
+++ b/src/PhpWord/Writer/Word2007/Part/Chart.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -24,14 +24,14 @@ use PhpOffice\PhpWord\Element\Chart as ChartElement;
* Word2007 chart part writer: word/charts/chartx.xml
*
* @since 0.12.0
- * @link http://www.datypic.com/sc/ooxml/e-draw-chart_chartSpace.html
+ * @see http://www.datypic.com/sc/ooxml/e-draw-chart_chartSpace.html
*/
class Chart extends AbstractPart
{
/**
* Chart element
*
- * @var \PhpOffice\PhpWord\Element\Chart $element
+ * @var \PhpOffice\PhpWord\Element\Chart
*/
private $element;
@@ -62,7 +62,6 @@ class Chart extends AbstractPart
* Set chart element.
*
* @param \PhpOffice\PhpWord\Element\Chart $element
- * @return void
*/
public function setElement(ChartElement $element)
{
@@ -95,9 +94,8 @@ class Chart extends AbstractPart
/**
* Write chart
*
- * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_Chart.html
+ * @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_Chart.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter
- * @return void
*/
private function writeChart(XMLWriter $xmlWriter)
{
@@ -113,16 +111,15 @@ class Chart extends AbstractPart
/**
* Write plot area.
*
- * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_PlotArea.html
- * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_PieChart.html
- * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_DoughnutChart.html
- * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_BarChart.html
- * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_LineChart.html
- * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_AreaChart.html
- * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_RadarChart.html
- * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_ScatterChart.html
+ * @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_PlotArea.html
+ * @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_PieChart.html
+ * @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_DoughnutChart.html
+ * @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_BarChart.html
+ * @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_LineChart.html
+ * @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_AreaChart.html
+ * @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_RadarChart.html
+ * @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_ScatterChart.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter
- * @return void
*/
private function writePlotArea(XMLWriter $xmlWriter)
{
@@ -135,7 +132,7 @@ class Chart extends AbstractPart
// Chart
$chartType = $this->options['type'];
- $chartType .= $style->is3d() && !isset($this->options['no3d'])? '3D' : '';
+ $chartType .= $style->is3d() && !isset($this->options['no3d']) ? '3D' : '';
$chartType .= 'Chart';
$xmlWriter->startElement("c:{$chartType}");
@@ -182,7 +179,6 @@ class Chart extends AbstractPart
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param bool $scatter
- * @return void
*/
private function writeSeries(XMLWriter $xmlWriter, $scatter = false)
{
@@ -221,13 +217,12 @@ class Chart extends AbstractPart
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param string $type
* @param array $values
- * @return void
*/
private function writeSeriesItem(XMLWriter $xmlWriter, $type, $values)
{
$types = array(
- 'cat' => array('c:cat', 'c:strLit'),
- 'val' => array('c:val', 'c:numLit'),
+ 'cat' => array('c:cat', 'c:strLit'),
+ 'val' => array('c:val', 'c:numLit'),
'xVal' => array('c:xVal', 'c:strLit'),
'yVal' => array('c:yVal', 'c:numLit'),
);
@@ -258,10 +253,9 @@ class Chart extends AbstractPart
/**
* Write axis
*
- * @link http://www.datypic.com/sc/ooxml/t-draw-chart_CT_CatAx.html
+ * @see http://www.datypic.com/sc/ooxml/t-draw-chart_CT_CatAx.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param string $type
- * @return void
*/
private function writeAxis(XMLWriter $xmlWriter, $type)
{
@@ -301,10 +295,9 @@ class Chart extends AbstractPart
/**
* Write shape
*
- * @link http://www.datypic.com/sc/ooxml/t-a_CT_ShapeProperties.html
+ * @see http://www.datypic.com/sc/ooxml/t-a_CT_ShapeProperties.html
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param bool $line
- * @return void
*/
private function writeShape(XMLWriter $xmlWriter, $line = false)
{
diff --git a/src/PhpWord/Writer/Word2007/Part/Comments.php b/src/PhpWord/Writer/Word2007/Part/Comments.php
index 73314785..b2b49864 100644
--- a/src/PhpWord/Writer/Word2007/Part/Comments.php
+++ b/src/PhpWord/Writer/Word2007/Part/Comments.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -72,7 +72,6 @@ class Comments extends AbstractPart
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Comment $comment
- * @return void
*/
protected function writeComment(XMLWriter $xmlWriter, Comment $comment)
{
diff --git a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php
index 7a03243e..9be988d3 100644
--- a/src/PhpWord/Writer/Word2007/Part/ContentTypes.php
+++ b/src/PhpWord/Writer/Word2007/Part/ContentTypes.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,20 +36,20 @@ class ContentTypes extends AbstractPart
$contentTypes = $parentWriter->getContentTypes();
$openXMLPrefix = 'application/vnd.openxmlformats-';
- $wordMLPrefix = $openXMLPrefix . 'officedocument.wordprocessingml.';
- $drawingMLPrefix = $openXMLPrefix . 'officedocument.drawingml.';
+ $wordMLPrefix = $openXMLPrefix . 'officedocument.wordprocessingml.';
+ $drawingMLPrefix = $openXMLPrefix . 'officedocument.drawingml.';
$overrides = array(
'/docProps/core.xml' => $openXMLPrefix . 'package.core-properties+xml',
'/docProps/app.xml' => $openXMLPrefix . 'officedocument.extended-properties+xml',
'/docProps/custom.xml' => $openXMLPrefix . 'officedocument.custom-properties+xml',
- '/word/document.xml' => $wordMLPrefix . 'document.main+xml',
- '/word/styles.xml' => $wordMLPrefix . 'styles+xml',
- '/word/numbering.xml' => $wordMLPrefix . 'numbering+xml',
- '/word/settings.xml' => $wordMLPrefix . 'settings+xml',
+ '/word/document.xml' => $wordMLPrefix . 'document.main+xml',
+ '/word/styles.xml' => $wordMLPrefix . 'styles+xml',
+ '/word/numbering.xml' => $wordMLPrefix . 'numbering+xml',
+ '/word/settings.xml' => $wordMLPrefix . 'settings+xml',
'/word/theme/theme1.xml' => $openXMLPrefix . 'officedocument.theme+xml',
- '/word/webSettings.xml' => $wordMLPrefix . 'webSettings+xml',
- '/word/fontTable.xml' => $wordMLPrefix . 'fontTable+xml',
- '/word/comments.xml' => $wordMLPrefix . 'comments+xml',
+ '/word/webSettings.xml' => $wordMLPrefix . 'webSettings+xml',
+ '/word/fontTable.xml' => $wordMLPrefix . 'fontTable+xml',
+ '/word/comments.xml' => $wordMLPrefix . 'comments+xml',
);
$defaults = $contentTypes['default'];
@@ -82,8 +82,7 @@ class ContentTypes extends AbstractPart
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter XML Writer
* @param array $parts
- * @param boolean $isDefault
- * @return void
+ * @param bool $isDefault
*/
private function writeContentType(XMLWriter $xmlWriter, $parts, $isDefault)
{
diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php b/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php
index adfe752f..dbd55187 100644
--- a/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php
+++ b/src/PhpWord/Writer/Word2007/Part/DocPropsApp.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php b/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php
index afb6f286..fdabee36 100644
--- a/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php
+++ b/src/PhpWord/Writer/Word2007/Part/DocPropsCore.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007/Part/DocPropsCustom.php b/src/PhpWord/Writer/Word2007/Part/DocPropsCustom.php
index 63ed8ede..212e9d27 100644
--- a/src/PhpWord/Writer/Word2007/Part/DocPropsCustom.php
+++ b/src/PhpWord/Writer/Word2007/Part/DocPropsCustom.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007/Part/Document.php b/src/PhpWord/Writer/Word2007/Part/Document.php
index 11e3f510..72e4fcd8 100644
--- a/src/PhpWord/Writer/Word2007/Part/Document.php
+++ b/src/PhpWord/Writer/Word2007/Part/Document.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -56,7 +56,6 @@ class Document extends AbstractPart
$xmlWriter->startElement('w:body');
-
if ($sectionCount > 0) {
foreach ($sections as $section) {
$currentSection++;
@@ -83,7 +82,6 @@ class Document extends AbstractPart
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Section $section
- * @return void
*/
private function writeSection(XMLWriter $xmlWriter, Section $section)
{
@@ -99,7 +97,6 @@ class Document extends AbstractPart
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Section $section
- * @return void
*/
private function writeSectionSettings(XMLWriter $xmlWriter, Section $section)
{
diff --git a/src/PhpWord/Writer/Word2007/Part/Endnotes.php b/src/PhpWord/Writer/Word2007/Part/Endnotes.php
index bc15cf1e..289119db 100644
--- a/src/PhpWord/Writer/Word2007/Part/Endnotes.php
+++ b/src/PhpWord/Writer/Word2007/Part/Endnotes.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007/Part/FontTable.php b/src/PhpWord/Writer/Word2007/Part/FontTable.php
index 08f0ad0e..065a318e 100644
--- a/src/PhpWord/Writer/Word2007/Part/FontTable.php
+++ b/src/PhpWord/Writer/Word2007/Part/FontTable.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007/Part/Footer.php b/src/PhpWord/Writer/Word2007/Part/Footer.php
index 3e4e4fee..cfc9dd40 100644
--- a/src/PhpWord/Writer/Word2007/Part/Footer.php
+++ b/src/PhpWord/Writer/Word2007/Part/Footer.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007/Part/Footnotes.php b/src/PhpWord/Writer/Word2007/Part/Footnotes.php
index fd692149..c9e3bcac 100644
--- a/src/PhpWord/Writer/Word2007/Part/Footnotes.php
+++ b/src/PhpWord/Writer/Word2007/Part/Footnotes.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -137,7 +137,6 @@ class Footnotes extends AbstractPart
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Element\Footnote|\PhpOffice\PhpWord\Element\Endnote $element
- * @return void
*/
protected function writeNote(XMLWriter $xmlWriter, $element)
{
diff --git a/src/PhpWord/Writer/Word2007/Part/Header.php b/src/PhpWord/Writer/Word2007/Part/Header.php
index 438e503e..5853d92f 100644
--- a/src/PhpWord/Writer/Word2007/Part/Header.php
+++ b/src/PhpWord/Writer/Word2007/Part/Header.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007/Part/Numbering.php b/src/PhpWord/Writer/Word2007/Part/Numbering.php
index c5c9b4c7..6233a6b7 100644
--- a/src/PhpWord/Writer/Word2007/Part/Numbering.php
+++ b/src/PhpWord/Writer/Word2007/Part/Numbering.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -99,7 +99,6 @@ class Numbering extends AbstractPart
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
- * @return void
*/
private function writeLevel(XMLWriter $xmlWriter, NumberingLevel $level)
{
@@ -140,7 +139,6 @@ class Numbering extends AbstractPart
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
- * @return void
* @todo Use paragraph style writer
*/
private function writeParagraph(XMLWriter $xmlWriter, NumberingLevel $level)
@@ -173,7 +171,6 @@ class Numbering extends AbstractPart
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\NumberingLevel $level
- * @return void
* @todo Use font style writer
*/
private function writeFont(XMLWriter $xmlWriter, NumberingLevel $level)
diff --git a/src/PhpWord/Writer/Word2007/Part/Rels.php b/src/PhpWord/Writer/Word2007/Part/Rels.php
index 4a3b5b67..154c7e89 100644
--- a/src/PhpWord/Writer/Word2007/Part/Rels.php
+++ b/src/PhpWord/Writer/Word2007/Part/Rels.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -53,7 +53,6 @@ class Rels extends AbstractPart
* @param array $xmlRels
* @param array $mediaRels
* @param int $relId
- * @return void
*/
protected function writeRels(XMLWriter $xmlWriter, $xmlRels = array(), $mediaRels = array(), $relId = 1)
{
@@ -80,7 +79,6 @@ class Rels extends AbstractPart
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param int $relId
* @param array $mediaRel
- * @return void
*/
private function writeMediaRel(XMLWriter $xmlWriter, $relId, $mediaRel)
{
@@ -109,8 +107,6 @@ class Rels extends AbstractPart
* @param string $target Relationship target
* @param string $targetMode Relationship target mode
*
- * @return void
- *
* @throws \PhpOffice\PhpWord\Exception\Exception
*/
private function writeRel(XMLWriter $xmlWriter, $relId, $type, $target, $targetMode = '')
@@ -128,7 +124,7 @@ class Rels extends AbstractPart
}
$xmlWriter->endElement();
} else {
- throw new Exception("Invalid parameters passed.");
+ throw new Exception('Invalid parameters passed.');
}
}
}
diff --git a/src/PhpWord/Writer/Word2007/Part/RelsDocument.php b/src/PhpWord/Writer/Word2007/Part/RelsDocument.php
index c60dba28..505aa223 100644
--- a/src/PhpWord/Writer/Word2007/Part/RelsDocument.php
+++ b/src/PhpWord/Writer/Word2007/Part/RelsDocument.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007/Part/RelsPart.php b/src/PhpWord/Writer/Word2007/Part/RelsPart.php
index e8939c7f..e639c041 100644
--- a/src/PhpWord/Writer/Word2007/Part/RelsPart.php
+++ b/src/PhpWord/Writer/Word2007/Part/RelsPart.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007/Part/Settings.php b/src/PhpWord/Writer/Word2007/Part/Settings.php
index eca70d29..b205619d 100644
--- a/src/PhpWord/Writer/Word2007/Part/Settings.php
+++ b/src/PhpWord/Writer/Word2007/Part/Settings.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -24,7 +24,7 @@ use PhpOffice\PhpWord\Style\Language;
/**
* Word2007 settings part writer: word/settings.xml
*
- * @link http://www.schemacentral.com/sc/ooxml/t-w_CT_Settings.html
+ * @see http://www.schemacentral.com/sc/ooxml/t-w_CT_Settings.html
*/
class Settings extends AbstractPart
{
@@ -71,7 +71,6 @@ class Settings extends AbstractPart
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param string $settingKey
* @param array|string $settingValue
- * @return void
*/
protected function writeSetting($xmlWriter, $settingKey, $settingValue)
{
@@ -96,49 +95,46 @@ class Settings extends AbstractPart
/**
* Get settings.
- *
- * @return void
*/
private function getSettings()
{
-
/** @var \PhpOffice\PhpWord\Metadata\Settings $documentSettings */
$documentSettings = $this->getParentWriter()->getPhpWord()->getSettings();
// Default settings
$this->settings = array(
- 'w:defaultTabStop' => array('@attributes' => array('w:val' => '708')),
- 'w:hyphenationZone' => array('@attributes' => array('w:val' => '425')),
+ 'w:defaultTabStop' => array('@attributes' => array('w:val' => '708')),
+ 'w:hyphenationZone' => array('@attributes' => array('w:val' => '425')),
'w:characterSpacingControl' => array('@attributes' => array('w:val' => 'doNotCompress')),
- 'w:decimalSymbol' => array('@attributes' => array('w:val' => $documentSettings->getDecimalSymbol())),
- 'w:listSeparator' => array('@attributes' => array('w:val' => ';')),
- 'w:compat' => array(),
- 'm:mathPr' => array(
- 'm:mathFont' => array('@attributes' => array('m:val' => 'Cambria Math')),
- 'm:brkBin' => array('@attributes' => array('m:val' => 'before')),
- 'm:brkBinSub' => array('@attributes' => array('m:val' => '--')),
- 'm:smallFrac' => array('@attributes' => array('m:val' => 'off')),
- 'm:dispDef' => '',
- 'm:lMargin' => array('@attributes' => array('m:val' => '0')),
- 'm:rMargin' => array('@attributes' => array('m:val' => '0')),
- 'm:defJc' => array('@attributes' => array('m:val' => 'centerGroup')),
+ 'w:decimalSymbol' => array('@attributes' => array('w:val' => $documentSettings->getDecimalSymbol())),
+ 'w:listSeparator' => array('@attributes' => array('w:val' => ';')),
+ 'w:compat' => array(),
+ 'm:mathPr' => array(
+ 'm:mathFont' => array('@attributes' => array('m:val' => 'Cambria Math')),
+ 'm:brkBin' => array('@attributes' => array('m:val' => 'before')),
+ 'm:brkBinSub' => array('@attributes' => array('m:val' => '--')),
+ 'm:smallFrac' => array('@attributes' => array('m:val' => 'off')),
+ 'm:dispDef' => '',
+ 'm:lMargin' => array('@attributes' => array('m:val' => '0')),
+ 'm:rMargin' => array('@attributes' => array('m:val' => '0')),
+ 'm:defJc' => array('@attributes' => array('m:val' => 'centerGroup')),
'm:wrapIndent' => array('@attributes' => array('m:val' => '1440')),
- 'm:intLim' => array('@attributes' => array('m:val' => 'subSup')),
- 'm:naryLim' => array('@attributes' => array('m:val' => 'undOvr')),
+ 'm:intLim' => array('@attributes' => array('m:val' => 'subSup')),
+ 'm:naryLim' => array('@attributes' => array('m:val' => 'undOvr')),
),
'w:clrSchemeMapping' => array(
'@attributes' => array(
- 'w:bg1' => 'light1',
- 'w:t1' => 'dark1',
- 'w:bg2' => 'light2',
- 'w:t2' => 'dark2',
- 'w:accent1' => 'accent1',
- 'w:accent2' => 'accent2',
- 'w:accent3' => 'accent3',
- 'w:accent4' => 'accent4',
- 'w:accent5' => 'accent5',
- 'w:accent6' => 'accent6',
- 'w:hyperlink' => 'hyperlink',
+ 'w:bg1' => 'light1',
+ 'w:t1' => 'dark1',
+ 'w:bg2' => 'light2',
+ 'w:t2' => 'dark2',
+ 'w:accent1' => 'accent1',
+ 'w:accent2' => 'accent2',
+ 'w:accent3' => 'accent3',
+ 'w:accent4' => 'accent4',
+ 'w:accent5' => 'accent5',
+ 'w:accent6' => 'accent6',
+ 'w:hyperlink' => 'hyperlink',
'w:followedHyperlink' => 'followedHyperlink',
),
),
@@ -163,7 +159,7 @@ class Settings extends AbstractPart
* Adds a boolean attribute to the settings array
*
* @param string $settingName
- * @param boolean $booleanValue
+ * @param bool $booleanValue
*/
private function setOnOffValue($settingName, $booleanValue)
{
@@ -180,7 +176,6 @@ class Settings extends AbstractPart
* Get protection settings.
*
* @param \PhpOffice\PhpWord\Metadata\Protection $documentProtection
- * @return void
*/
private function setDocumentProtection($documentProtection)
{
@@ -188,8 +183,8 @@ class Settings extends AbstractPart
$this->settings['w:documentProtection'] = array(
'@attributes' => array(
'w:enforcement' => 1,
- 'w:edit' => $documentProtection->getEditing(),
- )
+ 'w:edit' => $documentProtection->getEditing(),
+ ),
);
}
}
@@ -205,8 +200,8 @@ class Settings extends AbstractPart
$this->settings['w:proofState'] = array(
'@attributes' => array(
'w:spelling' => $proofState->getSpelling(),
- 'w:grammar' => $proofState->getGrammar()
- )
+ 'w:grammar' => $proofState->getGrammar(),
+ ),
);
}
}
@@ -219,11 +214,11 @@ class Settings extends AbstractPart
private function setRevisionView(TrackChangesView $trackChangesView = null)
{
if ($trackChangesView != null) {
- $revisionView['w:markup'] = $trackChangesView->hasMarkup() ? 'true': 'false';
- $revisionView['w:comments'] = $trackChangesView->hasComments() ? 'true': 'false';
- $revisionView['w:insDel'] = $trackChangesView->hasInsDel() ? 'true': 'false';
- $revisionView['w:formatting'] = $trackChangesView->hasFormatting() ? 'true': 'false';
- $revisionView['w:inkAnnotations'] = $trackChangesView->hasInkAnnotations() ? 'true': 'false';
+ $revisionView['w:markup'] = $trackChangesView->hasMarkup() ? 'true' : 'false';
+ $revisionView['w:comments'] = $trackChangesView->hasComments() ? 'true' : 'false';
+ $revisionView['w:insDel'] = $trackChangesView->hasInsDel() ? 'true' : 'false';
+ $revisionView['w:formatting'] = $trackChangesView->hasFormatting() ? 'true' : 'false';
+ $revisionView['w:inkAnnotations'] = $trackChangesView->hasInkAnnotations() ? 'true' : 'false';
$this->settings['w:revisionView'] = array('@attributes' => $revisionView);
}
@@ -231,7 +226,7 @@ class Settings extends AbstractPart
/**
* Sets the language
- *
+ *
* @param Language $language
*/
private function setThemeFontLang(Language $language = null)
@@ -261,8 +256,6 @@ class Settings extends AbstractPart
/**
* Get compatibility setting.
- *
- * @return void
*/
private function getCompatibility()
{
diff --git a/src/PhpWord/Writer/Word2007/Part/Styles.php b/src/PhpWord/Writer/Word2007/Part/Styles.php
index 7795d56b..126cda4f 100644
--- a/src/PhpWord/Writer/Word2007/Part/Styles.php
+++ b/src/PhpWord/Writer/Word2007/Part/Styles.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -79,7 +79,6 @@ class Styles extends AbstractPart
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\AbstractStyle[] $styles
- * @return void
*/
private function writeDefaultStyles(XMLWriter $xmlWriter, $styles)
{
@@ -154,7 +153,6 @@ class Styles extends AbstractPart
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param string $styleName
* @param \PhpOffice\PhpWord\Style\Font $style
- * @return void
*/
private function writeFontStyle(XMLWriter $xmlWriter, $styleName, FontStyle $style)
{
@@ -179,7 +177,7 @@ class Styles extends AbstractPart
$xmlWriter->startElement('w:link');
$xmlWriter->writeAttribute('w:val', $styleLink);
$xmlWriter->endElement();
- } else if (!is_null($paragraphStyle)) {
+ } elseif (!is_null($paragraphStyle)) {
// if type is 'paragraph' it should have a styleId
$xmlWriter->writeAttribute('w:styleId', $styleName);
}
@@ -217,7 +215,6 @@ class Styles extends AbstractPart
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param string $styleName
* @param \PhpOffice\PhpWord\Style\Paragraph $style
- * @return void
*/
private function writeParagraphStyle(XMLWriter $xmlWriter, $styleName, ParagraphStyle $style)
{
@@ -250,7 +247,6 @@ class Styles extends AbstractPart
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param string $styleName
* @param \PhpOffice\PhpWord\Style\Table $style
- * @return void
*/
private function writeTableStyle(XMLWriter $xmlWriter, $styleName, TableStyle $style)
{
diff --git a/src/PhpWord/Writer/Word2007/Part/Theme.php b/src/PhpWord/Writer/Word2007/Part/Theme.php
index e9b16bfc..c264140e 100644
--- a/src/PhpWord/Writer/Word2007/Part/Theme.php
+++ b/src/PhpWord/Writer/Word2007/Part/Theme.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -48,7 +48,6 @@ class Theme extends AbstractPart
return $str;
}
-
/**
* Write color scheme
*
diff --git a/src/PhpWord/Writer/Word2007/Part/WebSettings.php b/src/PhpWord/Writer/Word2007/Part/WebSettings.php
index ce42063d..9f18e356 100644
--- a/src/PhpWord/Writer/Word2007/Part/WebSettings.php
+++ b/src/PhpWord/Writer/Word2007/Part/WebSettings.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php
index 0b8b0a52..d7756933 100644
--- a/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php
+++ b/src/PhpWord/Writer/Word2007/Style/AbstractStyle.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -88,11 +88,11 @@ abstract class AbstractStyle
protected function convertTwip($value, $default = 0)
{
$factors = array(
- Settings::UNIT_CM => 567,
- Settings::UNIT_MM => 56.7,
- Settings::UNIT_INCH => 1440,
+ Settings::UNIT_CM => 567,
+ Settings::UNIT_MM => 56.7,
+ Settings::UNIT_INCH => 1440,
Settings::UNIT_POINT => 20,
- Settings::UNIT_PICA => 240,
+ Settings::UNIT_PICA => 240,
);
$unit = Settings::getMeasurementUnit();
$factor = 1;
@@ -109,12 +109,11 @@ abstract class AbstractStyle
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param string $name
* @param mixed $value
- * @return void
*/
protected function writeChildStyle(XMLWriter $xmlWriter, $name, $value)
{
if ($value !== null) {
- $class = "PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\" . $name;
+ $class = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\' . $name;
/** @var \PhpOffice\PhpWord\Writer\Word2007\Style\AbstractStyle $writer */
$writer = new $class($xmlWriter, $value);
diff --git a/src/PhpWord/Writer/Word2007/Style/Cell.php b/src/PhpWord/Writer/Word2007/Style/Cell.php
index c9156de1..c2cf1c7c 100644
--- a/src/PhpWord/Writer/Word2007/Style/Cell.php
+++ b/src/PhpWord/Writer/Word2007/Style/Cell.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,8 +33,6 @@ class Cell extends AbstractStyle
/**
* Write style.
- *
- * @return void
*/
public function write()
{
@@ -93,7 +91,6 @@ class Cell extends AbstractStyle
* Set width.
*
* @param int $value
- * @return void
*/
public function setWidth($value = null)
{
diff --git a/src/PhpWord/Writer/Word2007/Style/Extrusion.php b/src/PhpWord/Writer/Word2007/Style/Extrusion.php
index 3ecd76e4..e3a86a58 100644
--- a/src/PhpWord/Writer/Word2007/Style/Extrusion.php
+++ b/src/PhpWord/Writer/Word2007/Style/Extrusion.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Extrusion extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
@@ -37,7 +35,7 @@ class Extrusion extends AbstractStyle
}
$xmlWriter = $this->getXmlWriter();
- $xmlWriter->startElement("o:extrusion");
+ $xmlWriter->startElement('o:extrusion');
$xmlWriter->writeAttribute('on', 't');
$xmlWriter->writeAttributeIf($style->getType() !== null, 'type', $style->getType());
$xmlWriter->writeAttributeIf($style->getColor() !== null, 'color', $style->getColor());
diff --git a/src/PhpWord/Writer/Word2007/Style/Fill.php b/src/PhpWord/Writer/Word2007/Style/Fill.php
index 7ce68106..de64313b 100644
--- a/src/PhpWord/Writer/Word2007/Style/Fill.php
+++ b/src/PhpWord/Writer/Word2007/Style/Fill.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Fill extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Style/Font.php b/src/PhpWord/Writer/Word2007/Style/Font.php
index 2248a448..0cb3209f 100644
--- a/src/PhpWord/Writer/Word2007/Style/Font.php
+++ b/src/PhpWord/Writer/Word2007/Style/Font.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,8 +33,6 @@ class Font extends AbstractStyle
/**
* Write style.
- *
- * @return void
*/
public function write()
{
@@ -54,8 +52,6 @@ class Font extends AbstractStyle
/**
* Write full style.
- *
- * @return void
*/
private function writeStyle()
{
@@ -139,7 +135,7 @@ class Font extends AbstractStyle
$styleWriter = new Shading($xmlWriter, $shading);
$styleWriter->write();
}
-
+
// RTL
if ($this->isInline === true) {
$styleName = $style->getStyleName();
@@ -153,7 +149,6 @@ class Font extends AbstractStyle
* Set is inline.
*
* @param bool $value
- * @return void
*/
public function setIsInline($value)
{
diff --git a/src/PhpWord/Writer/Word2007/Style/Frame.php b/src/PhpWord/Writer/Word2007/Style/Frame.php
index 9c6ddaef..da5aee1e 100644
--- a/src/PhpWord/Writer/Word2007/Style/Frame.php
+++ b/src/PhpWord/Writer/Word2007/Style/Frame.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -30,8 +30,6 @@ class Frame extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
@@ -62,7 +60,7 @@ class Frame extends AbstractStyle
$styles = array_merge($sizeStyles, $posStyles);
- // zIndex for infront & behind wrap
+ // zIndex for infront & behind wrap
$wrap = $style->getWrap();
if ($wrap !== null && isset($zIndices[$wrap])) {
$styles['z-index'] = $zIndices[$wrap];
@@ -77,8 +75,6 @@ class Frame extends AbstractStyle
/**
* Write alignment.
- *
- * @return void
*/
public function writeAlignment()
{
@@ -108,7 +104,6 @@ class Frame extends AbstractStyle
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Frame $style
* @param string $wrap
- * @return void
*/
private function writeWrap(XMLWriter $xmlWriter, FrameStyle $style, $wrap)
{
@@ -129,8 +124,8 @@ class Frame extends AbstractStyle
$vPos = $style->getVPosRelTo();
if ($pos == FrameStyle::POS_ABSOLUTE) {
- $xmlWriter->writeAttribute('anchorx', "page");
- $xmlWriter->writeAttribute('anchory', "page");
+ $xmlWriter->writeAttribute('anchorx', 'page');
+ $xmlWriter->writeAttribute('anchory', 'page');
} elseif ($pos == FrameStyle::POS_RELATIVE) {
if (isset($relativePositions[$hPos])) {
$xmlWriter->writeAttribute('anchorx', $relativePositions[$hPos]);
diff --git a/src/PhpWord/Writer/Word2007/Style/Image.php b/src/PhpWord/Writer/Word2007/Style/Image.php
index 3bbe751e..271b99df 100644
--- a/src/PhpWord/Writer/Word2007/Style/Image.php
+++ b/src/PhpWord/Writer/Word2007/Style/Image.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/src/PhpWord/Writer/Word2007/Style/Indentation.php b/src/PhpWord/Writer/Word2007/Style/Indentation.php
index a7edaee1..c5a598ff 100644
--- a/src/PhpWord/Writer/Word2007/Style/Indentation.php
+++ b/src/PhpWord/Writer/Word2007/Style/Indentation.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Indentation extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Style/Line.php b/src/PhpWord/Writer/Word2007/Style/Line.php
index 3407c252..f065e521 100644
--- a/src/PhpWord/Writer/Word2007/Style/Line.php
+++ b/src/PhpWord/Writer/Word2007/Style/Line.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -21,14 +21,11 @@ use PhpOffice\PhpWord\Style\Line as LineStyle;
/**
* Line style writer
- *
*/
class Line extends Frame
{
/**
* Write Line stroke.
- *
- * @return void
* @todo Merge with `Stroke` style
*/
public function writeStroke()
diff --git a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php
index 592fb7bb..3ed577c6 100644
--- a/src/PhpWord/Writer/Word2007/Style/LineNumbering.php
+++ b/src/PhpWord/Writer/Word2007/Style/LineNumbering.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,9 +26,6 @@ class LineNumbering extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
- *
* The w:start seems to be zero based so we have to decrement by one
*/
public function write()
diff --git a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php
index 68ba70d2..3d877384 100644
--- a/src/PhpWord/Writer/Word2007/Style/MarginBorder.php
+++ b/src/PhpWord/Writer/Word2007/Style/MarginBorder.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -29,7 +29,7 @@ class MarginBorder extends AbstractStyle
/**
* Sizes
*
- * @var integer[]
+ * @var int[]
*/
private $sizes = array();
@@ -49,8 +49,6 @@ class MarginBorder extends AbstractStyle
/**
* Write style.
- *
- * @return void
*/
public function write()
{
@@ -76,7 +74,6 @@ class MarginBorder extends AbstractStyle
* @param string $side
* @param int $width
* @param string $color
- * @return void
*/
private function writeSide(XMLWriter $xmlWriter, $side, $width, $color = null)
{
@@ -105,8 +102,7 @@ class MarginBorder extends AbstractStyle
/**
* Set sizes.
*
- * @param integer[] $value
- * @return void
+ * @param int[] $value
*/
public function setSizes($value)
{
@@ -117,7 +113,6 @@ class MarginBorder extends AbstractStyle
* Set colors.
*
* @param string[] $value
- * @return void
*/
public function setColors($value)
{
@@ -128,7 +123,6 @@ class MarginBorder extends AbstractStyle
* Set attributes.
*
* @param array $value
- * @return void
*/
public function setAttributes($value)
{
diff --git a/src/PhpWord/Writer/Word2007/Style/Outline.php b/src/PhpWord/Writer/Word2007/Style/Outline.php
index 620720b3..9ae61f39 100644
--- a/src/PhpWord/Writer/Word2007/Style/Outline.php
+++ b/src/PhpWord/Writer/Word2007/Style/Outline.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Outline extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
@@ -37,7 +35,7 @@ class Outline extends AbstractStyle
}
$xmlWriter = $this->getXmlWriter();
- $xmlWriter->startElement("v:stroke");
+ $xmlWriter->startElement('v:stroke');
$xmlWriter->writeAttribute('on', 't');
$xmlWriter->writeAttributeIf($style->getColor() !== null, 'color', $style->getColor());
$xmlWriter->writeAttributeIf($style->getWeight() !== null, 'weight', $style->getWeight() . $style->getUnit());
diff --git a/src/PhpWord/Writer/Word2007/Style/Paragraph.php b/src/PhpWord/Writer/Word2007/Style/Paragraph.php
index 32f8abba..707bf031 100644
--- a/src/PhpWord/Writer/Word2007/Style/Paragraph.php
+++ b/src/PhpWord/Writer/Word2007/Style/Paragraph.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -45,8 +45,6 @@ class Paragraph extends AbstractStyle
/**
* Write style.
- *
- * @return void
*/
public function write()
{
@@ -70,8 +68,6 @@ class Paragraph extends AbstractStyle
/**
* Write full style.
- *
- * @return void
*/
private function writeStyle()
{
@@ -146,12 +142,11 @@ class Paragraph extends AbstractStyle
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Tab[] $tabs
- * @return void
*/
private function writeTabs(XMLWriter $xmlWriter, $tabs)
{
if (!empty($tabs)) {
- $xmlWriter->startElement("w:tabs");
+ $xmlWriter->startElement('w:tabs');
foreach ($tabs as $tab) {
$styleWriter = new Tab($xmlWriter, $tab);
$styleWriter->write();
@@ -165,7 +160,6 @@ class Paragraph extends AbstractStyle
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param array $numbering
- * @return void
*/
private function writeNumbering(XMLWriter $xmlWriter, $numbering)
{
@@ -194,7 +188,6 @@ class Paragraph extends AbstractStyle
* Set without w:pPr.
*
* @param bool $value
- * @return void
*/
public function setWithoutPPR($value)
{
@@ -205,7 +198,6 @@ class Paragraph extends AbstractStyle
* Set is inline.
*
* @param bool $value
- * @return void
*/
public function setIsInline($value)
{
diff --git a/src/PhpWord/Writer/Word2007/Style/Row.php b/src/PhpWord/Writer/Word2007/Style/Row.php
index e8b7e1a5..f57094db 100644
--- a/src/PhpWord/Writer/Word2007/Style/Row.php
+++ b/src/PhpWord/Writer/Word2007/Style/Row.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -31,8 +31,6 @@ class Row extends AbstractStyle
/**
* Write style.
- *
- * @return void
*/
public function write()
{
@@ -60,7 +58,6 @@ class Row extends AbstractStyle
* Set height.
*
* @param int $value
- * @return void
*/
public function setHeight($value = null)
{
diff --git a/src/PhpWord/Writer/Word2007/Style/Section.php b/src/PhpWord/Writer/Word2007/Style/Section.php
index 60b5d869..ef50c111 100644
--- a/src/PhpWord/Writer/Word2007/Style/Section.php
+++ b/src/PhpWord/Writer/Word2007/Style/Section.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,8 +28,6 @@ class Section extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Style/Shading.php b/src/PhpWord/Writer/Word2007/Style/Shading.php
index c3594b24..a8e6592a 100644
--- a/src/PhpWord/Writer/Word2007/Style/Shading.php
+++ b/src/PhpWord/Writer/Word2007/Style/Shading.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Shading extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Style/Shadow.php b/src/PhpWord/Writer/Word2007/Style/Shadow.php
index 239c161d..5efc38c4 100644
--- a/src/PhpWord/Writer/Word2007/Style/Shadow.php
+++ b/src/PhpWord/Writer/Word2007/Style/Shadow.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Shadow extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
@@ -37,7 +35,7 @@ class Shadow extends AbstractStyle
}
$xmlWriter = $this->getXmlWriter();
- $xmlWriter->startElement("v:shadow");
+ $xmlWriter->startElement('v:shadow');
$xmlWriter->writeAttribute('on', 't');
$xmlWriter->writeAttributeIf($style->getColor() !== null, 'color', $style->getColor());
$xmlWriter->writeAttributeIf($style->getOffset() !== null, 'offset', $style->getOffset());
diff --git a/src/PhpWord/Writer/Word2007/Style/Shape.php b/src/PhpWord/Writer/Word2007/Style/Shape.php
index 4ed1469d..aad42ae7 100644
--- a/src/PhpWord/Writer/Word2007/Style/Shape.php
+++ b/src/PhpWord/Writer/Word2007/Style/Shape.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Shape extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Style/Spacing.php b/src/PhpWord/Writer/Word2007/Style/Spacing.php
index bd2d06aa..8db78161 100644
--- a/src/PhpWord/Writer/Word2007/Style/Spacing.php
+++ b/src/PhpWord/Writer/Word2007/Style/Spacing.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Spacing extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
diff --git a/src/PhpWord/Writer/Word2007/Style/Tab.php b/src/PhpWord/Writer/Word2007/Style/Tab.php
index 9867023f..7b0a0ab5 100644
--- a/src/PhpWord/Writer/Word2007/Style/Tab.php
+++ b/src/PhpWord/Writer/Word2007/Style/Tab.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,8 +26,6 @@ class Tab extends AbstractStyle
{
/**
* Write style.
- *
- * @return void
*/
public function write()
{
@@ -37,9 +35,9 @@ class Tab extends AbstractStyle
}
$xmlWriter = $this->getXmlWriter();
- $xmlWriter->startElement("w:tab");
- $xmlWriter->writeAttribute("w:val", $style->getType());
- $xmlWriter->writeAttribute("w:leader", $style->getLeader());
+ $xmlWriter->startElement('w:tab');
+ $xmlWriter->writeAttribute('w:val', $style->getType());
+ $xmlWriter->writeAttribute('w:leader', $style->getLeader());
$xmlWriter->writeAttribute('w:pos', $this->convertTwip($style->getPosition()));
$xmlWriter->endElement();
}
diff --git a/src/PhpWord/Writer/Word2007/Style/Table.php b/src/PhpWord/Writer/Word2007/Style/Table.php
index 570e85bb..620e4fbf 100644
--- a/src/PhpWord/Writer/Word2007/Style/Table.php
+++ b/src/PhpWord/Writer/Word2007/Style/Table.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -35,8 +35,6 @@ class Table extends AbstractStyle
/**
* Write style.
- *
- * @return void
*/
public function write()
{
@@ -62,7 +60,6 @@ class Table extends AbstractStyle
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Table $style
- * @return void
*/
private function writeStyle(XMLWriter $xmlWriter, TableStyle $style)
{
@@ -100,7 +97,6 @@ class Table extends AbstractStyle
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param int $width
* @param string $unit
- * @return void
*/
private function writeWidth(XMLWriter $xmlWriter, $width, $unit)
{
@@ -115,7 +111,6 @@ class Table extends AbstractStyle
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Table $style
- * @return void
*/
private function writeMargin(XMLWriter $xmlWriter, TableStyle $style)
{
@@ -135,7 +130,6 @@ class Table extends AbstractStyle
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Table $style
- * @return void
*/
private function writeBorder(XMLWriter $xmlWriter, TableStyle $style)
{
@@ -156,7 +150,6 @@ class Table extends AbstractStyle
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Table $style
- * @return void
*/
private function writeFirstRow(XMLWriter $xmlWriter, TableStyle $style)
{
@@ -176,7 +169,6 @@ class Table extends AbstractStyle
*
* @param \PhpOffice\Common\XMLWriter $xmlWriter
* @param \PhpOffice\PhpWord\Style\Table $style
- * @return void
*/
private function writeShading(XMLWriter $xmlWriter, TableStyle $style)
{
@@ -194,7 +186,6 @@ class Table extends AbstractStyle
* Set width.
*
* @param int $value
- * @return void
*/
public function setWidth($value = null)
{
diff --git a/src/PhpWord/Writer/Word2007/Style/TextBox.php b/src/PhpWord/Writer/Word2007/Style/TextBox.php
index f8f94da3..cd92f845 100644
--- a/src/PhpWord/Writer/Word2007/Style/TextBox.php
+++ b/src/PhpWord/Writer/Word2007/Style/TextBox.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -28,8 +28,6 @@ class TextBox extends Frame
{
/**
* Writer inner margin.
- *
- * @return void
*/
public function writeInnerMargin()
{
@@ -46,8 +44,6 @@ class TextBox extends Frame
/**
* Writer border.
- *
- * @return void
*/
public function writeBorder()
{
diff --git a/src/PhpWord/Writer/WriterInterface.php b/src/PhpWord/Writer/WriterInterface.php
index 1ccdf321..b5f08199 100644
--- a/src/PhpWord/Writer/WriterInterface.php
+++ b/src/PhpWord/Writer/WriterInterface.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Collection/CollectionTest.php b/tests/PhpWord/Collection/CollectionTest.php
index 4b2fa0ca..22f89b72 100644
--- a/tests/PhpWord/Collection/CollectionTest.php
+++ b/tests/PhpWord/Collection/CollectionTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/ComplexType/FootnotePropertiesTest.php b/tests/PhpWord/ComplexType/FootnotePropertiesTest.php
index aa46d89b..55e22e6f 100644
--- a/tests/PhpWord/ComplexType/FootnotePropertiesTest.php
+++ b/tests/PhpWord/ComplexType/FootnotePropertiesTest.php
@@ -10,14 +10,13 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWord\ComplexType;
-use PhpOffice\PhpWord\ComplexType\FootnoteProperties;
use PhpOffice\PhpWord\SimpleType\NumberFormat;
/**
@@ -52,7 +51,7 @@ class FootnotePropertiesTest extends \PHPUnit_Framework_TestCase
*/
public function testWrongPos()
{
- $footnoteProp= new FootnoteProperties();
+ $footnoteProp = new FootnoteProperties();
$footnoteProp->setPos(NumberFormat::LOWER_ROMAN);
}
@@ -63,7 +62,7 @@ class FootnotePropertiesTest extends \PHPUnit_Framework_TestCase
*/
public function testWrongNumFmt()
{
- $footnoteProp= new FootnoteProperties();
+ $footnoteProp = new FootnoteProperties();
$footnoteProp->setNumFmt(FootnoteProperties::POSITION_DOC_END);
}
@@ -74,7 +73,7 @@ class FootnotePropertiesTest extends \PHPUnit_Framework_TestCase
*/
public function testWrongNumRestart()
{
- $footnoteProp= new FootnoteProperties();
+ $footnoteProp = new FootnoteProperties();
$footnoteProp->setNumRestart(NumberFormat::LOWER_ROMAN);
}
}
diff --git a/tests/PhpWord/ComplexType/ProofStateTest.php b/tests/PhpWord/ComplexType/ProofStateTest.php
index 0b7e74ca..e807ca2f 100644
--- a/tests/PhpWord/ComplexType/ProofStateTest.php
+++ b/tests/PhpWord/ComplexType/ProofStateTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\ComplexType;
/**
@@ -23,13 +24,12 @@ namespace PhpOffice\PhpWord\ComplexType;
*/
class ProofStateTest extends \PHPUnit_Framework_TestCase
{
-
/**
* Tests the getters and setters
*/
public function testGetSet()
{
- $pState= new ProofState();
+ $pState = new ProofState();
$pState->setGrammar(ProofState::CLEAN);
$pState->setSpelling(ProofState::DIRTY);
@@ -55,7 +55,7 @@ class ProofStateTest extends \PHPUnit_Framework_TestCase
*/
public function testWrongSpelling()
{
- $pState= new ProofState();
+ $pState = new ProofState();
$pState->setSpelling('Wrong');
}
}
diff --git a/tests/PhpWord/Element/AbstractElementTest.php b/tests/PhpWord/Element/AbstractElementTest.php
index 83f209e4..458b94c8 100644
--- a/tests/PhpWord/Element/AbstractElementTest.php
+++ b/tests/PhpWord/Element/AbstractElementTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/BookmarkTest.php b/tests/PhpWord/Element/BookmarkTest.php
new file mode 100644
index 00000000..da86a62e
--- /dev/null
+++ b/tests/PhpWord/Element/BookmarkTest.php
@@ -0,0 +1,38 @@
+assertInstanceOf('PhpOffice\\PhpWord\\Element\\Bookmark', $oBookmark);
+ $this->assertEquals($bookmarkName, $oBookmark->getName());
+ }
+}
diff --git a/tests/PhpWord/Element/CellTest.php b/tests/PhpWord/Element/CellTest.php
index f1d6a280..aff208c4 100644
--- a/tests/PhpWord/Element/CellTest.php
+++ b/tests/PhpWord/Element/CellTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/CheckBoxTest.php b/tests/PhpWord/Element/CheckBoxTest.php
index 183d22db..fb71b8c2 100644
--- a/tests/PhpWord/Element/CheckBoxTest.php
+++ b/tests/PhpWord/Element/CheckBoxTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/CommentTest.php b/tests/PhpWord/Element/CommentTest.php
index db9ec902..fd2c814d 100644
--- a/tests/PhpWord/Element/CommentTest.php
+++ b/tests/PhpWord/Element/CommentTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -80,4 +80,24 @@ class CommentTest extends \PHPUnit_Framework_TestCase
$oComment->setRelationId($iVal);
$this->assertEquals($iVal, $oComment->getRelationId());
}
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testExceptionOnCommentStartOnComment()
+ {
+ $dummyComment = new Comment('Test User', new \DateTime(), 'my_initials');
+ $oComment = new Comment('Test User', new \DateTime(), 'my_initials');
+ $oComment->setCommentRangeStart($dummyComment);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testExceptionOnCommentEndOnComment()
+ {
+ $dummyComment = new Comment('Test User', new \DateTime(), 'my_initials');
+ $oComment = new Comment('Test User', new \DateTime(), 'my_initials');
+ $oComment->setCommentRangeEnd($dummyComment);
+ }
}
diff --git a/tests/PhpWord/Element/FieldTest.php b/tests/PhpWord/Element/FieldTest.php
index 6f5ebbbf..1bd0c216 100644
--- a/tests/PhpWord/Element/FieldTest.php
+++ b/tests/PhpWord/Element/FieldTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/FooterTest.php b/tests/PhpWord/Element/FooterTest.php
index 33a211d3..2938ae5e 100644
--- a/tests/PhpWord/Element/FooterTest.php
+++ b/tests/PhpWord/Element/FooterTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/FootnoteTest.php b/tests/PhpWord/Element/FootnoteTest.php
index a3f3b4d8..b02ab5c6 100644
--- a/tests/PhpWord/Element/FootnoteTest.php
+++ b/tests/PhpWord/Element/FootnoteTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/HeaderTest.php b/tests/PhpWord/Element/HeaderTest.php
index f75910aa..13ace285 100644
--- a/tests/PhpWord/Element/HeaderTest.php
+++ b/tests/PhpWord/Element/HeaderTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -228,7 +228,7 @@ class HeaderTest extends \PHPUnit_Framework_TestCase
/**
* Add footnote exception
*
- * @expectedException BadMethodCallException
+ * @expectedException \BadMethodCallException
*/
public function testAddFootnoteException()
{
diff --git a/tests/PhpWord/Element/ImageTest.php b/tests/PhpWord/Element/ImageTest.php
index 974e868c..80e0bcfc 100644
--- a/tests/PhpWord/Element/ImageTest.php
+++ b/tests/PhpWord/Element/ImageTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -133,9 +133,9 @@ class ImageTest extends \PHPUnit_Framework_TestCase
{
//disable ssl verification, never do this in real application, you should pass the certiciate instead!!!
$arrContextOptions = array(
- "ssl" => array(
- "verify_peer" => false,
- "verify_peer_name" => false,
+ 'ssl' => array(
+ 'verify_peer' => false,
+ 'verify_peer_name' => false,
),
);
stream_context_set_default($arrContextOptions);
diff --git a/tests/PhpWord/Element/LineTest.php b/tests/PhpWord/Element/LineTest.php
index a7b15b08..a6e3f79b 100644
--- a/tests/PhpWord/Element/LineTest.php
+++ b/tests/PhpWord/Element/LineTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/LinkTest.php b/tests/PhpWord/Element/LinkTest.php
index 40f07a1f..48b576c3 100644
--- a/tests/PhpWord/Element/LinkTest.php
+++ b/tests/PhpWord/Element/LinkTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -49,7 +49,7 @@ class LinkTest extends \PHPUnit_Framework_TestCase
$oLink = new Link(
'https://github.com/PHPOffice/PHPWord',
'PHPWord on GitHub',
- array('color' => '0000FF', 'underline' => Font::UNDERLINE_SINGLE),
+ array('color' => '0000FF', 'underline' => Font::UNDERLINE_SINGLE),
array('marginLeft' => 600, 'marginRight' => 600, 'marginTop' => 600, 'marginBottom' => 600)
);
diff --git a/tests/PhpWord/Element/ListItemRunTest.php b/tests/PhpWord/Element/ListItemRunTest.php
index 91609357..0c4c1ac9 100644
--- a/tests/PhpWord/Element/ListItemRunTest.php
+++ b/tests/PhpWord/Element/ListItemRunTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/ListItemTest.php b/tests/PhpWord/Element/ListItemTest.php
index 2dc4f65c..775a97d4 100644
--- a/tests/PhpWord/Element/ListItemTest.php
+++ b/tests/PhpWord/Element/ListItemTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/ObjectTest.php b/tests/PhpWord/Element/ObjectTest.php
index 44516b61..51ed19b5 100644
--- a/tests/PhpWord/Element/ObjectTest.php
+++ b/tests/PhpWord/Element/ObjectTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -26,9 +26,22 @@ namespace PhpOffice\PhpWord\Element;
class ObjectTest extends \PHPUnit_Framework_TestCase
{
/**
- * Create new instance with supported files
+ * Create new instance with supported files, 4 character extention
*/
public function testConstructWithSupportedFiles()
+ {
+ $src = __DIR__ . '/../_files/documents/reader.docx';
+ $oObject = new Object($src);
+
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Element\\Object', $oObject);
+ $this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Image', $oObject->getStyle());
+ $this->assertEquals($src, $oObject->getSource());
+ }
+
+ /**
+ * Create new instance with supported files
+ */
+ public function testConstructWithSupportedFilesLong()
{
$src = __DIR__ . '/../_files/documents/sheet.xls';
$oObject = new Object($src);
diff --git a/tests/PhpWord/Element/PageBreakTest.php b/tests/PhpWord/Element/PageBreakTest.php
index 3d8b1db6..69a71204 100644
--- a/tests/PhpWord/Element/PageBreakTest.php
+++ b/tests/PhpWord/Element/PageBreakTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/PreserveTextTest.php b/tests/PhpWord/Element/PreserveTextTest.php
index 33e2272a..a47cc77c 100644
--- a/tests/PhpWord/Element/PreserveTextTest.php
+++ b/tests/PhpWord/Element/PreserveTextTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/RowTest.php b/tests/PhpWord/Element/RowTest.php
index 58a166f4..cb365dad 100644
--- a/tests/PhpWord/Element/RowTest.php
+++ b/tests/PhpWord/Element/RowTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/SDTTest.php b/tests/PhpWord/Element/SDTTest.php
index 52705bc1..fc3682b6 100644
--- a/tests/PhpWord/Element/SDTTest.php
+++ b/tests/PhpWord/Element/SDTTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/SectionTest.php b/tests/PhpWord/Element/SectionTest.php
index 78010bc9..aebfc9b7 100644
--- a/tests/PhpWord/Element/SectionTest.php
+++ b/tests/PhpWord/Element/SectionTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -129,6 +129,17 @@ class SectionTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($object->hasDifferentFirstPage());
}
+ /**
+ * @covers ::addHeader
+ * @covers ::hasDifferentFirstPage
+ */
+ public function testHasDifferentFirstPageFooter()
+ {
+ $object = new Section(1);
+ $object->addFooter(Header::FIRST);
+ $this->assertTrue($object->hasDifferentFirstPage());
+ }
+
/**
* @covers ::addHeader
* @covers ::hasDifferentFirstPage
diff --git a/tests/PhpWord/Element/TOCTest.php b/tests/PhpWord/Element/TOCTest.php
index 6b5867bc..655d567c 100644
--- a/tests/PhpWord/Element/TOCTest.php
+++ b/tests/PhpWord/Element/TOCTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/TableTest.php b/tests/PhpWord/Element/TableTest.php
index 785ec40a..3085aee2 100644
--- a/tests/PhpWord/Element/TableTest.php
+++ b/tests/PhpWord/Element/TableTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/TextBoxTest.php b/tests/PhpWord/Element/TextBoxTest.php
index cb3fdb99..cc61e20d 100644
--- a/tests/PhpWord/Element/TextBoxTest.php
+++ b/tests/PhpWord/Element/TextBoxTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/TextBreakTest.php b/tests/PhpWord/Element/TextBreakTest.php
index 40ed6965..62186244 100644
--- a/tests/PhpWord/Element/TextBreakTest.php
+++ b/tests/PhpWord/Element/TextBreakTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/TextRunTest.php b/tests/PhpWord/Element/TextRunTest.php
index efd8d6f3..59db597c 100644
--- a/tests/PhpWord/Element/TextRunTest.php
+++ b/tests/PhpWord/Element/TextRunTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/TextTest.php b/tests/PhpWord/Element/TextTest.php
index d2fe0472..9723a2e1 100644
--- a/tests/PhpWord/Element/TextTest.php
+++ b/tests/PhpWord/Element/TextTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Element/TitleTest.php b/tests/PhpWord/Element/TitleTest.php
index 2b886e5e..500de133 100644
--- a/tests/PhpWord/Element/TitleTest.php
+++ b/tests/PhpWord/Element/TitleTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Exception/CopyFileExceptionTest.php b/tests/PhpWord/Exception/CopyFileExceptionTest.php
index 0bc2e322..9d921740 100644
--- a/tests/PhpWord/Exception/CopyFileExceptionTest.php
+++ b/tests/PhpWord/Exception/CopyFileExceptionTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Exception/CreateTemporaryFileExceptionTest.php b/tests/PhpWord/Exception/CreateTemporaryFileExceptionTest.php
index d68bf573..91c7012f 100644
--- a/tests/PhpWord/Exception/CreateTemporaryFileExceptionTest.php
+++ b/tests/PhpWord/Exception/CreateTemporaryFileExceptionTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Exception/ExceptionTest.php b/tests/PhpWord/Exception/ExceptionTest.php
index 4c14abb9..28b15702 100644
--- a/tests/PhpWord/Exception/ExceptionTest.php
+++ b/tests/PhpWord/Exception/ExceptionTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,6 +33,6 @@ class ExceptionTest extends \PHPUnit_Framework_TestCase
*/
public function testThrowException()
{
- throw new Exception;
+ throw new Exception();
}
}
diff --git a/tests/PhpWord/Exception/InvalidImageExceptionTest.php b/tests/PhpWord/Exception/InvalidImageExceptionTest.php
index d83aa878..dfaadbd7 100644
--- a/tests/PhpWord/Exception/InvalidImageExceptionTest.php
+++ b/tests/PhpWord/Exception/InvalidImageExceptionTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,6 +33,6 @@ class InvalidImageExceptionTest extends \PHPUnit_Framework_TestCase
*/
public function testThrowException()
{
- throw new InvalidImageException;
+ throw new InvalidImageException();
}
}
diff --git a/tests/PhpWord/Exception/InvalidStyleExceptionTest.php b/tests/PhpWord/Exception/InvalidStyleExceptionTest.php
index 5038ed2f..77ee8571 100644
--- a/tests/PhpWord/Exception/InvalidStyleExceptionTest.php
+++ b/tests/PhpWord/Exception/InvalidStyleExceptionTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,6 +33,6 @@ class InvalidStyleExceptionTest extends \PHPUnit_Framework_TestCase
*/
public function testThrowException()
{
- throw new InvalidStyleException;
+ throw new InvalidStyleException();
}
}
diff --git a/tests/PhpWord/Exception/UnsupportedImageTypeExceptionTest.php b/tests/PhpWord/Exception/UnsupportedImageTypeExceptionTest.php
index 251ed957..50b4806d 100644
--- a/tests/PhpWord/Exception/UnsupportedImageTypeExceptionTest.php
+++ b/tests/PhpWord/Exception/UnsupportedImageTypeExceptionTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -33,6 +33,6 @@ class UnsupportedImageTypeExceptionTest extends \PHPUnit_Framework_TestCase
*/
public function testThrowException()
{
- throw new UnsupportedImageTypeException;
+ throw new UnsupportedImageTypeException();
}
}
diff --git a/tests/PhpWord/IOFactoryTest.php b/tests/PhpWord/IOFactoryTest.php
index 9c2d1e67..6dbb006e 100644
--- a/tests/PhpWord/IOFactoryTest.php
+++ b/tests/PhpWord/IOFactoryTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/MediaTest.php b/tests/PhpWord/MediaTest.php
index 25480313..d045abcd 100644
--- a/tests/PhpWord/MediaTest.php
+++ b/tests/PhpWord/MediaTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -106,7 +106,7 @@ class MediaTest extends \PHPUnit_Framework_TestCase
/**
* Add image element exception
*
- * @expectedException Exception
+ * @expectedException \Exception
* @expectedExceptionMessage Image object not assigned.
*/
public function testAddElementImageException()
diff --git a/tests/PhpWord/Metadata/DocInfoTest.php b/tests/PhpWord/Metadata/DocInfoTest.php
index 23572710..5443f0b2 100644
--- a/tests/PhpWord/Metadata/DocInfoTest.php
+++ b/tests/PhpWord/Metadata/DocInfoTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Metadata/SettingsTest.php b/tests/PhpWord/Metadata/SettingsTest.php
index fff51652..6f493d04 100644
--- a/tests/PhpWord/Metadata/SettingsTest.php
+++ b/tests/PhpWord/Metadata/SettingsTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -34,7 +34,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
{
$oSettings = new Settings();
$oSettings->setEvenAndOddHeaders(true);
- $this->assertEquals(true, $oSettings->hasEvenAndOddHeaders());
+ $this->assertTrue($oSettings->hasEvenAndOddHeaders());
}
/**
@@ -44,7 +44,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
{
$oSettings = new Settings();
$oSettings->setHideGrammaticalErrors(true);
- $this->assertEquals(true, $oSettings->hasHideGrammaticalErrors());
+ $this->assertTrue($oSettings->hasHideGrammaticalErrors());
}
/**
@@ -54,7 +54,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
{
$oSettings = new Settings();
$oSettings->setHideSpellingErrors(true);
- $this->assertEquals(true, $oSettings->hasHideSpellingErrors());
+ $this->assertTrue($oSettings->hasHideSpellingErrors());
}
/**
@@ -77,7 +77,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
{
$oSettings = new Settings();
$oSettings->setTrackRevisions(true);
- $this->assertEquals(true, $oSettings->hasTrackRevisions());
+ $this->assertTrue($oSettings->hasTrackRevisions());
}
/**
@@ -87,7 +87,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
{
$oSettings = new Settings();
$oSettings->setDoNotTrackFormatting(true);
- $this->assertEquals(true, $oSettings->hasDoNotTrackFormatting());
+ $this->assertTrue($oSettings->hasDoNotTrackFormatting());
}
/**
@@ -97,7 +97,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
{
$oSettings = new Settings();
$oSettings->setDoNotTrackMoves(true);
- $this->assertEquals(true, $oSettings->hasDoNotTrackMoves());
+ $this->assertTrue($oSettings->hasDoNotTrackMoves());
}
/**
@@ -116,6 +116,24 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(ProofState::DIRTY, $oSettings->getProofState()->getSpelling());
}
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testWrongProofStateGrammar()
+ {
+ $proofState = new ProofState();
+ $proofState->setGrammar('wrong');
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testWrongProofStateSpelling()
+ {
+ $proofState = new ProofState();
+ $proofState->setSpelling('wrong');
+ }
+
/**
* Zoom as percentage
*/
diff --git a/tests/PhpWord/PhpWordTest.php b/tests/PhpWord/PhpWordTest.php
index b49666f5..01d7342e 100644
--- a/tests/PhpWord/PhpWordTest.php
+++ b/tests/PhpWord/PhpWordTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -138,7 +138,7 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
*/
public function testLoadTemplateException()
{
- $templateFqfn = join(
+ $templateFqfn = implode(
DIRECTORY_SEPARATOR,
array(PHPWORD_TESTS_BASE_DIR, 'PhpWord', 'Tests', '_files', 'templates', 'blanks.docx')
);
@@ -151,6 +151,8 @@ class PhpWordTest extends \PHPUnit_Framework_TestCase
*/
public function testSave()
{
+ $this->setOutputCallback(function () {
+ });
$phpWord = new PhpWord();
$section = $phpWord->addSection();
$section->addText('Hello world!');
diff --git a/tests/PhpWord/Reader/HTMLTest.php b/tests/PhpWord/Reader/HTMLTest.php
index 6e3039cf..24751cac 100644
--- a/tests/PhpWord/Reader/HTMLTest.php
+++ b/tests/PhpWord/Reader/HTMLTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Reader/MsDocTest.php b/tests/PhpWord/Reader/MsDocTest.php
index b4173d17..ed16e64b 100644
--- a/tests/PhpWord/Reader/MsDocTest.php
+++ b/tests/PhpWord/Reader/MsDocTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Reader/ODTextTest.php b/tests/PhpWord/Reader/ODTextTest.php
index 1bdce2e6..d00657de 100644
--- a/tests/PhpWord/Reader/ODTextTest.php
+++ b/tests/PhpWord/Reader/ODTextTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Reader/RTFTest.php b/tests/PhpWord/Reader/RTFTest.php
index 79cf13a7..58154ee3 100644
--- a/tests/PhpWord/Reader/RTFTest.php
+++ b/tests/PhpWord/Reader/RTFTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Reader/Word2007Test.php b/tests/PhpWord/Reader/Word2007Test.php
index 9be78a5b..627bc66e 100644
--- a/tests/PhpWord/Reader/Word2007Test.php
+++ b/tests/PhpWord/Reader/Word2007Test.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/SettingsTest.php b/tests/PhpWord/SettingsTest.php
index f5ac3ed6..6fd2f52b 100644
--- a/tests/PhpWord/SettingsTest.php
+++ b/tests/PhpWord/SettingsTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -78,7 +78,6 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(sys_get_temp_dir(), Settings::getTempDir());
}
-
/**
* @covers ::setTempDir
* @covers ::getTempDir
diff --git a/tests/PhpWord/Shared/ConverterTest.php b/tests/PhpWord/Shared/ConverterTest.php
index e307f09b..a2031787 100644
--- a/tests/PhpWord/Shared/ConverterTest.php
+++ b/tests/PhpWord/Shared/ConverterTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -89,7 +89,7 @@ class ConverterTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(round($value / 9525), $result);
$result = Converter::degreeToAngle($value);
- $this->assertEquals((int)round($value * 60000), $result);
+ $this->assertEquals((int) round($value * 60000), $result);
$result = Converter::angleToDegree($value);
$this->assertEquals(round($value / 60000), $result);
diff --git a/tests/PhpWord/Shared/HtmlTest.php b/tests/PhpWord/Shared/HtmlTest.php
index c651fd4a..602b644d 100644
--- a/tests/PhpWord/Shared/HtmlTest.php
+++ b/tests/PhpWord/Shared/HtmlTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Shared/ZipArchiveTest.php b/tests/PhpWord/Shared/ZipArchiveTest.php
index 1adcfbfc..689f122b 100644
--- a/tests/PhpWord/Shared/ZipArchiveTest.php
+++ b/tests/PhpWord/Shared/ZipArchiveTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -27,7 +27,6 @@ use PhpOffice\PhpWord\Settings;
*/
class ZipArchiveTest extends \PHPUnit_Framework_TestCase
{
-
/**
* Test close method exception: Working in local, not working in Travis
*
diff --git a/tests/PhpWord/Style/AbstractStyleTest.php b/tests/PhpWord/Style/AbstractStyleTest.php
index f7c6f6c5..ab3ea14e 100644
--- a/tests/PhpWord/Style/AbstractStyleTest.php
+++ b/tests/PhpWord/Style/AbstractStyleTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -87,6 +87,7 @@ class AbstractStyleTest extends \PHPUnit_Framework_TestCase
$class = new \ReflectionClass(get_class($object));
$method = $class->getMethod($method);
$method->setAccessible(true);
+
return $method->invokeArgs($object, $args);
}
}
diff --git a/tests/PhpWord/Style/CellTest.php b/tests/PhpWord/Style/CellTest.php
index 51f4e895..71b32a65 100644
--- a/tests/PhpWord/Style/CellTest.php
+++ b/tests/PhpWord/Style/CellTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/FontTest.php b/tests/PhpWord/Style/FontTest.php
index c8fd4dab..707784f6 100644
--- a/tests/PhpWord/Style/FontTest.php
+++ b/tests/PhpWord/Style/FontTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -45,7 +45,7 @@ class FontTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('text', $object->getStyleType());
$this->assertInstanceOf('PhpOffice\\PhpWord\\Style\\Paragraph', $object->getParagraphStyle());
- $this->assertTrue(is_array($object->getStyleValues()));
+ $this->assertInternalType('array', $object->getStyleValues());
}
/**
diff --git a/tests/PhpWord/Style/ImageTest.php b/tests/PhpWord/Style/ImageTest.php
index c5bb5c7d..decc13b1 100644
--- a/tests/PhpWord/Style/ImageTest.php
+++ b/tests/PhpWord/Style/ImageTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/IndentationTest.php b/tests/PhpWord/Style/IndentationTest.php
index 477e1314..db079704 100644
--- a/tests/PhpWord/Style/IndentationTest.php
+++ b/tests/PhpWord/Style/IndentationTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/LanguageTest.php b/tests/PhpWord/Style/LanguageTest.php
index bd466956..35a01e07 100644
--- a/tests/PhpWord/Style/LanguageTest.php
+++ b/tests/PhpWord/Style/LanguageTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/LineNumberingTest.php b/tests/PhpWord/Style/LineNumberingTest.php
index e8ef1367..56440529 100644
--- a/tests/PhpWord/Style/LineNumberingTest.php
+++ b/tests/PhpWord/Style/LineNumberingTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/LineTest.php b/tests/PhpWord/Style/LineTest.php
index 98e20b3d..21489caf 100644
--- a/tests/PhpWord/Style/LineTest.php
+++ b/tests/PhpWord/Style/LineTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/ListItemTest.php b/tests/PhpWord/Style/ListItemTest.php
index 2e8692e9..a2e4eb74 100644
--- a/tests/PhpWord/Style/ListItemTest.php
+++ b/tests/PhpWord/Style/ListItemTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/NumberingLevelTest.php b/tests/PhpWord/Style/NumberingLevelTest.php
index c6cee11c..402d936b 100644
--- a/tests/PhpWord/Style/NumberingLevelTest.php
+++ b/tests/PhpWord/Style/NumberingLevelTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/NumberingTest.php b/tests/PhpWord/Style/NumberingTest.php
index ee9c032c..ad57ebff 100644
--- a/tests/PhpWord/Style/NumberingTest.php
+++ b/tests/PhpWord/Style/NumberingTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/PaperTest.php b/tests/PhpWord/Style/PaperTest.php
index 8e1dd960..7d12410c 100644
--- a/tests/PhpWord/Style/PaperTest.php
+++ b/tests/PhpWord/Style/PaperTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/ParagraphTest.php b/tests/PhpWord/Style/ParagraphTest.php
index b78c557a..a702d3f2 100644
--- a/tests/PhpWord/Style/ParagraphTest.php
+++ b/tests/PhpWord/Style/ParagraphTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -99,10 +99,11 @@ class ParagraphTest extends \PHPUnit_Framework_TestCase
if (is_bool($value)) {
if (method_exists($object, "is{$key}")) {
return "is{$key}";
- } else if (method_exists($object, "has{$key}")) {
+ } elseif (method_exists($object, "has{$key}")) {
return "has{$key}";
}
}
+
return "get{$key}";
}
diff --git a/tests/PhpWord/Style/RowTest.php b/tests/PhpWord/Style/RowTest.php
index a89f73d2..db98d0a9 100644
--- a/tests/PhpWord/Style/RowTest.php
+++ b/tests/PhpWord/Style/RowTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/SectionTest.php b/tests/PhpWord/Style/SectionTest.php
index d15dc490..89c4640a 100644
--- a/tests/PhpWord/Style/SectionTest.php
+++ b/tests/PhpWord/Style/SectionTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -23,7 +23,7 @@ namespace PhpOffice\PhpWord\Style;
* @coversDefaultClass \PhpOffice\PhpWord\Element\Section
* @runTestsInSeparateProcesses
*/
-class SettingsTest extends \PHPUnit_Framework_TestCase
+class SectionTest extends \PHPUnit_Framework_TestCase
{
/**
* Executed before each method of the class
diff --git a/tests/PhpWord/Style/ShadingTest.php b/tests/PhpWord/Style/ShadingTest.php
index d6378f8d..fd0aaf5e 100644
--- a/tests/PhpWord/Style/ShadingTest.php
+++ b/tests/PhpWord/Style/ShadingTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/SpacingTest.php b/tests/PhpWord/Style/SpacingTest.php
index 79c9e458..f147ae61 100644
--- a/tests/PhpWord/Style/SpacingTest.php
+++ b/tests/PhpWord/Style/SpacingTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/TOCTest.php b/tests/PhpWord/Style/TOCTest.php
index 03620c17..ec01acd9 100644
--- a/tests/PhpWord/Style/TOCTest.php
+++ b/tests/PhpWord/Style/TOCTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/TabTest.php b/tests/PhpWord/Style/TabTest.php
index 7724aa41..8102369d 100644
--- a/tests/PhpWord/Style/TabTest.php
+++ b/tests/PhpWord/Style/TabTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/TableTest.php b/tests/PhpWord/Style/TableTest.php
index 5e878692..ee020dd9 100644
--- a/tests/PhpWord/Style/TableTest.php
+++ b/tests/PhpWord/Style/TableTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/Style/TextBoxTest.php b/tests/PhpWord/Style/TextBoxTest.php
index ea7bc71f..a91b5b28 100644
--- a/tests/PhpWord/Style/TextBoxTest.php
+++ b/tests/PhpWord/Style/TextBoxTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -238,7 +238,6 @@ class TextBoxTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expected, $object->getPosVerticalRel());
}
-
/**
* Test set/get innerMarginRight
*/
diff --git a/tests/PhpWord/StyleTest.php b/tests/PhpWord/StyleTest.php
index 57ec98f4..aa46c6b1 100644
--- a/tests/PhpWord/StyleTest.php
+++ b/tests/PhpWord/StyleTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
diff --git a/tests/PhpWord/TemplateProcessorTest.php b/tests/PhpWord/TemplateProcessorTest.php
index 11b43cf4..4bf69f5a 100644
--- a/tests/PhpWord/TemplateProcessorTest.php
+++ b/tests/PhpWord/TemplateProcessorTest.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -36,7 +36,7 @@ final class TemplateProcessorTest extends \PHPUnit_Framework_TestCase
$templateProcessor = new TemplateProcessor($templateFqfn);
$xslDomDocument = new \DOMDocument();
- $xslDomDocument->load(__DIR__ . "/_files/xsl/remove_tables_by_needle.xsl");
+ $xslDomDocument->load(__DIR__ . '/_files/xsl/remove_tables_by_needle.xsl');
foreach (array('${employee.', '${scoreboard.', '${reference.') as $needle) {
$templateProcessor->applyXslStyleSheet($xslDomDocument, array('needle' => $needle));
}
diff --git a/tests/PhpWord/Writer/HTML/ElementTest.php b/tests/PhpWord/Writer/HTML/ElementTest.php
index 2a1e03dc..0778650e 100644
--- a/tests/PhpWord/Writer/HTML/ElementTest.php
+++ b/tests/PhpWord/Writer/HTML/ElementTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\HTML;
use PhpOffice\PhpWord\Element\Text as TextElement;
diff --git a/tests/PhpWord/Writer/HTML/PartTest.php b/tests/PhpWord/Writer/HTML/PartTest.php
index 137a092e..a4a6264e 100644
--- a/tests/PhpWord/Writer/HTML/PartTest.php
+++ b/tests/PhpWord/Writer/HTML/PartTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\HTML;
use PhpOffice\PhpWord\Writer\HTML\Part\Body;
diff --git a/tests/PhpWord/Writer/HTML/StyleTest.php b/tests/PhpWord/Writer/HTML/StyleTest.php
index 629efd7a..7548ff02 100644
--- a/tests/PhpWord/Writer/HTML/StyleTest.php
+++ b/tests/PhpWord/Writer/HTML/StyleTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\HTML;
/**
diff --git a/tests/PhpWord/Writer/HTMLTest.php b/tests/PhpWord/Writer/HTMLTest.php
index b2b10165..69cd5a97 100644
--- a/tests/PhpWord/Writer/HTMLTest.php
+++ b/tests/PhpWord/Writer/HTMLTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer;
use PhpOffice\PhpWord\PhpWord;
@@ -31,7 +32,7 @@ class HTMLTest extends \PHPUnit_Framework_TestCase
*/
public function testConstruct()
{
- $object = new HTML(new PhpWord);
+ $object = new HTML(new PhpWord());
$this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $object->getPhpWord());
}
@@ -121,7 +122,7 @@ class HTMLTest extends \PHPUnit_Framework_TestCase
$writer = new HTML($phpWord);
$writer->save($file);
- $this->assertTrue(file_exists($file));
+ $this->assertFileExists($file);
unlink($file);
}
diff --git a/tests/PhpWord/Writer/ODText/ElementTest.php b/tests/PhpWord/Writer/ODText/ElementTest.php
index fb14aae5..ef4e68b0 100644
--- a/tests/PhpWord/Writer/ODText/ElementTest.php
+++ b/tests/PhpWord/Writer/ODText/ElementTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\ODText;
use PhpOffice\Common\XMLWriter;
diff --git a/tests/PhpWord/Writer/ODText/Part/AbstractPartTest.php b/tests/PhpWord/Writer/ODText/Part/AbstractPartTest.php
index 90874b47..5ca980f2 100644
--- a/tests/PhpWord/Writer/ODText/Part/AbstractPartTest.php
+++ b/tests/PhpWord/Writer/ODText/Part/AbstractPartTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\ODText\Part;
use PhpOffice\PhpWord\Writer\ODText;
@@ -40,7 +41,7 @@ class AbstractPartTest extends \PHPUnit_Framework_TestCase
/**
* covers ::getParentWriter
*
- * @expectedException Exception
+ * @expectedException \Exception
* @expectedExceptionMessage No parent WriterInterface assigned.
*/
public function testSetGetParentWriterNull()
diff --git a/tests/PhpWord/Writer/ODText/Part/ContentTest.php b/tests/PhpWord/Writer/ODText/Part/ContentTest.php
index 5814fa60..048c5242 100644
--- a/tests/PhpWord/Writer/ODText/Part/ContentTest.php
+++ b/tests/PhpWord/Writer/ODText/Part/ContentTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\ODText\Part;
use PhpOffice\PhpWord\PhpWord;
diff --git a/tests/PhpWord/Writer/ODText/StyleTest.php b/tests/PhpWord/Writer/ODText/StyleTest.php
index 6b979385..1a0c3ccd 100644
--- a/tests/PhpWord/Writer/ODText/StyleTest.php
+++ b/tests/PhpWord/Writer/ODText/StyleTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\ODText;
use PhpOffice\Common\XMLWriter;
diff --git a/tests/PhpWord/Writer/ODTextTest.php b/tests/PhpWord/Writer/ODTextTest.php
index d79a9d42..d35a4ec7 100644
--- a/tests/PhpWord/Writer/ODTextTest.php
+++ b/tests/PhpWord/Writer/ODTextTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer;
use PhpOffice\PhpWord\PhpWord;
@@ -90,7 +91,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
$writer = new ODText($phpWord);
$writer->save($file);
- $this->assertTrue(file_exists($file));
+ $this->assertFileExists($file);
unlink($file);
}
@@ -102,6 +103,8 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
*/
public function testSavePhpOutput()
{
+ $this->setOutputCallback(function () {
+ });
$phpWord = new PhpWord();
$section = $phpWord->addSection();
$section->addText('Test');
@@ -136,7 +139,7 @@ class ODTextTest extends \PHPUnit_Framework_TestCase
*/
public function testSetUseDiskCachingException()
{
- $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_BASE_DIR, 'foo'));
+ $dir = implode(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_BASE_DIR, 'foo'));
$object = new ODText();
$object->setUseDiskCaching(true, $dir);
diff --git a/tests/PhpWord/Writer/PDF/DomPDFTest.php b/tests/PhpWord/Writer/PDF/DomPDFTest.php
index 67026a84..7831f472 100644
--- a/tests/PhpWord/Writer/PDF/DomPDFTest.php
+++ b/tests/PhpWord/Writer/PDF/DomPDFTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\PDF;
use PhpOffice\PhpWord\PhpWord;
@@ -45,7 +46,7 @@ class DomPDFTest extends \PHPUnit_Framework_TestCase
$writer = new PDF($phpWord);
$writer->save($file);
- $this->assertTrue(file_exists($file));
+ $this->assertFileExists($file);
unlink($file);
}
diff --git a/tests/PhpWord/Writer/PDF/MPDFTest.php b/tests/PhpWord/Writer/PDF/MPDFTest.php
index b6c85a40..62411b97 100644
--- a/tests/PhpWord/Writer/PDF/MPDFTest.php
+++ b/tests/PhpWord/Writer/PDF/MPDFTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\PDF;
use PhpOffice\PhpWord\PhpWord;
@@ -44,7 +45,7 @@ class MPDFTest extends \PHPUnit_Framework_TestCase
$writer = new PDF($phpWord);
$writer->save($file);
- $this->assertTrue(file_exists($file));
+ $this->assertFileExists($file);
unlink($file);
}
diff --git a/tests/PhpWord/Writer/PDF/TCPDFTest.php b/tests/PhpWord/Writer/PDF/TCPDFTest.php
index aaec55eb..d5bd534b 100644
--- a/tests/PhpWord/Writer/PDF/TCPDFTest.php
+++ b/tests/PhpWord/Writer/PDF/TCPDFTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\PDF;
use PhpOffice\PhpWord\PhpWord;
@@ -44,7 +45,7 @@ class TCPDFTest extends \PHPUnit_Framework_TestCase
$writer = new PDF($phpWord);
$writer->save($file);
- $this->assertTrue(file_exists($file));
+ $this->assertFileExists($file);
unlink($file);
}
diff --git a/tests/PhpWord/Writer/PDFTest.php b/tests/PhpWord/Writer/PDFTest.php
index 75db6c03..f1a908a9 100644
--- a/tests/PhpWord/Writer/PDFTest.php
+++ b/tests/PhpWord/Writer/PDFTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer;
use PhpOffice\PhpWord\PhpWord;
@@ -40,7 +41,7 @@ class PDFTest extends \PHPUnit_Framework_TestCase
$writer = new PDF(new PhpWord());
$writer->save($file);
- $this->assertTrue(file_exists($file));
+ $this->assertFileExists($file);
unlink($file);
}
diff --git a/tests/PhpWord/Writer/RTF/ElementTest.php b/tests/PhpWord/Writer/RTF/ElementTest.php
index 47d01d00..17a9c22f 100644
--- a/tests/PhpWord/Writer/RTF/ElementTest.php
+++ b/tests/PhpWord/Writer/RTF/ElementTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\RTF;
use PhpOffice\PhpWord\Writer\RTF;
diff --git a/tests/PhpWord/Writer/RTF/StyleTest.php b/tests/PhpWord/Writer/RTF/StyleTest.php
index 095d30d5..4e3a0eed 100644
--- a/tests/PhpWord/Writer/RTF/StyleTest.php
+++ b/tests/PhpWord/Writer/RTF/StyleTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\RTF;
/**
diff --git a/tests/PhpWord/Writer/RTFTest.php b/tests/PhpWord/Writer/RTFTest.php
index 0b4f6b0f..ec83f7b1 100644
--- a/tests/PhpWord/Writer/RTFTest.php
+++ b/tests/PhpWord/Writer/RTFTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer;
use PhpOffice\PhpWord\PhpWord;
@@ -31,7 +32,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
*/
public function testConstruct()
{
- $object = new RTF(new PhpWord);
+ $object = new RTF(new PhpWord());
$this->assertInstanceOf('PhpOffice\\PhpWord\\PhpWord', $object->getPhpWord());
}
@@ -91,7 +92,7 @@ class RTFTest extends \PHPUnit_Framework_TestCase
$writer = new RTF($phpWord);
$writer->save($file);
- $this->assertTrue(file_exists($file));
+ $this->assertFileExists($file);
@unlink($file);
}
@@ -103,6 +104,8 @@ class RTFTest extends \PHPUnit_Framework_TestCase
*/
public function testSavePhpOutput()
{
+ $this->setOutputCallback(function () {
+ });
$phpWord = new PhpWord();
$section = $phpWord->addSection();
$section->addText(htmlspecialchars('Test', ENT_COMPAT, 'UTF-8'));
diff --git a/tests/PhpWord/Writer/Word2007/ElementTest.php b/tests/PhpWord/Writer/Word2007/ElementTest.php
index b3c7b197..6186695b 100644
--- a/tests/PhpWord/Writer/Word2007/ElementTest.php
+++ b/tests/PhpWord/Writer/Word2007/ElementTest.php
@@ -10,16 +10,17 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\Common\XMLWriter;
+use PhpOffice\PhpWord\Element\TextRun;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\TestHelperDOCX;
-use PhpOffice\PhpWord\Element\TextRun;
/**
* Test class for PhpOffice\PhpWord\Writer\Word2007\Element subnamespace
@@ -186,7 +187,7 @@ class ElementTest extends \PHPUnit_Framework_TestCase
$index = 0;
foreach ($chartTypes as $chartType) {
- $index++;
+ ++$index;
$file = "word/charts/chart{$index}.xml";
$path = "/c:chartSpace/c:chart/c:plotArea/c:{$chartType}Chart";
$this->assertTrue($doc->elementExists($path, $file));
diff --git a/tests/PhpWord/Writer/Word2007/Part/AbstractPartTest.php b/tests/PhpWord/Writer/Word2007/Part/AbstractPartTest.php
index 8f72cdfe..47f65861 100644
--- a/tests/PhpWord/Writer/Word2007/Part/AbstractPartTest.php
+++ b/tests/PhpWord/Writer/Word2007/Part/AbstractPartTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\Writer\Word2007;
@@ -24,7 +25,7 @@ use PhpOffice\PhpWord\Writer\Word2007;
* @coversDefaultClass \PhpOffice\PhpWord\Writer\Word2007\Part\AbstractWriterPart
* @runTestsInSeparateProcesses
*/
-class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
+class AbstractPartTest extends \PHPUnit_Framework_TestCase
{
/**
* covers ::setParentWriter
@@ -40,7 +41,7 @@ class AbstractWriterPartTest extends \PHPUnit_Framework_TestCase
/**
* covers ::getParentWriter
*
- * @expectedException Exception
+ * @expectedException \Exception
* @expectedExceptionMessage No parent WriterInterface assigned.
*/
public function testSetGetParentWriterNull()
diff --git a/tests/PhpWord/Writer/Word2007/Part/CommentsTest.php b/tests/PhpWord/Writer/Word2007/Part/CommentsTest.php
index aac4b15b..4a4fd308 100644
--- a/tests/PhpWord/Writer/Word2007/Part/CommentsTest.php
+++ b/tests/PhpWord/Writer/Word2007/Part/CommentsTest.php
@@ -10,15 +10,15 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\TestHelperDOCX;
-use PhpOffice\PhpWord\Writer\Word2007;
/**
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Comment
@@ -40,7 +40,6 @@ class CommentsTest extends \PHPUnit_Framework_TestCase
*/
public function testWriteComments()
{
-
$comment = new \PhpOffice\PhpWord\Element\Comment('Authors name', new \DateTime(), 'my_initials');
$comment->addText('Test');
@@ -55,7 +54,7 @@ class CommentsTest extends \PHPUnit_Framework_TestCase
$element = $doc->getElement($path, $file);
$this->assertNotNull($element->getAttribute('w:id'));
- $this->assertEquals("Authors name", $element->getAttribute('w:author'));
- $this->assertEquals("my_initials", $element->getAttribute('w:initials'));
+ $this->assertEquals('Authors name', $element->getAttribute('w:author'));
+ $this->assertEquals('my_initials', $element->getAttribute('w:initials'));
}
}
diff --git a/tests/PhpWord/Writer/Word2007/Part/DocumentTest.php b/tests/PhpWord/Writer/Word2007/Part/DocumentTest.php
index d45cde6b..d194814c 100644
--- a/tests/PhpWord/Writer/Word2007/Part/DocumentTest.php
+++ b/tests/PhpWord/Writer/Word2007/Part/DocumentTest.php
@@ -10,18 +10,19 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\ComplexType\FootnoteProperties;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\Jc;
+use PhpOffice\PhpWord\SimpleType\NumberFormat;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\TestHelperDOCX;
-use PhpOffice\PhpWord\SimpleType\NumberFormat;
/**
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Document
@@ -458,7 +459,7 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
// Test the attributes
$attributeCount = 0;
foreach ($attributes as $key => $value) {
- $attributeCount++;
+ ++$attributeCount;
$nodeName = ($key == 'alignment') ? 'jc' : $key;
$path = "/w:document/w:body/w:p[{$attributeCount}]/w:pPr/w:{$nodeName}";
if ('alignment' != $key) {
diff --git a/tests/PhpWord/Writer/Word2007/Part/FooterTest.php b/tests/PhpWord/Writer/Word2007/Part/FooterTest.php
index 9a7d809a..98fb003e 100644
--- a/tests/PhpWord/Writer/Word2007/Part/FooterTest.php
+++ b/tests/PhpWord/Writer/Word2007/Part/FooterTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\Writer\Word2007;
diff --git a/tests/PhpWord/Writer/Word2007/Part/FootnotesTest.php b/tests/PhpWord/Writer/Word2007/Part/FootnotesTest.php
index 2d48fe36..e557d9c2 100644
--- a/tests/PhpWord/Writer/Word2007/Part/FootnotesTest.php
+++ b/tests/PhpWord/Writer/Word2007/Part/FootnotesTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\PhpWord;
diff --git a/tests/PhpWord/Writer/Word2007/Part/HeaderTest.php b/tests/PhpWord/Writer/Word2007/Part/HeaderTest.php
index 6c285af6..7830469c 100644
--- a/tests/PhpWord/Writer/Word2007/Part/HeaderTest.php
+++ b/tests/PhpWord/Writer/Word2007/Part/HeaderTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\Writer\Word2007;
diff --git a/tests/PhpWord/Writer/Word2007/Part/NumberingTest.php b/tests/PhpWord/Writer/Word2007/Part/NumberingTest.php
index bca4b562..0f1ae523 100644
--- a/tests/PhpWord/Writer/Word2007/Part/NumberingTest.php
+++ b/tests/PhpWord/Writer/Word2007/Part/NumberingTest.php
@@ -10,16 +10,17 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\SimpleType\Jc;
-use PhpOffice\PhpWord\TestHelperDOCX;
use PhpOffice\PhpWord\SimpleType\NumberFormat;
+use PhpOffice\PhpWord\TestHelperDOCX;
/**
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Numbering
@@ -64,7 +65,7 @@ class NumberingTest extends \PHPUnit_Framework_TestCase
'font' => 'Arial',
'hint' => 'default',
),
- )
+ ),
)
);
diff --git a/tests/PhpWord/Writer/Word2007/Part/SettingsTest.php b/tests/PhpWord/Writer/Word2007/Part/SettingsTest.php
index 99c66680..7d85995c 100644
--- a/tests/PhpWord/Writer/Word2007/Part/SettingsTest.php
+++ b/tests/PhpWord/Writer/Word2007/Part/SettingsTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\ComplexType\TrackChangesView;
@@ -77,15 +78,15 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
public function testDefaultLanguage()
{
$phpWord = new PhpWord();
-
+
$doc = TestHelperDOCX::getDocument($phpWord);
-
+
$file = 'word/settings.xml';
-
+
$path = '/w:settings/w:themeFontLang';
$this->assertTrue($doc->elementExists($path, $file));
$element = $doc->getElement($path, $file);
-
+
$this->assertEquals('en-US', $element->getAttribute('w:val'));
}
@@ -97,13 +98,13 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$phpWord = new PhpWord();
$phpWord->getSettings()->setThemeFontLang(new Language(Language::DE_DE, Language::KO_KR, Language::HE_IL));
$doc = TestHelperDOCX::getDocument($phpWord);
-
+
$file = 'word/settings.xml';
-
+
$path = '/w:settings/w:themeFontLang';
$this->assertTrue($doc->elementExists($path, $file));
$element = $doc->getElement($path, $file);
-
+
$this->assertEquals(Language::DE_DE, $element->getAttribute('w:val'));
$this->assertEquals(Language::KO_KR, $element->getAttribute('w:eastAsia'));
$this->assertEquals(Language::HE_IL, $element->getAttribute('w:bidi'));
@@ -116,15 +117,15 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
{
$phpWord = new PhpWord();
$phpWord->getSettings()->setHideSpellingErrors(true);
-
+
$doc = TestHelperDOCX::getDocument($phpWord);
-
+
$file = 'word/settings.xml';
-
+
$path = '/w:settings/w:hideSpellingErrors';
$this->assertTrue($doc->elementExists($path, $file));
$element = $doc->getElement($path, $file);
-
+
$this->assertNotEquals('false', $element->getAttribute('w:val'));
}
@@ -135,14 +136,14 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
{
$phpWord = new PhpWord();
$phpWord->getSettings()->setEvenAndOddHeaders(true);
-
+
$doc = TestHelperDOCX::getDocument($phpWord);
-
+
$file = 'word/settings.xml';
-
+
$path = '/w:settings/w:evenAndOddHeaders';
$this->assertTrue($doc->elementExists($path, $file));
-
+
$element = $doc->getElement($path, $file);
$this->assertNotEquals('false', $element->getAttribute('w:val'));
}
@@ -161,7 +162,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$path = '/w:settings/w:zoom';
$this->assertTrue($doc->elementExists($path, $file));
-
+
$element = $doc->getElement($path, $file);
$this->assertEquals('75', $element->getAttribute('w:percent'));
}
@@ -180,7 +181,7 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
$path = '/w:settings/w:zoom';
$this->assertTrue($doc->elementExists($path, $file));
-
+
$element = $doc->getElement($path, $file);
$this->assertEquals('fullPage', $element->getAttribute('w:val'));
}
diff --git a/tests/PhpWord/Writer/Word2007/Part/StylesTest.php b/tests/PhpWord/Writer/Word2007/Part/StylesTest.php
index 0c0f7aef..cba0bfb3 100644
--- a/tests/PhpWord/Writer/Word2007/Part/StylesTest.php
+++ b/tests/PhpWord/Writer/Word2007/Part/StylesTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007\Part;
use PhpOffice\PhpWord\PhpWord;
@@ -21,7 +22,6 @@ use PhpOffice\PhpWord\SimpleType\Jc;
use PhpOffice\PhpWord\Style\Font;
use PhpOffice\PhpWord\Style\Paragraph;
use PhpOffice\PhpWord\TestHelperDOCX;
-use PhpOffice\PhpWord\Writer\Word2007;
/**
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Styles
@@ -85,12 +85,12 @@ class StylesTest extends \PHPUnit_Framework_TestCase
$baseParagraphStyle = new Paragraph();
$baseParagraphStyle->setAlignment(Jc::CENTER);
$baseParagraphStyle = $phpWord->addParagraphStyle('BaseStyle', $baseParagraphStyle);
-
+
$childFont = new Font();
$childFont->setParagraph($baseParagraphStyle);
$childFont->setSize(16);
$childFont = $phpWord->addFontStyle('ChildFontStyle', $childFont);
-
+
$otherFont = new Font();
$otherFont->setSize(20);
$otherFont = $phpWord->addFontStyle('OtherFontStyle', $otherFont);
@@ -134,7 +134,7 @@ class StylesTest extends \PHPUnit_Framework_TestCase
$styleGenerationEteinte->setParagraph($styleGenerationEteinteP);
$styleGenerationEteinte->setSize(8.5);
$phpWord->addFontStyle('GeneratEteinte', $styleGenerationEteinte);
-
+
$doc = TestHelperDOCX::getDocument($phpWord);
$file = 'word/styles.xml';
diff --git a/tests/PhpWord/Writer/Word2007/PartTest.php b/tests/PhpWord/Writer/Word2007/PartTest.php
index 7af8ce3a..3261db4f 100644
--- a/tests/PhpWord/Writer/Word2007/PartTest.php
+++ b/tests/PhpWord/Writer/Word2007/PartTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\PhpWord\Writer\Word2007\Part\RelsPart;
diff --git a/tests/PhpWord/Writer/Word2007/Style/FontTest.php b/tests/PhpWord/Writer/Word2007/Style/FontTest.php
index 50a7ecf7..f406bc05 100644
--- a/tests/PhpWord/Writer/Word2007/Style/FontTest.php
+++ b/tests/PhpWord/Writer/Word2007/Style/FontTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007\Style;
use PhpOffice\PhpWord\TestHelperDOCX;
diff --git a/tests/PhpWord/Writer/Word2007/StyleTest.php b/tests/PhpWord/Writer/Word2007/StyleTest.php
index dfabec03..05785b0c 100644
--- a/tests/PhpWord/Writer/Word2007/StyleTest.php
+++ b/tests/PhpWord/Writer/Word2007/StyleTest.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer\Word2007;
use PhpOffice\Common\XMLWriter;
diff --git a/tests/PhpWord/Writer/Word2007Test.php b/tests/PhpWord/Writer/Word2007Test.php
index 76ba2114..88a522a9 100644
--- a/tests/PhpWord/Writer/Word2007Test.php
+++ b/tests/PhpWord/Writer/Word2007Test.php
@@ -10,10 +10,11 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
+
namespace PhpOffice\PhpWord\Writer;
use PhpOffice\PhpWord\PhpWord;
@@ -96,7 +97,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
$file = __DIR__ . '/../_files/temp.docx';
$writer->save($file);
- $this->assertTrue(file_exists($file));
+ $this->assertFileExists($file);
unlink($file);
}
@@ -117,7 +118,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
$file = __DIR__ . '/../_files/temp.docx';
$writer->save($file);
- $this->assertTrue(file_exists($file));
+ $this->assertFileExists($file);
unlink($file);
}
@@ -166,6 +167,8 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
*/
public function testSetGetUseDiskCaching()
{
+ $this->setOutputCallback(function () {
+ });
$phpWord = new PhpWord();
$phpWord->addSection();
$object = new Word2007($phpWord);
@@ -183,7 +186,7 @@ class Word2007Test extends \PHPUnit_Framework_TestCase
*/
public function testSetUseDiskCachingException()
{
- $dir = join(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_BASE_DIR, 'foo'));
+ $dir = implode(DIRECTORY_SEPARATOR, array(PHPWORD_TESTS_BASE_DIR, 'foo'));
$object = new Word2007();
$object->setUseDiskCaching(true, $dir);
diff --git a/tests/PhpWord/_includes/TestHelperDOCX.php b/tests/PhpWord/_includes/TestHelperDOCX.php
index 03079974..bef060ee 100644
--- a/tests/PhpWord/_includes/TestHelperDOCX.php
+++ b/tests/PhpWord/_includes/TestHelperDOCX.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -29,7 +29,7 @@ class TestHelperDOCX
*
* @var string
*/
- static protected $file;
+ protected static $file;
/**
* Get document content
@@ -39,9 +39,8 @@ class TestHelperDOCX
* @param \PhpOffice\PhpWord\PhpWord $phpWord
* @param string $writerName
*
- * @return \PhpOffice\PhpWord\XmlDocument
- *
* @throws \PhpOffice\PhpWord\Exception\CreateTemporaryFileException
+ * @return \PhpOffice\PhpWord\XmlDocument
*/
public static function getDocument(PhpWord $phpWord, $writerName = 'Word2007')
{
@@ -57,7 +56,7 @@ class TestHelperDOCX
$xmlWriter = IOFactory::createWriter($phpWord, $writerName);
$xmlWriter->save(self::$file);
- $zip = new \ZipArchive;
+ $zip = new \ZipArchive();
$res = $zip->open(self::$file);
if (true === $res) {
$zip->extractTo(Settings::getTempDir() . '/PhpWord_Unit_Test/');
diff --git a/tests/PhpWord/_includes/XmlDocument.php b/tests/PhpWord/_includes/XmlDocument.php
index c3bab0f6..ef56ed15 100644
--- a/tests/PhpWord/_includes/XmlDocument.php
+++ b/tests/PhpWord/_includes/XmlDocument.php
@@ -10,8 +10,8 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
@@ -25,7 +25,7 @@ class XmlDocument
/**
* Path
*
- * @var string $path
+ * @var string
*/
private $path;
@@ -78,6 +78,7 @@ class XmlDocument
$file = $this->path . '/' . $file;
$this->dom = new \DOMDocument();
$this->dom->load($file);
+
return $this->dom;
}
@@ -158,6 +159,7 @@ class XmlDocument
public function elementExists($path, $file = 'word/document.xml')
{
$nodeList = $this->getNodeList($path, $file);
+
return !($nodeList->length == 0);
}
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 60ca5ae7..7126c204 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -10,11 +10,10 @@
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. test bootstrap
*
- * @link https://github.com/PHPOffice/PHPWord
- * @copyright 2010-2016 PHPWord contributors
+ * @see https://github.com/PHPOffice/PHPWord
+ * @copyright 2010-2017 PHPWord contributors
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
-
require_once __DIR__ . '/../bootstrap.php';
date_default_timezone_set('UTC');
@@ -29,7 +28,7 @@ spl_autoload_register(function ($class) {
$prefix = 'PhpOffice\\PhpWord';
if (strpos($class, $prefix) === 0) {
$class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
- $class = join(DIRECTORY_SEPARATOR, array('PhpWord', '_includes')) .
+ $class = implode(DIRECTORY_SEPARATOR, array('PhpWord', '_includes')) .
substr($class, strlen($prefix));
$file = __DIR__ . DIRECTORY_SEPARATOR . $class . '.php';
if (file_exists($file)) {