Skip to content

Commit

Permalink
Merge pull request #5 from cosmocode/bot/autofix
Browse files Browse the repository at this point in the history
🤖 Automatic code style fixes
  • Loading branch information
splitbrain authored Jul 25, 2024
2 parents 28a6986 + 8a97b96 commit 43101ed
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docx/Numbering.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected function parse()
$id = (int)$num->attributes('w', true)->abstractNumId;
$types[$id] = [];

foreach($num->xpath('.//w:lvl') as $lvl) {
foreach ($num->xpath('.//w:lvl') as $lvl) {
$depth = (int)$lvl->attributes('w', true)->ilvl;
$lvlType = (string)$lvl->xpath('.//w:numFmt')[0]->attributes('w', true)->val;
$lvlType = ($lvlType === 'decimal') ? 'ordered' : 'unordered';
Expand Down
10 changes: 5 additions & 5 deletions docx/Paragraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __toString(): string

// close all formatting that is not in the current text
$toclose = array_diff($fStack, $formatting);
foreach($toclose as $f) {
foreach ($toclose as $f) {
// we need to make sure all formatting is closed, but we close by popping the
// stack. This ensures we don't create invalid nesting
while (in_array($f, $fStack)) {
Expand Down Expand Up @@ -91,8 +91,8 @@ public function __toString(): string
protected function updateFormattingScores()
{
$len = count($this->texts);
if($len < 2) return;
for($i = $len - 2; $i >= 0; $i--) {
if ($len < 2) return;
for ($i = $len - 2; $i >= 0; $i--) {
$this->texts[$i]->updateFormattingScores($this->texts[$i + 1]);
}
}
Expand Down Expand Up @@ -139,7 +139,7 @@ public function alignmentPadding($text)
*/
public function openFormatting(&$text, $formatting)
{
if(!isset($this->fSyntax[$formatting])) {
if (!isset($this->fSyntax[$formatting])) {
throw new \RuntimeException("Unknown formatting: $formatting");
}

Expand All @@ -161,7 +161,7 @@ public function closeFormatting(&$text, $formatting)
$text = $matches[1];
$suffix = $matches[2];

if(!isset($this->fSyntax[$formatting])) {
if (!isset($this->fSyntax[$formatting])) {
throw new \RuntimeException("Unknown formatting: $formatting");
}

Expand Down
1 change: 0 additions & 1 deletion docx/Styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class Styles extends AbstractXMLFile
{

protected $id2name = [];
protected $name2id = [];

Expand Down
3 changes: 0 additions & 3 deletions docx/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ public function __toString(): string
$text .= '|';
foreach ($row as $cell) {
$text .= $cell->__toString();

}
$text .= "\n";
}
return $text;
}


}
8 changes: 2 additions & 6 deletions docx/TableCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

class TableCell extends AbstractParagraph
{

protected $vmerge = false;
protected $span = 1;
/** @var Paragraph[] */
Expand All @@ -13,7 +12,7 @@ class TableCell extends AbstractParagraph
public function parse()
{

$x = $this->p->asXML();
$this->p->asXML();

// vertical merge
$vMerge = $this->p->xpath('w:tcPr/w:vMerge');
Expand Down Expand Up @@ -41,9 +40,7 @@ public function __toString(): string
if ($this->vmerge) {
$string = ":::";
} else {
$string = join('\\\\ ', array_map(function ($p) {
return $p->__toString();
}, $this->paragraphs));
$string = implode('\\\\ ', array_map(static fn($p) => $p->__toString(), $this->paragraphs));
}

if ($this->paragraphs) {
Expand All @@ -54,5 +51,4 @@ public function __toString(): string
$string .= str_repeat('|', $this->span);
return $string;
}

}
1 change: 0 additions & 1 deletion docx/TextRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,4 @@ public function updateFormattingScores(TextRun $nextRun)
// sort by value, longest chains first
arsort($this->formatting);
}

}

0 comments on commit 43101ed

Please sign in to comment.