Skip to content

Commit 1b7b43a

Browse files
committed
fix code formatting
1 parent e1bbc85 commit 1b7b43a

File tree

2 files changed

+40
-40
lines changed

2 files changed

+40
-40
lines changed

src/PhpWord/Shared/Html.php

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ protected static function parseInlineStyle($node, $styles = array())
115115
// tables, cells
116116
if (false !== strpos($val, '%')) {
117117
// e.g. <table width="100%"> or <td width="50%">
118-
$styles['width'] = intval($val) * 50;
118+
$styles['width'] = (int) $val * 50;
119119
$styles['unit'] = \PhpOffice\PhpWord\SimpleType\TblWidth::PERCENT;
120120
} else {
121121
// e.g. <table width="250> where "250" = 250px (always pixels)
@@ -125,7 +125,7 @@ protected static function parseInlineStyle($node, $styles = array())
125125
break;
126126
case 'cellspacing':
127127
// tables e.g. <table cellspacing="2">, where "2" = 2px (always pixels)
128-
$val = intval($val).'px';
128+
$val = (int) $val . 'px';
129129
$styles['cellSpacing'] = Converter::cssToTwip($val);
130130
break;
131131
case 'bgcolor':
@@ -693,7 +693,7 @@ protected static function parseStyle($attribute, $styles)
693693
// This may be adjusted, if better ratio or formula found.
694694
// BC change: up to ver. 0.17.0 was $size converted to points - Converter::cssToPoint($size)
695695
$size = Converter::cssToTwip($matches[1]);
696-
$size = intval($size / 2);
696+
$size = (int) ($size / 2);
697697
// valid variants may be e.g. borderSize, borderTopSize, borderLeftColor, etc ..
698698
$styles["border{$which}Size"] = $size; // twips
699699
$styles["border{$which}Color"] = trim($matches[2], '#');
@@ -871,9 +871,9 @@ protected static function mapAlign($cssAlignment)
871871
}
872872

873873
/**
874-
* Transforms a HTML/CSS alignment into a \PhpOffice\PhpWord\SimpleType\Jc
874+
* Transforms a HTML/CSS vertical alignment
875875
*
876-
* @param string $cssAlignment
876+
* @param string $alignment
877877
* @return string|null
878878
*/
879879
protected static function mapAlignVertical($alignment)
@@ -901,10 +901,10 @@ protected static function mapAlignVertical($alignment)
901901
}
902902

903903
/**
904-
* Map list style for ordered list
905-
*
906-
* @param string $cssListType
907-
*/
904+
* Map list style for ordered list
905+
*
906+
* @param string $cssListType
907+
*/
908908
protected static function mapListType($cssListType)
909909
{
910910
switch ($cssListType) {
@@ -959,32 +959,32 @@ protected static function parseLink($node, $element, &$styles)
959959
}
960960

961961
/**
962-
* Render horizontal rule
963-
* Note: Word rule is not the same as HTML's <hr> since it does not support width and thus neither alignment
964-
*
965-
* @param \DOMNode $node
966-
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
967-
*/
962+
* Render horizontal rule
963+
* Note: Word rule is not the same as HTML's <hr> since it does not support width and thus neither alignment
964+
*
965+
* @param \DOMNode $node
966+
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element
967+
*/
968968
protected static function parseHorizRule($node, $element)
969969
{
970970
$styles = self::parseInlineStyle($node);
971971

972972
// <hr> is implemented as an empty paragraph - extending 100% inside the section
973973
// Some properties may be controlled, e.g. <hr style="border-bottom: 3px #DDDDDD solid; margin-bottom: 0;">
974974

975-
$fontStyle = $styles + ['size' => 3];
975+
$fontStyle = $styles + array('size' => 3);
976976

977-
$paragraphStyle = $styles + [
978-
'lineHeight' => 0.25, // multiply default line height - e.g. 1, 1.5 etc
979-
'spacing' => 0, // twip
980-
'spaceBefore' => 120, // twip, 240/2 (default line height)
981-
'spaceAfter' => 120, // twip
982-
'borderBottomSize' => empty($styles['line-height']) ? 1 : $styles['line-height'],
977+
$paragraphStyle = $styles + array(
978+
'lineHeight' => 0.25, // multiply default line height - e.g. 1, 1.5 etc
979+
'spacing' => 0, // twip
980+
'spaceBefore' => 120, // twip, 240/2 (default line height)
981+
'spaceAfter' => 120, // twip
982+
'borderBottomSize' => empty($styles['line-height']) ? 1 : $styles['line-height'],
983983
'borderBottomColor' => empty($styles['color']) ? '000000' : $styles['color'],
984984
'borderBottomStyle' => 'single', // same as "solid"
985-
];
985+
);
986986

987-
$element->addText("", $fontStyle, $paragraphStyle);
987+
$element->addText('', $fontStyle, $paragraphStyle);
988988

989989
// Notes: <hr/> cannot be:
990990
// - table - throws error "cannot be inside textruns", e.g. lists

tests/PhpWord/Shared/HtmlTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,8 @@ public function testParseLetterSpacing()
634634
}
635635

636636
/**
637-
* Parse widths in tables and cells, which also allows for controlling column width
638-
*/
637+
* Parse widths in tables and cells, which also allows for controlling column width
638+
*/
639639
public function testParseTableAndCellWidth()
640640
{
641641
$phpWord = new \PhpOffice\PhpWord\PhpWord();
@@ -703,14 +703,14 @@ public function testParseTableAndCellWidth()
703703
}
704704

705705
/**
706-
* Test parsing background color for table rows and table cellspacing
707-
*/
706+
* Test parsing background color for table rows and table cellspacing
707+
*/
708708
public function testParseCellspacingRowBgColor()
709709
{
710710
$phpWord = new \PhpOffice\PhpWord\PhpWord();
711-
$section = $phpWord->addSection([
711+
$section = $phpWord->addSection(array(
712712
'orientation' => \PhpOffice\PhpWord\Style\Section::ORIENTATION_LANDSCAPE,
713-
]);
713+
));
714714

715715
// borders & backgrounds are here just for better visual comparison
716716
$html = <<<HTML
@@ -744,8 +744,8 @@ public function testParseCellspacingRowBgColor()
744744
}
745745

746746
/**
747-
* Parse horizontal rule
748-
*/
747+
* Parse horizontal rule
748+
*/
749749
public function testParseHorizRule()
750750
{
751751
$phpWord = new \PhpOffice\PhpWord\PhpWord();
@@ -774,7 +774,7 @@ public function testParseHorizRule()
774774
$xpath = '/w:document/w:body/w:p[4]/w:pPr/w:pBdr/w:bottom';
775775
$this->assertTrue($doc->elementExists($xpath));
776776
$this->assertEquals('single', $doc->getElement($xpath)->getAttribute('w:val'));
777-
$this->assertEquals(intval(5 * 15 / 2), $doc->getElement($xpath)->getAttribute('w:sz'));
777+
$this->assertEquals((int) (5 * 15 / 2), $doc->getElement($xpath)->getAttribute('w:sz'));
778778
$this->assertEquals('lightblue', $doc->getElement($xpath)->getAttribute('w:color'));
779779

780780
$xpath = '/w:document/w:body/w:p[4]/w:pPr/w:spacing';
@@ -785,8 +785,8 @@ public function testParseHorizRule()
785785
}
786786

787787
/**
788-
* Parse ordered list start & numbering style
789-
*/
788+
* Parse ordered list start & numbering style
789+
*/
790790
public function testParseOrderedList()
791791
{
792792
$phpWord = new \PhpOffice\PhpWord\PhpWord();
@@ -846,8 +846,8 @@ public function testParseOrderedList()
846846
}
847847

848848
/**
849-
* Parse ordered list start & numbering style
850-
*/
849+
* Parse ordered list start & numbering style
850+
*/
851851
public function testParseVerticalAlign()
852852
{
853853
$phpWord = new \PhpOffice\PhpWord\PhpWord();
@@ -886,8 +886,8 @@ public function testParseVerticalAlign()
886886
}
887887

888888
/**
889-
* Fix bug - don't decode double quotes inside double quoted string
890-
*/
889+
* Fix bug - don't decode double quotes inside double quoted string
890+
*/
891891
public function testDontDecodeAlreadyEncodedDoubleQuotes()
892892
{
893893
$phpWord = new \PhpOffice\PhpWord\PhpWord();
@@ -900,6 +900,6 @@ public function testDontDecodeAlreadyEncodedDoubleQuotes()
900900

901901
Html::addHtml($section, $html);
902902
$doc = TestHelperDOCX::getDocument($phpWord, 'Word2007');
903-
$this->assertTrue(is_object($doc));
903+
$this->assertInternalType('object', $doc);
904904
}
905905
}

0 commit comments

Comments
 (0)