Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: "Run unit tests"

permissions:
contents: read

on:
- push
- pull_request
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
"sabberworm/php-css-parser": "^8.4"
},
"require-dev": {
"phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11"
"phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10 || ^11 || ^12"
}
}
10 changes: 5 additions & 5 deletions src/Svg/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ private function _tagStart($parser, $name, $attributes)
$this->enterDefs();
$tag = new Symbol($this, $name);
break;

case 'clippath':
$tag = new ClipPath($this, $name);
break;
Expand Down Expand Up @@ -403,7 +403,7 @@ function _charData($parser, $data)

function _tagEnd($parser, $name)
{
/** @var AbstractTag $tag */
/** @var AbstractTag|null $tag */
$tag = null;
switch (strtolower($name)) {
case 'defs':
Expand All @@ -414,7 +414,7 @@ function _tagEnd($parser, $name)
$this->exitDefs();
$tag = array_pop($this->stack);
break;

case 'svg':
case 'path':
case 'rect':
Expand All @@ -437,8 +437,8 @@ function _tagEnd($parser, $name)
break;
}

if ((!$this->inDefs && $tag) || $tag instanceof StyleTag) {
if ((!$this->inDefs && $tag !== null) || $tag instanceof StyleTag) {
$tag->handleEnd();
}
}
}
}
9 changes: 7 additions & 2 deletions src/Svg/Style.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ protected function getStyleMap()
}

/**
* @param $attributes
* @param array<string,string|float|int|null> $attributes
*
* @return Style
* @return void
*/
public function fromAttributes($attributes)
{
Expand Down Expand Up @@ -151,6 +151,11 @@ public function fromStyleSheets(AbstractTag $tag, $attributes) {
$this->fillStyles($styles);
}

/**
* @param array<string,string|float|int|null> $styles
*
* @return void
*/
protected function fillStyles($styles)
{
$style_map = $this->getStyleMap();
Expand Down
Loading