Scrutinizer fixes

This commit is contained in:
troosan 2017-11-26 22:55:37 +01:00
parent 23bc837666
commit ca25eba8aa
13 changed files with 45 additions and 33 deletions

13
phpstan.neon Normal file
View File

@ -0,0 +1,13 @@
includes:
- vendor/phpstan/phpstan/conf/config.level1.neon
parameters:
memory-limit: 200000
autoload_directories:
- tests
autoload_files:
- tests/bootstrap.php
excludes_analyse:
- */pclzip.lib.php
- src/PhpWord/Shared/OLERead.php
- src/PhpWord/Reader/MsDoc.php
- src/PhpWord/Writer/PDF/MPDF.php

View File

@ -17,8 +17,6 @@
namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\Paragraph;
/**
* Endnote element
*
@ -38,6 +36,6 @@ class Endnote extends Footnote
*/
public function __construct($paragraphStyle = null)
{
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
parent::__construct($paragraphStyle);
}
}

View File

@ -98,7 +98,7 @@ class Field extends AbstractElement
* @param string $type
* @param array $properties
* @param array $options
* @param TextRun|string $text
* @param TextRun|string|null $text
*/
public function __construct($type = null, $properties = array(), $options = array(), $text = null)
{
@ -209,7 +209,7 @@ class Field extends AbstractElement
* @param string|TextRun $text
*
* @throws \InvalidArgumentException
* @return string|TextRun
* @return null|string|TextRun
*/
public function setText($text)
{

View File

@ -137,7 +137,7 @@ class Image extends AbstractElement
$this->setIsWatermark($watermark);
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
$this->checkImage($source);
$this->checkImage();
}
/**

View File

@ -18,7 +18,6 @@
namespace PhpOffice\PhpWord\Element;
use PhpOffice\PhpWord\Style\ListItem as ListItemStyle;
use PhpOffice\PhpWord\Style\Paragraph;
/**
* List item element
@ -61,7 +60,7 @@ class ListItemRun extends TextRun
} else {
$this->style = $this->setNewStyle(new ListItemStyle(), $listStyle, true);
}
$this->paragraphStyle = $this->setNewStyle(new Paragraph(), $paragraphStyle);
parent::__construct($paragraphStyle);
}
/**

View File

@ -142,7 +142,7 @@ class Section extends AbstractContainer
/**
* Get the footnote properties
*
* @return \PhpOffice\PhpWord\Element\FooterProperties
* @return FootnoteProperties
*/
public function getFootnotePropoperties()
{

View File

@ -410,7 +410,7 @@ class DocInfo
* Get a Custom Property Value
*
* @param string $propertyName
* @return string
* @return mixed
*/
public function getCustomPropertyValue($propertyName)
{

View File

@ -3790,7 +3790,7 @@ class PclZip
}
// ----- Write gz file format header
$v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
$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
@ -4383,7 +4383,7 @@ class PclZip
//$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);
$v_bytes = (($v_bytes & 0xFFFFFF) << 8) | ord($v_byte);
// ----- Compare the bytes
if ($v_bytes == 0x504b0506) {

View File

@ -40,7 +40,6 @@ class TCPDF extends AbstractRenderer implements WriterInterface
* Save PhpWord to file.
*
* @param string $filename Name of the file to save as
* @return vois
*/
public function save($filename = null)
{
@ -55,21 +54,21 @@ class TCPDF extends AbstractRenderer implements WriterInterface
$pdf->setFontSubsetting(false);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->addPage();
$pdf->setFont($this->getFont());
$pdf->AddPage();
$pdf->SetFont($this->getFont());
$pdf->writeHTML($this->getContent());
// Write document properties
$phpWord = $this->getPhpWord();
$docProps = $phpWord->getDocInfo();
$pdf->setTitle($docProps->getTitle());
$pdf->setAuthor($docProps->getCreator());
$pdf->setSubject($docProps->getSubject());
$pdf->setKeywords($docProps->getKeywords());
$pdf->setCreator($docProps->getCreator());
$pdf->SetTitle($docProps->getTitle());
$pdf->SetAuthor($docProps->getCreator());
$pdf->SetSubject($docProps->getSubject());
$pdf->SetKeywords($docProps->getKeywords());
$pdf->SetCreator($docProps->getCreator());
// Write to file
fwrite($fileHandle, $pdf->output($filename, 'S'));
fwrite($fileHandle, $pdf->Output($filename, 'S'));
parent::restoreStateAfterSave($fileHandle);
}

View File

@ -101,7 +101,7 @@ class SDT extends Text
*/
private function writeDropDownList(XMLWriter $xmlWriter, SDTElement $element)
{
$this->writecomboBox($xmlWriter, $element);
$this->writeComboBox($xmlWriter, $element);
}
/**

View File

@ -73,7 +73,7 @@ class ConverterTest extends \PHPUnit\Framework\TestCase
$result = Converter::pixelToPoint($value);
$this->assertEquals($value / 96 * 72, $result);
$result = Converter::pixelToEMU($value);
$result = Converter::pixelToEmu($value);
$this->assertEquals(round($value * 9525), $result);
$result = Converter::pointToTwip($value);
@ -82,7 +82,7 @@ class ConverterTest extends \PHPUnit\Framework\TestCase
$result = Converter::pointToPixel($value);
$this->assertEquals($value / 72 * 96, $result);
$result = Converter::pointToEMU($value);
$result = Converter::pointToEmu($value);
$this->assertEquals(round($value / 72 * 96 * 9525), $result);
$result = Converter::emuToPixel($value);
@ -111,7 +111,7 @@ class ConverterTest extends \PHPUnit\Framework\TestCase
$values[] = array('0F9D', false); // 4 characters
// Conduct test
foreach ($values as $value) {
$result = Converter::htmlToRGB($value[0]);
$result = Converter::htmlToRgb($value[0]);
$this->assertEquals($value[1], $result);
}
}

View File

@ -29,21 +29,21 @@ class NumberingTest extends \PHPUnit\Framework\TestCase
*/
public function testGetSetProperties()
{
$this->object = new Numbering();
$this->properties = array(
$object = new Numbering();
$properties = array(
'numId' => array(null, 1),
'type' => array(null, 'singleLevel'),
);
foreach ($this->properties as $property => $value) {
foreach ($properties as $property => $value) {
list($default, $expected) = $value;
$get = "get{$property}";
$set = "set{$property}";
$this->assertEquals($default, $this->object->$get()); // Default value
$this->assertEquals($default, $object->$get()); // Default value
$this->object->$set($expected);
$object->$set($expected);
$this->assertEquals($expected, $this->object->$get()); // New value
$this->assertEquals($expected, $object->$get()); // New value
}
}
@ -52,8 +52,8 @@ class NumberingTest extends \PHPUnit\Framework\TestCase
*/
public function testGetLevels()
{
$this->object = new Numbering();
$object = new Numbering();
$this->assertEmpty($this->object->getLevels());
$this->assertEmpty($object->getLevels());
}
}

View File

@ -99,6 +99,7 @@ class TableTest extends \PHPUnit\Framework\TestCase
$value = 'FF0000';
$object->setBorderColor($value);
$values = array();
foreach ($parts as $part) {
$get = "getBorder{$part}Color";
$values[] = $value;
@ -121,6 +122,7 @@ class TableTest extends \PHPUnit\Framework\TestCase
$value = 4;
$object->setBorderSize($value);
$values = array();
foreach ($parts as $part) {
$get = "getBorder{$part}Size";
$values[] = $value;
@ -143,6 +145,7 @@ class TableTest extends \PHPUnit\Framework\TestCase
$value = 240;
$object->setCellMargin($value);
$values = array();
foreach ($parts as $part) {
$get = "getCellMargin{$part}";
$values[] = $value;