From 23bc8376668cfff4a2be8ff7286c5ba5ee399f36 Mon Sep 17 00:00:00 2001 From: troosan Date: Sun, 26 Nov 2017 17:54:47 +0100 Subject: [PATCH] Scrutinizer fixes --- run_tests.sh | 8 +++++++- src/PhpWord/Element/Field.php | 4 ++-- src/PhpWord/Element/TrackChange.php | 2 +- src/PhpWord/Reader/Word2007/Settings.php | 6 +++--- src/PhpWord/Shared/AbstractEnum.php | 2 +- src/PhpWord/Shared/ZipArchive.php | 2 +- src/PhpWord/Writer/ODText/Element/Text.php | 1 - 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 6b81d69c..a5d94259 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,14 +1,20 @@ #!/bin/bash +echo "Running composer update" +composer update ## PHP_CodeSniffer +echo "Running CodeSniffer" ./vendor/bin/phpcs src/ tests/ --standard=PSR2 -n --ignore=src/PhpWord/Shared/PCLZip ## PHP-CS-Fixer +echo "Running CS Fixer" ./vendor/bin/php-cs-fixer fix --diff --verbose --dry-run ## PHP Mess Detector +echo "Running Mess Detector" ./vendor/bin/phpmd src/,tests/ text ./phpmd.xml.dist --exclude pclzip.lib.php ## PHPUnit -./vendor/bin/phpunit -c ./ --no-coverage +echo "Running PHPUnit" +./vendor/bin/phpunit -c ./ diff --git a/src/PhpWord/Element/Field.php b/src/PhpWord/Element/Field.php index d51cba8d..4481f16b 100644 --- a/src/PhpWord/Element/Field.php +++ b/src/PhpWord/Element/Field.php @@ -74,7 +74,7 @@ class Field extends AbstractElement /** * Field text * - * @var TextRun | string + * @var TextRun|string */ protected $text; @@ -98,7 +98,7 @@ class Field extends AbstractElement * @param string $type * @param array $properties * @param array $options - * @param TextRun | string $text + * @param TextRun|string $text */ public function __construct($type = null, $properties = array(), $options = array(), $text = null) { diff --git a/src/PhpWord/Element/TrackChange.php b/src/PhpWord/Element/TrackChange.php index d900b053..9ed623f9 100644 --- a/src/PhpWord/Element/TrackChange.php +++ b/src/PhpWord/Element/TrackChange.php @@ -37,7 +37,7 @@ class TrackChange extends AbstractContainer /** * Date * - * @var DateTime + * @var \DateTime */ private $date; diff --git a/src/PhpWord/Reader/Word2007/Settings.php b/src/PhpWord/Reader/Word2007/Settings.php index 2580209e..c116425e 100644 --- a/src/PhpWord/Reader/Word2007/Settings.php +++ b/src/PhpWord/Reader/Word2007/Settings.php @@ -150,11 +150,11 @@ class Settings extends AbstractPart protected function setRevisionView(XMLReader $xmlReader, PhpWord $phpWord, \DOMElement $node) { $revisionView = new TrackChangesView(); - $revisionView->setMarkup($xmlReader->getAttribute('w:markup', $node)); + $revisionView->setMarkup(filter_var($xmlReader->getAttribute('w:markup', $node), FILTER_VALIDATE_BOOLEAN)); $revisionView->setComments($xmlReader->getAttribute('w:comments', $node)); $revisionView->setInsDel($xmlReader->getAttribute('w:insDel', $node)); - $revisionView->setFormatting($xmlReader->getAttribute('w:formatting', $node)); - $revisionView->setInkAnnotations($xmlReader->getAttribute('w:inkAnnotations', $node)); + $revisionView->setFormatting(filter_var($xmlReader->getAttribute('w:formatting', $node), FILTER_VALIDATE_BOOLEAN)); + $revisionView->setInkAnnotations(filter_var($xmlReader->getAttribute('w:inkAnnotations', $node), FILTER_VALIDATE_BOOLEAN)); $phpWord->getSettings()->setRevisionView($revisionView); } } diff --git a/src/PhpWord/Shared/AbstractEnum.php b/src/PhpWord/Shared/AbstractEnum.php index 58601a14..442d8251 100644 --- a/src/PhpWord/Shared/AbstractEnum.php +++ b/src/PhpWord/Shared/AbstractEnum.php @@ -48,7 +48,7 @@ abstract class AbstractEnum /** * Returns true the value is valid for this enum * - * @param strign $value + * @param string $value * @return bool true if value is valid */ public static function isValid($value) diff --git a/src/PhpWord/Shared/ZipArchive.php b/src/PhpWord/Shared/ZipArchive.php index d73f6c33..77a84488 100644 --- a/src/PhpWord/Shared/ZipArchive.php +++ b/src/PhpWord/Shared/ZipArchive.php @@ -351,7 +351,7 @@ class ZipArchive * Returns the name of an entry using its index (emulate \ZipArchive) * * @param int $index - * @return string + * @return string|bool * @since 0.10.0 */ public function pclzipGetNameIndex($index) diff --git a/src/PhpWord/Writer/ODText/Element/Text.php b/src/PhpWord/Writer/ODText/Element/Text.php index dc377699..1fc0b800 100644 --- a/src/PhpWord/Writer/ODText/Element/Text.php +++ b/src/PhpWord/Writer/ODText/Element/Text.php @@ -18,7 +18,6 @@ namespace PhpOffice\PhpWord\Writer\ODText\Element; use PhpOffice\PhpWord\Exception\Exception; -use PhpOffice\PhpWord\Settings; /** * Text element writer