diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 705d16c8..52bb0a33 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - php74 pull_request: jobs: @@ -43,7 +44,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3'] steps: - uses: actions/checkout@v3 diff --git a/rector.php b/rector.php new file mode 100644 index 00000000..76f9e5eb --- /dev/null +++ b/rector.php @@ -0,0 +1,17 @@ +withPaths([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + + ->withPhpSets(php74: true) + ->withRules([ + AddVoidReturnTypeWhereNoReturnRector::class, + ]); diff --git a/src/Fonts/TrueTypeFontFile.php b/src/Fonts/TrueTypeFontFile.php index 455cce01..1ffa760c 100644 --- a/src/Fonts/TrueTypeFontFile.php +++ b/src/Fonts/TrueTypeFontFile.php @@ -44,10 +44,7 @@ public function getFamily(): string public function getWeight(): float { - if (isset($this->weightClass)) { - return $this->weightClass; - } - return $this->subfamily === 'Bold' || $this->subfamily === 'Bold Italic' ? 700 : 400; + return $this->weightClass ?? ($this->subfamily === 'Bold' || $this->subfamily === 'Bold Italic' ? 700 : 400); } public function isItalic(): bool diff --git a/src/Nodes/Embedded/SVGForeignObject.php b/src/Nodes/Embedded/SVGForeignObject.php index 51417885..b7deeeaf 100644 --- a/src/Nodes/Embedded/SVGForeignObject.php +++ b/src/Nodes/Embedded/SVGForeignObject.php @@ -10,7 +10,7 @@ */ class SVGForeignObject extends SVGNodeContainer { - const TAG_NAME = 'foreignObject'; + public const TAG_NAME = 'foreignObject'; public function __construct() { diff --git a/src/Nodes/Embedded/SVGImage.php b/src/Nodes/Embedded/SVGImage.php index be18a88a..46c0a073 100644 --- a/src/Nodes/Embedded/SVGImage.php +++ b/src/Nodes/Embedded/SVGImage.php @@ -14,7 +14,7 @@ */ class SVGImage extends SVGNodeContainer { - const TAG_NAME = 'image'; + public const TAG_NAME = 'image'; /** * @param string|null $href The image path, URL or URI. diff --git a/src/Nodes/Filters/SVGFEBlend.php b/src/Nodes/Filters/SVGFEBlend.php index 5332a984..478842e8 100644 --- a/src/Nodes/Filters/SVGFEBlend.php +++ b/src/Nodes/Filters/SVGFEBlend.php @@ -10,7 +10,7 @@ */ class SVGFEBlend extends SVGNodeContainer { - const TAG_NAME = 'feBlend'; + public const TAG_NAME = 'feBlend'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEColorMatrix.php b/src/Nodes/Filters/SVGFEColorMatrix.php index 1f0393a1..e1812185 100644 --- a/src/Nodes/Filters/SVGFEColorMatrix.php +++ b/src/Nodes/Filters/SVGFEColorMatrix.php @@ -10,7 +10,7 @@ */ class SVGFEColorMatrix extends SVGNodeContainer { - const TAG_NAME = 'feColorMatrix'; + public const TAG_NAME = 'feColorMatrix'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEComponentTransfer.php b/src/Nodes/Filters/SVGFEComponentTransfer.php index 7f51596d..ec7a4b74 100644 --- a/src/Nodes/Filters/SVGFEComponentTransfer.php +++ b/src/Nodes/Filters/SVGFEComponentTransfer.php @@ -10,7 +10,7 @@ */ class SVGFEComponentTransfer extends SVGNodeContainer { - const TAG_NAME = 'feComponentTransfer'; + public const TAG_NAME = 'feComponentTransfer'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEComposite.php b/src/Nodes/Filters/SVGFEComposite.php index 21df7302..e4c69300 100644 --- a/src/Nodes/Filters/SVGFEComposite.php +++ b/src/Nodes/Filters/SVGFEComposite.php @@ -10,7 +10,7 @@ */ class SVGFEComposite extends SVGNodeContainer { - const TAG_NAME = 'feComposite'; + public const TAG_NAME = 'feComposite'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEConvolveMatrix.php b/src/Nodes/Filters/SVGFEConvolveMatrix.php index a9dcde62..43c050cf 100644 --- a/src/Nodes/Filters/SVGFEConvolveMatrix.php +++ b/src/Nodes/Filters/SVGFEConvolveMatrix.php @@ -10,7 +10,7 @@ */ class SVGFEConvolveMatrix extends SVGNodeContainer { - const TAG_NAME = 'feConvolveMatrix'; + public const TAG_NAME = 'feConvolveMatrix'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEDiffuseLighting.php b/src/Nodes/Filters/SVGFEDiffuseLighting.php index 9ba0052a..338c49de 100644 --- a/src/Nodes/Filters/SVGFEDiffuseLighting.php +++ b/src/Nodes/Filters/SVGFEDiffuseLighting.php @@ -10,7 +10,7 @@ */ class SVGFEDiffuseLighting extends SVGNodeContainer { - const TAG_NAME = 'feDiffuseLighting'; + public const TAG_NAME = 'feDiffuseLighting'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEDisplacementMap.php b/src/Nodes/Filters/SVGFEDisplacementMap.php index cc198b2d..33604b3d 100644 --- a/src/Nodes/Filters/SVGFEDisplacementMap.php +++ b/src/Nodes/Filters/SVGFEDisplacementMap.php @@ -10,7 +10,7 @@ */ class SVGFEDisplacementMap extends SVGNodeContainer { - const TAG_NAME = 'feDisplacementMap'; + public const TAG_NAME = 'feDisplacementMap'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEDistantLight.php b/src/Nodes/Filters/SVGFEDistantLight.php index 24673db3..f4884fd9 100644 --- a/src/Nodes/Filters/SVGFEDistantLight.php +++ b/src/Nodes/Filters/SVGFEDistantLight.php @@ -10,7 +10,7 @@ */ class SVGFEDistantLight extends SVGNodeContainer { - const TAG_NAME = 'feDistantLight'; + public const TAG_NAME = 'feDistantLight'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEDropShadow.php b/src/Nodes/Filters/SVGFEDropShadow.php index d9827cda..ceeb98d9 100644 --- a/src/Nodes/Filters/SVGFEDropShadow.php +++ b/src/Nodes/Filters/SVGFEDropShadow.php @@ -10,7 +10,7 @@ */ class SVGFEDropShadow extends SVGNodeContainer { - const TAG_NAME = 'feDropShadow'; + public const TAG_NAME = 'feDropShadow'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEFlood.php b/src/Nodes/Filters/SVGFEFlood.php index 43d5b8c4..5a00596e 100644 --- a/src/Nodes/Filters/SVGFEFlood.php +++ b/src/Nodes/Filters/SVGFEFlood.php @@ -10,7 +10,7 @@ */ class SVGFEFlood extends SVGNodeContainer { - const TAG_NAME = 'feFlood'; + public const TAG_NAME = 'feFlood'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEFuncA.php b/src/Nodes/Filters/SVGFEFuncA.php index 75b8b47e..1a022770 100644 --- a/src/Nodes/Filters/SVGFEFuncA.php +++ b/src/Nodes/Filters/SVGFEFuncA.php @@ -10,7 +10,7 @@ */ class SVGFEFuncA extends SVGNodeContainer { - const TAG_NAME = 'feFuncA'; + public const TAG_NAME = 'feFuncA'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEFuncB.php b/src/Nodes/Filters/SVGFEFuncB.php index 468bd44b..82f433c7 100644 --- a/src/Nodes/Filters/SVGFEFuncB.php +++ b/src/Nodes/Filters/SVGFEFuncB.php @@ -10,7 +10,7 @@ */ class SVGFEFuncB extends SVGNodeContainer { - const TAG_NAME = 'feFuncB'; + public const TAG_NAME = 'feFuncB'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEFuncG.php b/src/Nodes/Filters/SVGFEFuncG.php index 646bd5b6..1a1c27f2 100644 --- a/src/Nodes/Filters/SVGFEFuncG.php +++ b/src/Nodes/Filters/SVGFEFuncG.php @@ -10,7 +10,7 @@ */ class SVGFEFuncG extends SVGNodeContainer { - const TAG_NAME = 'feFuncG'; + public const TAG_NAME = 'feFuncG'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEFuncR.php b/src/Nodes/Filters/SVGFEFuncR.php index dd4056f7..224bb58f 100644 --- a/src/Nodes/Filters/SVGFEFuncR.php +++ b/src/Nodes/Filters/SVGFEFuncR.php @@ -10,7 +10,7 @@ */ class SVGFEFuncR extends SVGNodeContainer { - const TAG_NAME = 'feFuncR'; + public const TAG_NAME = 'feFuncR'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEGaussianBlur.php b/src/Nodes/Filters/SVGFEGaussianBlur.php index 740a8bb3..89a5097c 100644 --- a/src/Nodes/Filters/SVGFEGaussianBlur.php +++ b/src/Nodes/Filters/SVGFEGaussianBlur.php @@ -10,7 +10,7 @@ */ class SVGFEGaussianBlur extends SVGNodeContainer { - const TAG_NAME = 'feGaussianBlur'; + public const TAG_NAME = 'feGaussianBlur'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEImage.php b/src/Nodes/Filters/SVGFEImage.php index 2a31d904..eb0ffdb1 100644 --- a/src/Nodes/Filters/SVGFEImage.php +++ b/src/Nodes/Filters/SVGFEImage.php @@ -10,7 +10,7 @@ */ class SVGFEImage extends SVGNodeContainer { - const TAG_NAME = 'feImage'; + public const TAG_NAME = 'feImage'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEMerge.php b/src/Nodes/Filters/SVGFEMerge.php index 70fc367e..366b6acf 100644 --- a/src/Nodes/Filters/SVGFEMerge.php +++ b/src/Nodes/Filters/SVGFEMerge.php @@ -10,7 +10,7 @@ */ class SVGFEMerge extends SVGNodeContainer { - const TAG_NAME = 'feMerge'; + public const TAG_NAME = 'feMerge'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEMergeNode.php b/src/Nodes/Filters/SVGFEMergeNode.php index 73c0167c..a480f639 100644 --- a/src/Nodes/Filters/SVGFEMergeNode.php +++ b/src/Nodes/Filters/SVGFEMergeNode.php @@ -10,7 +10,7 @@ */ class SVGFEMergeNode extends SVGNodeContainer { - const TAG_NAME = 'feMergeNode'; + public const TAG_NAME = 'feMergeNode'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEMorphology.php b/src/Nodes/Filters/SVGFEMorphology.php index 3c99918c..fe803d1f 100644 --- a/src/Nodes/Filters/SVGFEMorphology.php +++ b/src/Nodes/Filters/SVGFEMorphology.php @@ -10,7 +10,7 @@ */ class SVGFEMorphology extends SVGNodeContainer { - const TAG_NAME = 'feMorphology'; + public const TAG_NAME = 'feMorphology'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEOffset.php b/src/Nodes/Filters/SVGFEOffset.php index ef18c507..8529a647 100644 --- a/src/Nodes/Filters/SVGFEOffset.php +++ b/src/Nodes/Filters/SVGFEOffset.php @@ -10,7 +10,7 @@ */ class SVGFEOffset extends SVGNodeContainer { - const TAG_NAME = 'feOffset'; + public const TAG_NAME = 'feOffset'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFEPointLight.php b/src/Nodes/Filters/SVGFEPointLight.php index 933f9d8a..6910c47b 100644 --- a/src/Nodes/Filters/SVGFEPointLight.php +++ b/src/Nodes/Filters/SVGFEPointLight.php @@ -10,7 +10,7 @@ */ class SVGFEPointLight extends SVGNodeContainer { - const TAG_NAME = 'fePointLight'; + public const TAG_NAME = 'fePointLight'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFESpecularLighting.php b/src/Nodes/Filters/SVGFESpecularLighting.php index 5af754bd..1e2aee5f 100644 --- a/src/Nodes/Filters/SVGFESpecularLighting.php +++ b/src/Nodes/Filters/SVGFESpecularLighting.php @@ -10,7 +10,7 @@ */ class SVGFESpecularLighting extends SVGNodeContainer { - const TAG_NAME = 'feSpecularLighting'; + public const TAG_NAME = 'feSpecularLighting'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFESpotLight.php b/src/Nodes/Filters/SVGFESpotLight.php index 682dd5e5..2bde7e10 100644 --- a/src/Nodes/Filters/SVGFESpotLight.php +++ b/src/Nodes/Filters/SVGFESpotLight.php @@ -10,7 +10,7 @@ */ class SVGFESpotLight extends SVGNodeContainer { - const TAG_NAME = 'feSpotLight'; + public const TAG_NAME = 'feSpotLight'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFETile.php b/src/Nodes/Filters/SVGFETile.php index d326fb3d..7fbb39cb 100644 --- a/src/Nodes/Filters/SVGFETile.php +++ b/src/Nodes/Filters/SVGFETile.php @@ -10,7 +10,7 @@ */ class SVGFETile extends SVGNodeContainer { - const TAG_NAME = 'feTile'; + public const TAG_NAME = 'feTile'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFETurbulence.php b/src/Nodes/Filters/SVGFETurbulence.php index 5934da31..85890074 100644 --- a/src/Nodes/Filters/SVGFETurbulence.php +++ b/src/Nodes/Filters/SVGFETurbulence.php @@ -10,7 +10,7 @@ */ class SVGFETurbulence extends SVGNodeContainer { - const TAG_NAME = 'feTurbulence'; + public const TAG_NAME = 'feTurbulence'; public function __construct() { diff --git a/src/Nodes/Filters/SVGFilter.php b/src/Nodes/Filters/SVGFilter.php index 25b457f6..1465be96 100644 --- a/src/Nodes/Filters/SVGFilter.php +++ b/src/Nodes/Filters/SVGFilter.php @@ -10,7 +10,7 @@ */ class SVGFilter extends SVGNodeContainer { - const TAG_NAME = 'filter'; + public const TAG_NAME = 'filter'; public function __construct() { diff --git a/src/Nodes/Presentation/SVGAnimate.php b/src/Nodes/Presentation/SVGAnimate.php index 3470a091..eddbd03f 100644 --- a/src/Nodes/Presentation/SVGAnimate.php +++ b/src/Nodes/Presentation/SVGAnimate.php @@ -10,7 +10,7 @@ */ class SVGAnimate extends SVGNodeContainer { - const TAG_NAME = 'animate'; + public const TAG_NAME = 'animate'; public function __construct() { diff --git a/src/Nodes/Presentation/SVGAnimateMotion.php b/src/Nodes/Presentation/SVGAnimateMotion.php index 3d7a5d72..ef01f83f 100644 --- a/src/Nodes/Presentation/SVGAnimateMotion.php +++ b/src/Nodes/Presentation/SVGAnimateMotion.php @@ -10,7 +10,7 @@ */ class SVGAnimateMotion extends SVGNodeContainer { - const TAG_NAME = 'animateMotion'; + public const TAG_NAME = 'animateMotion'; public function __construct() { diff --git a/src/Nodes/Presentation/SVGAnimateTransform.php b/src/Nodes/Presentation/SVGAnimateTransform.php index ff68c95c..aa01c1ba 100644 --- a/src/Nodes/Presentation/SVGAnimateTransform.php +++ b/src/Nodes/Presentation/SVGAnimateTransform.php @@ -10,7 +10,7 @@ */ class SVGAnimateTransform extends SVGNodeContainer { - const TAG_NAME = 'animateTransform'; + public const TAG_NAME = 'animateTransform'; public function __construct() { diff --git a/src/Nodes/Presentation/SVGLinearGradient.php b/src/Nodes/Presentation/SVGLinearGradient.php index 2c1ea7e7..ff88acfd 100644 --- a/src/Nodes/Presentation/SVGLinearGradient.php +++ b/src/Nodes/Presentation/SVGLinearGradient.php @@ -10,7 +10,7 @@ */ class SVGLinearGradient extends SVGNodeContainer { - const TAG_NAME = 'linearGradient'; + public const TAG_NAME = 'linearGradient'; public function __construct() { diff --git a/src/Nodes/Presentation/SVGMPath.php b/src/Nodes/Presentation/SVGMPath.php index accb0939..6ba3964e 100644 --- a/src/Nodes/Presentation/SVGMPath.php +++ b/src/Nodes/Presentation/SVGMPath.php @@ -10,7 +10,7 @@ */ class SVGMPath extends SVGNodeContainer { - const TAG_NAME = 'mpath'; + public const TAG_NAME = 'mpath'; public function __construct() { diff --git a/src/Nodes/Presentation/SVGRadialGradient.php b/src/Nodes/Presentation/SVGRadialGradient.php index f275ef56..d9f41f93 100644 --- a/src/Nodes/Presentation/SVGRadialGradient.php +++ b/src/Nodes/Presentation/SVGRadialGradient.php @@ -10,7 +10,7 @@ */ class SVGRadialGradient extends SVGNodeContainer { - const TAG_NAME = 'radialGradient'; + public const TAG_NAME = 'radialGradient'; public function __construct() { diff --git a/src/Nodes/Presentation/SVGSet.php b/src/Nodes/Presentation/SVGSet.php index 2d56b370..f8713cc6 100644 --- a/src/Nodes/Presentation/SVGSet.php +++ b/src/Nodes/Presentation/SVGSet.php @@ -10,7 +10,7 @@ */ class SVGSet extends SVGNodeContainer { - const TAG_NAME = 'set'; + public const TAG_NAME = 'set'; public function __construct() { diff --git a/src/Nodes/Presentation/SVGStop.php b/src/Nodes/Presentation/SVGStop.php index a86f4b27..3d2180b1 100644 --- a/src/Nodes/Presentation/SVGStop.php +++ b/src/Nodes/Presentation/SVGStop.php @@ -10,7 +10,7 @@ */ class SVGStop extends SVGNodeContainer { - const TAG_NAME = 'stop'; + public const TAG_NAME = 'stop'; public function __construct() { diff --git a/src/Nodes/Presentation/SVGView.php b/src/Nodes/Presentation/SVGView.php index f72cfae8..1f2c96b0 100644 --- a/src/Nodes/Presentation/SVGView.php +++ b/src/Nodes/Presentation/SVGView.php @@ -10,7 +10,7 @@ */ class SVGView extends SVGNodeContainer { - const TAG_NAME = 'view'; + public const TAG_NAME = 'view'; public function __construct() { diff --git a/src/Nodes/SVGNodeContainer.php b/src/Nodes/SVGNodeContainer.php index af81c15c..aecb7695 100644 --- a/src/Nodes/SVGNodeContainer.php +++ b/src/Nodes/SVGNodeContainer.php @@ -49,7 +49,7 @@ public function addChild(SVGNode $node, int $index = null): SVGNodeContainer $node->parent->removeChild($node); } - $index = ($index !== null) ? $index : count($this->children); + $index = $index ?? count($this->children); // insert and set new parent array_splice($this->children, $index, 0, [$node]); diff --git a/src/Nodes/Shapes/SVGCircle.php b/src/Nodes/Shapes/SVGCircle.php index ffa2599d..f519abea 100644 --- a/src/Nodes/Shapes/SVGCircle.php +++ b/src/Nodes/Shapes/SVGCircle.php @@ -13,7 +13,7 @@ */ class SVGCircle extends SVGNodeContainer { - const TAG_NAME = 'circle'; + public const TAG_NAME = 'circle'; /** * @param mixed $cx The center's x coordinate. diff --git a/src/Nodes/Shapes/SVGEllipse.php b/src/Nodes/Shapes/SVGEllipse.php index 015f5a6c..a1278b77 100644 --- a/src/Nodes/Shapes/SVGEllipse.php +++ b/src/Nodes/Shapes/SVGEllipse.php @@ -13,7 +13,7 @@ */ class SVGEllipse extends SVGNodeContainer { - const TAG_NAME = 'ellipse'; + public const TAG_NAME = 'ellipse'; /** * @param mixed $cx The center's x coordinate. diff --git a/src/Nodes/Shapes/SVGLine.php b/src/Nodes/Shapes/SVGLine.php index 5de5fe6b..5009be59 100644 --- a/src/Nodes/Shapes/SVGLine.php +++ b/src/Nodes/Shapes/SVGLine.php @@ -13,7 +13,7 @@ */ class SVGLine extends SVGNodeContainer { - const TAG_NAME = 'line'; + public const TAG_NAME = 'line'; /** * @param mixed $x1 The first point's x coordinate. diff --git a/src/Nodes/Shapes/SVGPath.php b/src/Nodes/Shapes/SVGPath.php index ae8b2ef9..ba1cc955 100644 --- a/src/Nodes/Shapes/SVGPath.php +++ b/src/Nodes/Shapes/SVGPath.php @@ -12,7 +12,7 @@ */ class SVGPath extends SVGNodeContainer { - const TAG_NAME = 'path'; + public const TAG_NAME = 'path'; private static $pathParser; diff --git a/src/Nodes/Shapes/SVGPolygon.php b/src/Nodes/Shapes/SVGPolygon.php index 3c0da35a..bb5aab7f 100644 --- a/src/Nodes/Shapes/SVGPolygon.php +++ b/src/Nodes/Shapes/SVGPolygon.php @@ -11,7 +11,7 @@ */ class SVGPolygon extends SVGPolygonalShape { - const TAG_NAME = 'polygon'; + public const TAG_NAME = 'polygon'; /** * @param array[] $points Array of points (float 2-tuples). diff --git a/src/Nodes/Shapes/SVGPolygonalShape.php b/src/Nodes/Shapes/SVGPolygonalShape.php index 01e86315..ec580e4a 100644 --- a/src/Nodes/Shapes/SVGPolygonalShape.php +++ b/src/Nodes/Shapes/SVGPolygonalShape.php @@ -35,7 +35,7 @@ public function __construct(array $points = null) public function addPoint($a, $b = null): SVGPolygonalShape { if (is_array($a)) { - list($a, $b) = $a; + [$a, $b] = $a; } $pointsAttribute = $this->getAttribute('points') ?: ''; diff --git a/src/Nodes/Shapes/SVGPolyline.php b/src/Nodes/Shapes/SVGPolyline.php index c2c74f66..7575f098 100644 --- a/src/Nodes/Shapes/SVGPolyline.php +++ b/src/Nodes/Shapes/SVGPolyline.php @@ -11,7 +11,7 @@ */ class SVGPolyline extends SVGPolygonalShape { - const TAG_NAME = 'polyline'; + public const TAG_NAME = 'polyline'; /** * @param array[] $points Array of points (float 2-tuples). diff --git a/src/Nodes/Shapes/SVGRect.php b/src/Nodes/Shapes/SVGRect.php index f3629790..20f3346e 100644 --- a/src/Nodes/Shapes/SVGRect.php +++ b/src/Nodes/Shapes/SVGRect.php @@ -13,7 +13,7 @@ */ class SVGRect extends SVGNodeContainer { - const TAG_NAME = 'rect'; + public const TAG_NAME = 'rect'; /** * @param mixed $x The x coordinate of the upper left corner. diff --git a/src/Nodes/Structures/SVGClipPath.php b/src/Nodes/Structures/SVGClipPath.php index 5752738d..4eab6469 100644 --- a/src/Nodes/Structures/SVGClipPath.php +++ b/src/Nodes/Structures/SVGClipPath.php @@ -10,7 +10,7 @@ */ class SVGClipPath extends SVGNodeContainer { - const TAG_NAME = 'clipPath'; + public const TAG_NAME = 'clipPath'; public function __construct(string $id = null) { diff --git a/src/Nodes/Structures/SVGDefs.php b/src/Nodes/Structures/SVGDefs.php index 64ed2fab..57364550 100644 --- a/src/Nodes/Structures/SVGDefs.php +++ b/src/Nodes/Structures/SVGDefs.php @@ -10,7 +10,7 @@ */ class SVGDefs extends SVGNodeContainer { - const TAG_NAME = 'defs'; + public const TAG_NAME = 'defs'; public function __construct() { diff --git a/src/Nodes/Structures/SVGDocumentFragment.php b/src/Nodes/Structures/SVGDocumentFragment.php index ac14fedd..b8404e03 100644 --- a/src/Nodes/Structures/SVGDocumentFragment.php +++ b/src/Nodes/Structures/SVGDocumentFragment.php @@ -13,7 +13,7 @@ */ class SVGDocumentFragment extends SVGNodeContainer { - const TAG_NAME = 'svg'; + public const TAG_NAME = 'svg'; /** @var array $initialStyles A map of style keys to their defaults. */ private static $initialStyles = [ diff --git a/src/Nodes/Structures/SVGGroup.php b/src/Nodes/Structures/SVGGroup.php index ce392cc9..34fbe5c0 100644 --- a/src/Nodes/Structures/SVGGroup.php +++ b/src/Nodes/Structures/SVGGroup.php @@ -9,7 +9,7 @@ */ class SVGGroup extends SVGNodeContainer { - const TAG_NAME = 'g'; + public const TAG_NAME = 'g'; public function __construct() { diff --git a/src/Nodes/Structures/SVGLinkGroup.php b/src/Nodes/Structures/SVGLinkGroup.php index 19bd4aaa..07d7f0a6 100644 --- a/src/Nodes/Structures/SVGLinkGroup.php +++ b/src/Nodes/Structures/SVGLinkGroup.php @@ -9,7 +9,7 @@ */ class SVGLinkGroup extends SVGNodeContainer { - const TAG_NAME = 'a'; + public const TAG_NAME = 'a'; public function __construct() { diff --git a/src/Nodes/Structures/SVGMarker.php b/src/Nodes/Structures/SVGMarker.php index 55336c83..3ee895d0 100644 --- a/src/Nodes/Structures/SVGMarker.php +++ b/src/Nodes/Structures/SVGMarker.php @@ -10,7 +10,7 @@ */ class SVGMarker extends SVGNodeContainer { - const TAG_NAME = 'marker'; + public const TAG_NAME = 'marker'; public function __construct() { diff --git a/src/Nodes/Structures/SVGMask.php b/src/Nodes/Structures/SVGMask.php index 11d49776..5b9ff174 100644 --- a/src/Nodes/Structures/SVGMask.php +++ b/src/Nodes/Structures/SVGMask.php @@ -10,7 +10,7 @@ */ class SVGMask extends SVGNodeContainer { - const TAG_NAME = 'mask'; + public const TAG_NAME = 'mask'; public function __construct() { diff --git a/src/Nodes/Structures/SVGMetadata.php b/src/Nodes/Structures/SVGMetadata.php index c75c6aaf..91e556b6 100644 --- a/src/Nodes/Structures/SVGMetadata.php +++ b/src/Nodes/Structures/SVGMetadata.php @@ -10,7 +10,7 @@ */ class SVGMetadata extends SVGNodeContainer { - const TAG_NAME = 'metadata'; + public const TAG_NAME = 'metadata'; public function __construct() { diff --git a/src/Nodes/Structures/SVGPattern.php b/src/Nodes/Structures/SVGPattern.php index 914bda27..17cedc75 100644 --- a/src/Nodes/Structures/SVGPattern.php +++ b/src/Nodes/Structures/SVGPattern.php @@ -10,7 +10,7 @@ */ class SVGPattern extends SVGNodeContainer { - const TAG_NAME = 'pattern'; + public const TAG_NAME = 'pattern'; public function __construct() { diff --git a/src/Nodes/Structures/SVGScript.php b/src/Nodes/Structures/SVGScript.php index 4f915498..c3378d63 100644 --- a/src/Nodes/Structures/SVGScript.php +++ b/src/Nodes/Structures/SVGScript.php @@ -11,7 +11,7 @@ */ class SVGScript extends SVGNodeContainer implements CDataContainer { - const TAG_NAME = 'script'; + public const TAG_NAME = 'script'; /** * @param string $content The script content. diff --git a/src/Nodes/Structures/SVGStyle.php b/src/Nodes/Structures/SVGStyle.php index d97cc092..aac09c12 100644 --- a/src/Nodes/Structures/SVGStyle.php +++ b/src/Nodes/Structures/SVGStyle.php @@ -12,7 +12,7 @@ */ class SVGStyle extends SVGNodeContainer implements CDataContainer { - const TAG_NAME = 'style'; + public const TAG_NAME = 'style'; /** * @param string $css The CSS data rules. diff --git a/src/Nodes/Structures/SVGSwitch.php b/src/Nodes/Structures/SVGSwitch.php index 5bca9514..706825ef 100644 --- a/src/Nodes/Structures/SVGSwitch.php +++ b/src/Nodes/Structures/SVGSwitch.php @@ -10,7 +10,7 @@ */ class SVGSwitch extends SVGNodeContainer { - const TAG_NAME = 'switch'; + public const TAG_NAME = 'switch'; public function __construct() { diff --git a/src/Nodes/Structures/SVGSymbol.php b/src/Nodes/Structures/SVGSymbol.php index 8fd82664..9bb92b37 100644 --- a/src/Nodes/Structures/SVGSymbol.php +++ b/src/Nodes/Structures/SVGSymbol.php @@ -10,7 +10,7 @@ */ class SVGSymbol extends SVGNodeContainer { - const TAG_NAME = 'symbol'; + public const TAG_NAME = 'symbol'; public function __construct() { diff --git a/src/Nodes/Structures/SVGUse.php b/src/Nodes/Structures/SVGUse.php index 30f51ab1..a78e3089 100644 --- a/src/Nodes/Structures/SVGUse.php +++ b/src/Nodes/Structures/SVGUse.php @@ -10,7 +10,7 @@ */ class SVGUse extends SVGNodeContainer { - const TAG_NAME = 'use'; + public const TAG_NAME = 'use'; public function __construct() { diff --git a/src/Nodes/Texts/SVGDesc.php b/src/Nodes/Texts/SVGDesc.php index 3416afcf..f2b0f9fc 100644 --- a/src/Nodes/Texts/SVGDesc.php +++ b/src/Nodes/Texts/SVGDesc.php @@ -10,7 +10,7 @@ */ class SVGDesc extends SVGNodeContainer { - const TAG_NAME = 'desc'; + public const TAG_NAME = 'desc'; public function __construct() { diff --git a/src/Nodes/Texts/SVGTSpan.php b/src/Nodes/Texts/SVGTSpan.php index ebfaa079..4231eb01 100644 --- a/src/Nodes/Texts/SVGTSpan.php +++ b/src/Nodes/Texts/SVGTSpan.php @@ -10,7 +10,7 @@ */ class SVGTSpan extends SVGNodeContainer { - const TAG_NAME = 'tspan'; + public const TAG_NAME = 'tspan'; public function __construct() { diff --git a/src/Nodes/Texts/SVGText.php b/src/Nodes/Texts/SVGText.php index 1b1200c3..476e0567 100644 --- a/src/Nodes/Texts/SVGText.php +++ b/src/Nodes/Texts/SVGText.php @@ -25,7 +25,7 @@ */ class SVGText extends SVGNodeContainer { - const TAG_NAME = 'text'; + public const TAG_NAME = 'text'; public function __construct(string $text = '', $x = 0, $y = 0) { diff --git a/src/Nodes/Texts/SVGTextPath.php b/src/Nodes/Texts/SVGTextPath.php index e4d521d3..6e5223b3 100644 --- a/src/Nodes/Texts/SVGTextPath.php +++ b/src/Nodes/Texts/SVGTextPath.php @@ -10,7 +10,7 @@ */ class SVGTextPath extends SVGNodeContainer { - const TAG_NAME = 'textPath'; + public const TAG_NAME = 'textPath'; public function __construct() { diff --git a/src/Nodes/Texts/SVGTitle.php b/src/Nodes/Texts/SVGTitle.php index acdf14e2..2cbe3c7e 100644 --- a/src/Nodes/Texts/SVGTitle.php +++ b/src/Nodes/Texts/SVGTitle.php @@ -10,7 +10,7 @@ */ class SVGTitle extends SVGNodeContainer { - const TAG_NAME = 'title'; + public const TAG_NAME = 'title'; public function __construct(string $text = '') { diff --git a/src/Rasterization/Path/ArcApproximator.php b/src/Rasterization/Path/ArcApproximator.php index d4541d67..9bae8a06 100644 --- a/src/Rasterization/Path/ArcApproximator.php +++ b/src/Rasterization/Path/ArcApproximator.php @@ -59,7 +59,7 @@ public function approximate( $cosr = cos($rotation); $sinr = sin($rotation); - list($center, $radiusX, $radiusY, $angleStart, $angleDelta) = + [$center, $radiusX, $radiusY, $angleStart, $angleDelta] = self::endpointToCenter($start, $end, $large, $sweep, $radiusX, $radiusY, $cosr, $sinr); $dist = abs($end[0] - $start[0]) + abs($end[1] - $start[1]); diff --git a/src/Rasterization/Path/PathApproximator.php b/src/Rasterization/Path/PathApproximator.php index 1fad8f94..6fa18e1f 100644 --- a/src/Rasterization/Path/PathApproximator.php +++ b/src/Rasterization/Path/PathApproximator.php @@ -222,7 +222,7 @@ private static function reflectPoint(array $p, array $r): array */ private function moveTo(string $id, array $args): void { - list($x, $y) = $args; + [$x, $y] = $args; if ($id === 'm') { $x += $this->posX; $y += $this->posY; @@ -245,7 +245,7 @@ private function moveTo(string $id, array $args): void */ private function lineTo(string $id, array $args): void { - list($x, $y) = $args; + [$x, $y] = $args; if ($id === 'l') { $x += $this->posX; $y += $this->posY; @@ -337,7 +337,7 @@ private function curveToCubic(string $id, array $args): void } $this->cubicOld = $p2; - list($this->posX, $this->posY) = $p3; + [$this->posX, $this->posY] = $p3; $this->transform->map($p1[0], $p1[1]); $this->transform->map($p2[0], $p2[1]); @@ -379,7 +379,7 @@ private function curveToCubicSmooth(string $id, array $args): void } $this->cubicOld = $p2; - list($this->posX, $this->posY) = $p3; + [$this->posX, $this->posY] = $p3; $this->transform->map($p1[0], $p1[1]); $this->transform->map($p2[0], $p2[1]); @@ -414,7 +414,7 @@ private function curveToQuadratic(string $id, array $args): void } $this->quadraticOld = $p1; - list($this->posX, $this->posY) = $p2; + [$this->posX, $this->posY] = $p2; $this->transform->map($p1[0], $p1[1]); $this->transform->map($p2[0], $p2[1]); @@ -451,7 +451,7 @@ private function curveToQuadraticSmooth(string $id, array $args): void } $this->quadraticOld = $p1; - list($this->posX, $this->posY) = $p2; + [$this->posX, $this->posY] = $p2; $this->transform->map($p1[0], $p1[1]); $this->transform->map($p2[0], $p2[1]); @@ -494,7 +494,7 @@ private function arcTo(string $id, array $args): void $p1[1] += $this->posY; } - list($this->posX, $this->posY) = $p1; + [$this->posX, $this->posY] = $p1; // guess a scale factor $scaledRx = $rx; diff --git a/src/Rasterization/Renderers/PathRendererImplementation.php b/src/Rasterization/Renderers/PathRendererImplementation.php index 397e1cbc..63f68f0f 100644 --- a/src/Rasterization/Renderers/PathRendererImplementation.php +++ b/src/Rasterization/Renderers/PathRendererImplementation.php @@ -59,7 +59,7 @@ public static function fillMultipath($image, array $subpaths, int $color, string imagesetthickness($image, 1); // Sort the edges by their maximum y value, descending (i.e., edges that extend further down are sorted first). - usort($edges, ['SVG\Rasterization\Renderers\PathRendererEdge', 'compareMaxY']); + usort($edges, [\SVG\Rasterization\Renderers\PathRendererEdge::class, 'compareMaxY']); // Now the maxY of the entire path is just the maxY of the edge sorted first. // Since there is no way to know which edge has the minY, we cannot do the same for that and have to compute // it during the loop instead. @@ -92,7 +92,7 @@ public static function fillMultipath($image, array $subpaths, int $color, string if (!empty($activeEdges)) { // Now sort the active edges from rightmost to leftmost (i.e., by x descending). - usort($activeEdges, ['SVG\Rasterization\Renderers\PathRendererEdge', 'compareX']); + usort($activeEdges, [\SVG\Rasterization\Renderers\PathRendererEdge::class, 'compareX']); $windingNumber = $evenOdd ? 0 : $activeEdges[0]->direction; diff --git a/src/Reading/AttributeRegistry.php b/src/Reading/AttributeRegistry.php index 09030583..63483415 100644 --- a/src/Reading/AttributeRegistry.php +++ b/src/Reading/AttributeRegistry.php @@ -50,9 +50,9 @@ class AttributeRegistry * for SVG attribute to CSS property conversion. */ private static $styleConverters = [ - 'font-size' => 'SVG\Reading\LengthAttributeConverter', - 'letter-spacing' => 'SVG\Reading\LengthAttributeConverter', - 'word-spacing' => 'SVG\Reading\LengthAttributeConverter', + 'font-size' => \SVG\Reading\LengthAttributeConverter::class, + 'letter-spacing' => \SVG\Reading\LengthAttributeConverter::class, + 'word-spacing' => \SVG\Reading\LengthAttributeConverter::class, ]; /** diff --git a/src/Reading/NodeRegistry.php b/src/Reading/NodeRegistry.php index c4ff1791..04e60fa8 100644 --- a/src/Reading/NodeRegistry.php +++ b/src/Reading/NodeRegistry.php @@ -15,74 +15,74 @@ class NodeRegistry * @var string[] $nodeTypes Map of tag names to fully-qualified class names. */ private static $nodeTypes = [ - 'foreignObject' => 'SVG\Nodes\Embedded\SVGForeignObject', - 'image' => 'SVG\Nodes\Embedded\SVGImage', + 'foreignObject' => \SVG\Nodes\Embedded\SVGForeignObject::class, + 'image' => \SVG\Nodes\Embedded\SVGImage::class, - 'feBlend' => 'SVG\Nodes\Filters\SVGFEBlend', - 'feColorMatrix' => 'SVG\Nodes\Filters\SVGFEColorMatrix', - 'feComponentTransfer' => 'SVG\Nodes\Filters\SVGFEComponentTransfer', - 'feComposite' => 'SVG\Nodes\Filters\SVGFEComposite', - 'feConvolveMatrix' => 'SVG\Nodes\Filters\SVGFEConvolveMatrix', - 'feDiffuseLighting' => 'SVG\Nodes\Filters\SVGFEDiffuseLighting', - 'feDisplacementMap' => 'SVG\Nodes\Filters\SVGFEDisplacementMap', - 'feDistantLight' => 'SVG\Nodes\Filters\SVGFEDistantLight', - 'feDropShadow' => 'SVG\Nodes\Filters\SVGFEDropShadow', - 'feFlood' => 'SVG\Nodes\Filters\SVGFEFlood', - 'feFuncA' => 'SVG\Nodes\Filters\SVGFEFuncA', - 'feFuncB' => 'SVG\Nodes\Filters\SVGFEFuncB', - 'feFuncG' => 'SVG\Nodes\Filters\SVGFEFuncG', - 'feFuncR' => 'SVG\Nodes\Filters\SVGFEFuncR', - 'feGaussianBlur' => 'SVG\Nodes\Filters\SVGFEGaussianBlur', - 'feImage' => 'SVG\Nodes\Filters\SVGFEImage', - 'feMerge' => 'SVG\Nodes\Filters\SVGFEMerge', - 'feMergeNode' => 'SVG\Nodes\Filters\SVGFEMergeNode', - 'feMorphology' => 'SVG\Nodes\Filters\SVGFEMorphology', - 'feOffset' => 'SVG\Nodes\Filters\SVGFEOffset', - 'fePointLight' => 'SVG\Nodes\Filters\SVGFEPointLight', - 'feSpecularLighting' => 'SVG\Nodes\Filters\SVGFESpecularLighting', - 'feSpotLight' => 'SVG\Nodes\Filters\SVGFESpotLight', - 'feTile' => 'SVG\Nodes\Filters\SVGFETile', - 'feTurbulence' => 'SVG\Nodes\Filters\SVGFETurbulence', - 'filter' => 'SVG\Nodes\Filters\SVGFilter', + 'feBlend' => \SVG\Nodes\Filters\SVGFEBlend::class, + 'feColorMatrix' => \SVG\Nodes\Filters\SVGFEColorMatrix::class, + 'feComponentTransfer' => \SVG\Nodes\Filters\SVGFEComponentTransfer::class, + 'feComposite' => \SVG\Nodes\Filters\SVGFEComposite::class, + 'feConvolveMatrix' => \SVG\Nodes\Filters\SVGFEConvolveMatrix::class, + 'feDiffuseLighting' => \SVG\Nodes\Filters\SVGFEDiffuseLighting::class, + 'feDisplacementMap' => \SVG\Nodes\Filters\SVGFEDisplacementMap::class, + 'feDistantLight' => \SVG\Nodes\Filters\SVGFEDistantLight::class, + 'feDropShadow' => \SVG\Nodes\Filters\SVGFEDropShadow::class, + 'feFlood' => \SVG\Nodes\Filters\SVGFEFlood::class, + 'feFuncA' => \SVG\Nodes\Filters\SVGFEFuncA::class, + 'feFuncB' => \SVG\Nodes\Filters\SVGFEFuncB::class, + 'feFuncG' => \SVG\Nodes\Filters\SVGFEFuncG::class, + 'feFuncR' => \SVG\Nodes\Filters\SVGFEFuncR::class, + 'feGaussianBlur' => \SVG\Nodes\Filters\SVGFEGaussianBlur::class, + 'feImage' => \SVG\Nodes\Filters\SVGFEImage::class, + 'feMerge' => \SVG\Nodes\Filters\SVGFEMerge::class, + 'feMergeNode' => \SVG\Nodes\Filters\SVGFEMergeNode::class, + 'feMorphology' => \SVG\Nodes\Filters\SVGFEMorphology::class, + 'feOffset' => \SVG\Nodes\Filters\SVGFEOffset::class, + 'fePointLight' => \SVG\Nodes\Filters\SVGFEPointLight::class, + 'feSpecularLighting' => \SVG\Nodes\Filters\SVGFESpecularLighting::class, + 'feSpotLight' => \SVG\Nodes\Filters\SVGFESpotLight::class, + 'feTile' => \SVG\Nodes\Filters\SVGFETile::class, + 'feTurbulence' => \SVG\Nodes\Filters\SVGFETurbulence::class, + 'filter' => \SVG\Nodes\Filters\SVGFilter::class, - 'animate' => 'SVG\Nodes\Presentation\SVGAnimate', - 'animateMotion' => 'SVG\Nodes\Presentation\SVGAnimateMotion', - 'animateTransform' => 'SVG\Nodes\Presentation\SVGAnimateTransform', - 'linearGradient' => 'SVG\Nodes\Presentation\SVGLinearGradient', - 'mpath' => 'SVG\Nodes\Presentation\SVGMPath', - 'radialGradient' => 'SVG\Nodes\Presentation\SVGRadialGradient', - 'set' => 'SVG\Nodes\Presentation\SVGSet', - 'stop' => 'SVG\Nodes\Presentation\SVGStop', - 'view' => 'SVG\Nodes\Presentation\SVGView', + 'animate' => \SVG\Nodes\Presentation\SVGAnimate::class, + 'animateMotion' => \SVG\Nodes\Presentation\SVGAnimateMotion::class, + 'animateTransform' => \SVG\Nodes\Presentation\SVGAnimateTransform::class, + 'linearGradient' => \SVG\Nodes\Presentation\SVGLinearGradient::class, + 'mpath' => \SVG\Nodes\Presentation\SVGMPath::class, + 'radialGradient' => \SVG\Nodes\Presentation\SVGRadialGradient::class, + 'set' => \SVG\Nodes\Presentation\SVGSet::class, + 'stop' => \SVG\Nodes\Presentation\SVGStop::class, + 'view' => \SVG\Nodes\Presentation\SVGView::class, - 'circle' => 'SVG\Nodes\Shapes\SVGCircle', - 'ellipse' => 'SVG\Nodes\Shapes\SVGEllipse', - 'line' => 'SVG\Nodes\Shapes\SVGLine', - 'path' => 'SVG\Nodes\Shapes\SVGPath', - 'polygon' => 'SVG\Nodes\Shapes\SVGPolygon', - 'polyline' => 'SVG\Nodes\Shapes\SVGPolyline', - 'rect' => 'SVG\Nodes\Shapes\SVGRect', + 'circle' => \SVG\Nodes\Shapes\SVGCircle::class, + 'ellipse' => \SVG\Nodes\Shapes\SVGEllipse::class, + 'line' => \SVG\Nodes\Shapes\SVGLine::class, + 'path' => \SVG\Nodes\Shapes\SVGPath::class, + 'polygon' => \SVG\Nodes\Shapes\SVGPolygon::class, + 'polyline' => \SVG\Nodes\Shapes\SVGPolyline::class, + 'rect' => \SVG\Nodes\Shapes\SVGRect::class, - 'clipPath' => 'SVG\Nodes\Structures\SVGClipPath', - 'defs' => 'SVG\Nodes\Structures\SVGDefs', - 'svg' => 'SVG\Nodes\Structures\SVGDocumentFragment', - 'g' => 'SVG\Nodes\Structures\SVGGroup', - 'a' => 'SVG\Nodes\Structures\SVGLinkGroup', - 'marker' => 'SVG\Nodes\Structures\SVGMarker', - 'mask' => 'SVG\Nodes\Structures\SVGMask', - 'metadata' => 'SVG\Nodes\Structures\SVGMetadata', - 'pattern' => 'SVG\Nodes\Structures\SVGPattern', - 'script' => 'SVG\Nodes\Structures\SVGScript', - 'style' => 'SVG\Nodes\Structures\SVGStyle', - 'switch' => 'SVG\Nodes\Structures\SVGSwitch', - 'symbol' => 'SVG\Nodes\Structures\SVGSymbol', - 'use' => 'SVG\Nodes\Structures\SVGUse', + 'clipPath' => \SVG\Nodes\Structures\SVGClipPath::class, + 'defs' => \SVG\Nodes\Structures\SVGDefs::class, + 'svg' => \SVG\Nodes\Structures\SVGDocumentFragment::class, + 'g' => \SVG\Nodes\Structures\SVGGroup::class, + 'a' => \SVG\Nodes\Structures\SVGLinkGroup::class, + 'marker' => \SVG\Nodes\Structures\SVGMarker::class, + 'mask' => \SVG\Nodes\Structures\SVGMask::class, + 'metadata' => \SVG\Nodes\Structures\SVGMetadata::class, + 'pattern' => \SVG\Nodes\Structures\SVGPattern::class, + 'script' => \SVG\Nodes\Structures\SVGScript::class, + 'style' => \SVG\Nodes\Structures\SVGStyle::class, + 'switch' => \SVG\Nodes\Structures\SVGSwitch::class, + 'symbol' => \SVG\Nodes\Structures\SVGSymbol::class, + 'use' => \SVG\Nodes\Structures\SVGUse::class, - 'desc' => 'SVG\Nodes\Texts\SVGDesc', - 'text' => 'SVG\Nodes\Texts\SVGText', - 'textPath' => 'SVG\Nodes\Texts\SVGTextPath', - 'title' => 'SVG\Nodes\Texts\SVGTitle', - 'tspan' => 'SVG\Nodes\Texts\SVGTSpan', + 'desc' => \SVG\Nodes\Texts\SVGDesc::class, + 'text' => \SVG\Nodes\Texts\SVGText::class, + 'textPath' => \SVG\Nodes\Texts\SVGTextPath::class, + 'title' => \SVG\Nodes\Texts\SVGTitle::class, + 'tspan' => \SVG\Nodes\Texts\SVGTSpan::class, ]; /** diff --git a/src/Utilities/Colors/Color.php b/src/Utilities/Colors/Color.php index 5186475d..b8c4e9fd 100644 --- a/src/Utilities/Colors/Color.php +++ b/src/Utilities/Colors/Color.php @@ -25,11 +25,11 @@ public static function parse(string $color): array // pass on to dedicated functions depending on notation if (preg_match('/^#([0-9A-F]+)$/i', $color, $matches)) { - list($r, $g, $b, $a) = self::parseHexComponents($matches[1]); + [$r, $g, $b, $a] = self::parseHexComponents($matches[1]); } elseif (preg_match('/^rgba?\((.*)\)$/', $color, $matches)) { - list($r, $g, $b, $a) = self::parseRGBAComponents($matches[1]); + [$r, $g, $b, $a] = self::parseRGBAComponents($matches[1]); } elseif (preg_match('/^hsla?\((.*)\)$/', $color, $matches)) { - list($r, $g, $b, $a) = self::parseHSLAComponents($matches[1]); + [$r, $g, $b, $a] = self::parseHSLAComponents($matches[1]); } // any illegal component invalidates all components @@ -176,7 +176,7 @@ private static function parseHSLAComponents(string $str): array // convert HSL to RGB $r = $g = $b = null; if (isset($h) && isset($s) && isset($l)) { - list($r, $g, $b) = self::convertHSLtoRGB($h, $s, $l); + [$r, $g, $b] = self::convertHSLtoRGB($h, $s, $l); } // add alpha $a = count($params) < 4 ? 255 : self::parseRGBAComponent($params[3], 1, 255); diff --git a/tests/Nodes/Embedded/SVGImageTest.php b/tests/Nodes/Embedded/SVGImageTest.php index 564f6e93..7a8e5507 100644 --- a/tests/Nodes/Embedded/SVGImageTest.php +++ b/tests/Nodes/Embedded/SVGImageTest.php @@ -15,7 +15,7 @@ class SVGImageTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should not set any attributes by default $obj = new SVGImage(); @@ -35,7 +35,7 @@ public function test__construct() /** * @covers ::getHref */ - public function testGetHref() + public function testGetHref(): void { // should return xlink:href when available $obj = new SVGImage(); @@ -56,7 +56,7 @@ public function testGetHref() /** * @covers ::setHref */ - public function testSetHref() + public function testSetHref(): void { $obj = new SVGImage(); @@ -71,7 +71,7 @@ public function testSetHref() /** * @covers ::getX */ - public function testGetX() + public function testGetX(): void { $obj = new SVGImage(); @@ -83,7 +83,7 @@ public function testGetX() /** * @covers ::setX */ - public function testSetX() + public function testSetX(): void { $obj = new SVGImage(); @@ -98,7 +98,7 @@ public function testSetX() /** * @covers ::getY */ - public function testGetY() + public function testGetY(): void { $obj = new SVGImage(); @@ -110,7 +110,7 @@ public function testGetY() /** * @covers ::setY */ - public function testSetY() + public function testSetY(): void { $obj = new SVGImage(); @@ -125,7 +125,7 @@ public function testSetY() /** * @covers ::getWidth */ - public function testGetWidth() + public function testGetWidth(): void { $obj = new SVGImage(); @@ -137,7 +137,7 @@ public function testGetWidth() /** * @covers ::setWidth */ - public function testSetWidth() + public function testSetWidth(): void { $obj = new SVGImage(); @@ -152,7 +152,7 @@ public function testSetWidth() /** * @covers ::getHeight */ - public function testGetHeight() + public function testGetHeight(): void { $obj = new SVGImage(); @@ -164,7 +164,7 @@ public function testGetHeight() /** * @covers ::setHeight */ - public function testSetHeight() + public function testSetHeight(): void { $obj = new SVGImage(); @@ -179,11 +179,11 @@ public function testSetHeight() /** * @covers ::rasterize */ - public function testRasterize() + public function testRasterize(): void { $obj = new SVGImage('test-href', 10, 10, 100, 100); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/SVGNodeContainerTest.php b/tests/Nodes/SVGNodeContainerTest.php index e5c415d0..90c297cf 100644 --- a/tests/Nodes/SVGNodeContainerTest.php +++ b/tests/Nodes/SVGNodeContainerTest.php @@ -6,7 +6,7 @@ class SVGNodeContainerSubclass extends SVGNodeContainer { - const TAG_NAME = 'test_subclass'; + public const TAG_NAME = 'test_subclass'; } /** @@ -21,7 +21,7 @@ class SVGNodeContainerTest extends \PHPUnit\Framework\TestCase /** * @covers ::addChild */ - public function testAddChild() + public function testAddChild(): void { $obj = new SVGNodeContainerSubclass(); $obj2 = new SVGNodeContainerSubclass(); @@ -67,7 +67,7 @@ public function testAddChild() /** * @covers ::removeChild */ - public function testRemoveChild() + public function testRemoveChild(): void { $obj = new SVGNodeContainerSubclass(); $child = new SVGNodeContainerSubclass(); @@ -97,7 +97,7 @@ public function testRemoveChild() /** * @covers ::setChild */ - public function testSetChild() + public function testSetChild(): void { $obj = new SVGNodeContainerSubclass(); $obj2 = new SVGNodeContainerSubclass(); @@ -129,14 +129,14 @@ public function testSetChild() /** * @covers ::rasterize */ - public function testRasterize() + public function testRasterize(): void { $obj = new SVGNodeContainerSubclass(); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $obj->addChild($mockChild); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -152,7 +152,7 @@ public function testRasterize() /** * @covers ::getElementsByTagName */ - public function testGetElementsByTagName() + public function testGetElementsByTagName(): void { $obj = new SVGNodeContainerSubclass(); $root_0 = new \SVG\Nodes\Structures\SVGGroup(); @@ -198,7 +198,7 @@ public function testGetElementsByTagName() /** * @covers ::getElementsByClassName */ - public function testGetElementsByClassName() + public function testGetElementsByClassName(): void { $obj = new SVGNodeContainerSubclass(); $root_0 = new \SVG\Nodes\Structures\SVGGroup(); @@ -261,11 +261,11 @@ public function testGetElementsByClassName() /** * @covers ::getContainerStyleForNode */ - public function testGetContainerStyleForNode() + public function testGetContainerStyleForNode(): void { $obj = new SVGNodeContainerSubclass(); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $obj->addChild($mockChild); $this->assertCount(0, $obj->getContainerStyleForNode($mockChild)); @@ -274,11 +274,11 @@ public function testGetContainerStyleForNode() /** * @covers ::getContainerStyleByPattern */ - public function testGetContainerStyleByPattern() + public function testGetContainerStyleByPattern(): void { $obj = new SVGNodeContainerSubclass(); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $obj->addChild($mockChild); $this->assertCount(0, $obj->getContainerStyleByPattern('/^(\d+)?\.\d+$/')); diff --git a/tests/Nodes/SVGNodeTest.php b/tests/Nodes/SVGNodeTest.php index a32492d1..4329335d 100644 --- a/tests/Nodes/SVGNodeTest.php +++ b/tests/Nodes/SVGNodeTest.php @@ -6,7 +6,7 @@ class SVGNodeSubclass extends SVGNode { - const TAG_NAME = 'test_subclass'; + public const TAG_NAME = 'test_subclass'; /** * @inheritdoc @@ -28,7 +28,7 @@ class SVGNodeTest extends \PHPUnit\Framework\TestCase /** * @covers ::getName */ - public function testGetName() + public function testGetName(): void { $obj = new SVGNodeSubclass(); @@ -39,7 +39,7 @@ public function testGetName() /** * @covers ::getParent */ - public function testGetParent() + public function testGetParent(): void { $obj = new SVGNodeSubclass(); @@ -50,7 +50,7 @@ public function testGetParent() /** * @covers ::getValue */ - public function testGetValue() + public function testGetValue(): void { $obj = new SVGNodeSubclass(); @@ -61,7 +61,7 @@ public function testGetValue() /** * @covers ::setValue */ - public function testSetValue() + public function testSetValue(): void { $obj = new SVGNodeSubclass(); @@ -80,7 +80,7 @@ public function testSetValue() /** * @covers ::getStyle */ - public function testGetStyle() + public function testGetStyle(): void { $obj = new SVGNodeSubclass(); @@ -91,7 +91,7 @@ public function testGetStyle() /** * @covers ::setStyle */ - public function testSetStyle() + public function testSetStyle(): void { $obj = new SVGNodeSubclass(); @@ -134,7 +134,7 @@ public function testSetStyle() /** * @covers ::removeStyle */ - public function testRemoveStyle() + public function testRemoveStyle(): void { $obj = new SVGNodeSubclass(); @@ -150,7 +150,7 @@ public function testRemoveStyle() /** * @covers ::getAttribute */ - public function testGetAttribute() + public function testGetAttribute(): void { $obj = new SVGNodeSubclass(); @@ -161,7 +161,7 @@ public function testGetAttribute() /** * @covers ::setAttribute */ - public function testSetAttribute() + public function testSetAttribute(): void { $obj = new SVGNodeSubclass(); @@ -193,7 +193,7 @@ public function testSetAttribute() /** * @covers ::removeAttribute */ - public function testRemoveAttribute() + public function testRemoveAttribute(): void { $obj = new SVGNodeSubclass(); @@ -209,7 +209,7 @@ public function testRemoveAttribute() /** * @covers ::getSerializableNamespaces */ - public function testGetSerializableNamespaces() + public function testGetSerializableNamespaces(): void { $obj = new SVGNodeSubclass(); @@ -224,7 +224,7 @@ public function testGetSerializableNamespaces() /** * @covers ::getSerializableAttributes */ - public function testGetSerializableAttributes() + public function testGetSerializableAttributes(): void { $obj = new SVGNodeSubclass(); @@ -242,7 +242,7 @@ public function testGetSerializableAttributes() /** * @covers ::getSerializableStyles */ - public function testGetSerializableStyles() + public function testGetSerializableStyles(): void { $obj = new SVGNodeSubclass(); @@ -258,7 +258,7 @@ public function testGetSerializableStyles() /** * @covers ::getViewBox */ - public function testGetViewBox() + public function testGetViewBox(): void { $obj = new SVGNodeSubclass(); diff --git a/tests/Nodes/Shapes/SVGCircleTest.php b/tests/Nodes/Shapes/SVGCircleTest.php index f10d34ba..4afd3ba5 100644 --- a/tests/Nodes/Shapes/SVGCircleTest.php +++ b/tests/Nodes/Shapes/SVGCircleTest.php @@ -15,7 +15,7 @@ class SVGCircleTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should not set any attributes by default $obj = new SVGCircle(); @@ -33,7 +33,7 @@ public function test__construct() /** * @covers ::getCenterX */ - public function testGetCenterX() + public function testGetCenterX(): void { $obj = new SVGCircle(); @@ -45,7 +45,7 @@ public function testGetCenterX() /** * @covers ::setCenterX */ - public function testSetCenterX() + public function testSetCenterX(): void { $obj = new SVGCircle(); @@ -60,7 +60,7 @@ public function testSetCenterX() /** * @covers ::getCenterY */ - public function testGetCenterY() + public function testGetCenterY(): void { $obj = new SVGCircle(); @@ -72,7 +72,7 @@ public function testGetCenterY() /** * @covers ::setCenterY */ - public function testSetCenterY() + public function testSetCenterY(): void { $obj = new SVGCircle(); @@ -87,7 +87,7 @@ public function testSetCenterY() /** * @covers ::getRadius */ - public function testGetRadius() + public function testGetRadius(): void { $obj = new SVGCircle(); @@ -99,7 +99,7 @@ public function testGetRadius() /** * @covers ::setRadius */ - public function testSetRadius() + public function testSetRadius(): void { $obj = new SVGCircle(); @@ -114,11 +114,11 @@ public function testSetRadius() /** * @covers ::rasterize */ - public function testRasterize() + public function testRasterize(): void { $obj = new SVGCircle(37, 42, 100); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGEllipseTest.php b/tests/Nodes/Shapes/SVGEllipseTest.php index ba7903fc..97b516ee 100644 --- a/tests/Nodes/Shapes/SVGEllipseTest.php +++ b/tests/Nodes/Shapes/SVGEllipseTest.php @@ -15,7 +15,7 @@ class SVGEllipseTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should not set any attributes by default $obj = new SVGEllipse(); @@ -34,7 +34,7 @@ public function test__construct() /** * @covers ::getCenterX */ - public function testGetCenterX() + public function testGetCenterX(): void { $obj = new SVGEllipse(); @@ -46,7 +46,7 @@ public function testGetCenterX() /** * @covers ::setCenterX */ - public function testSetCenterX() + public function testSetCenterX(): void { $obj = new SVGEllipse(); @@ -61,7 +61,7 @@ public function testSetCenterX() /** * @covers ::getCenterY */ - public function testGetCenterY() + public function testGetCenterY(): void { $obj = new SVGEllipse(); @@ -73,7 +73,7 @@ public function testGetCenterY() /** * @covers ::setCenterY */ - public function testSetCenterY() + public function testSetCenterY(): void { $obj = new SVGEllipse(); @@ -88,7 +88,7 @@ public function testSetCenterY() /** * @covers ::getRadiusX */ - public function testGetRadiusX() + public function testGetRadiusX(): void { $obj = new SVGEllipse(); @@ -100,7 +100,7 @@ public function testGetRadiusX() /** * @covers ::setRadiusX */ - public function testSetRadiusX() + public function testSetRadiusX(): void { $obj = new SVGEllipse(); @@ -115,7 +115,7 @@ public function testSetRadiusX() /** * @covers ::getRadiusY */ - public function testGetRadiusY() + public function testGetRadiusY(): void { $obj = new SVGEllipse(); @@ -127,7 +127,7 @@ public function testGetRadiusY() /** * @covers ::setRadiusY */ - public function testSetRadiusY() + public function testSetRadiusY(): void { $obj = new SVGEllipse(); @@ -142,11 +142,11 @@ public function testSetRadiusY() /** * @covers ::rasterize */ - public function testRasterize() + public function testRasterize(): void { $obj = new SVGEllipse(37, 42, 100, 200); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGLineTest.php b/tests/Nodes/Shapes/SVGLineTest.php index d5160bf7..a52be623 100644 --- a/tests/Nodes/Shapes/SVGLineTest.php +++ b/tests/Nodes/Shapes/SVGLineTest.php @@ -15,7 +15,7 @@ class SVGLineTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should not set any attributes by default $obj = new SVGLine(); @@ -34,7 +34,7 @@ public function test__construct() /** * @covers ::getX1 */ - public function testGetX1() + public function testGetX1(): void { $obj = new SVGLine(); @@ -46,7 +46,7 @@ public function testGetX1() /** * @covers ::setX1 */ - public function testSetX1() + public function testSetX1(): void { $obj = new SVGLine(); @@ -61,7 +61,7 @@ public function testSetX1() /** * @covers ::getY1 */ - public function testGetY1() + public function testGetY1(): void { $obj = new SVGLine(); @@ -73,7 +73,7 @@ public function testGetY1() /** * @covers ::setY1 */ - public function testSetY1() + public function testSetY1(): void { $obj = new SVGLine(); @@ -88,7 +88,7 @@ public function testSetY1() /** * @covers ::getX2 */ - public function testGetX2() + public function testGetX2(): void { $obj = new SVGLine(); @@ -100,7 +100,7 @@ public function testGetX2() /** * @covers ::setX2 */ - public function testSetX2() + public function testSetX2(): void { $obj = new SVGLine(); @@ -115,7 +115,7 @@ public function testSetX2() /** * @covers ::getY2 */ - public function testGetY2() + public function testGetY2(): void { $obj = new SVGLine(); @@ -127,7 +127,7 @@ public function testGetY2() /** * @covers ::setY2 */ - public function testSetY2() + public function testSetY2(): void { $obj = new SVGLine(); @@ -142,11 +142,11 @@ public function testSetY2() /** * @covers ::rasterize */ - public function testRasterize() + public function testRasterize(): void { $obj = new SVGLine(11, 12, 13, 14); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGPathTest.php b/tests/Nodes/Shapes/SVGPathTest.php index a41284e0..565fdff9 100644 --- a/tests/Nodes/Shapes/SVGPathTest.php +++ b/tests/Nodes/Shapes/SVGPathTest.php @@ -24,7 +24,7 @@ class SVGPathTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should not set any attributes by default $obj = new SVGPath(); @@ -40,7 +40,7 @@ public function test__construct() /** * @covers ::getDescription */ - public function testGetDescription() + public function testGetDescription(): void { $obj = new SVGPath(); @@ -52,7 +52,7 @@ public function testGetDescription() /** * @covers ::setDescription */ - public function testSetDescription() + public function testSetDescription(): void { $obj = new SVGPath(); @@ -67,11 +67,11 @@ public function testSetDescription() /** * @covers ::rasterize */ - public function testRasterizeWithNull() + public function testRasterizeWithNull(): void { $obj = new SVGPath(); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -83,12 +83,12 @@ public function testRasterizeWithNull() /** * @covers ::rasterize */ - public function testRasterize() + public function testRasterize(): void { $obj = new SVGPath(self::$sampleDescription); // setup mocks - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -118,7 +118,7 @@ public function testRasterize() /** * @covers ::rasterize */ - public function testRasterizeShouldRespectFillRule() + public function testRasterizeShouldRespectFillRule(): void { $obj = new SVGPath(self::$sampleDescription); @@ -134,7 +134,7 @@ public function testRasterizeShouldRespectFillRule() 'foo' => 'foo', ]; foreach ($attributeToExpectedFillRule as $attribute => $expectedFillRule) { - $rasterizer = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rasterizer = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGPolygonTest.php b/tests/Nodes/Shapes/SVGPolygonTest.php index 3d23d29c..d0ea770a 100644 --- a/tests/Nodes/Shapes/SVGPolygonTest.php +++ b/tests/Nodes/Shapes/SVGPolygonTest.php @@ -15,7 +15,7 @@ class SVGPolygonTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should set empty points by default $obj = new SVGPolygon(); @@ -33,7 +33,7 @@ public function test__construct() /** * @covers ::rasterize */ - public function testRasterize() + public function testRasterize(): void { $points = [ [42.5, 42.5], @@ -42,7 +42,7 @@ public function testRasterize() $obj = new SVGPolygon($points); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -73,7 +73,7 @@ public function testRasterize() /** * @covers ::rasterize */ - public function testRasterizeShouldRespectFillRule() + public function testRasterizeShouldRespectFillRule(): void { $points = [ [42.5, 42.5], @@ -94,7 +94,7 @@ public function testRasterizeShouldRespectFillRule() 'foo' => 'foo', ]; foreach ($attributeToExpectedFillRule as $attribute => $expectedFillRule) { - $rasterizer = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rasterizer = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGPolygonalShapeTest.php b/tests/Nodes/Shapes/SVGPolygonalShapeTest.php index 63339ad5..26b0b5af 100644 --- a/tests/Nodes/Shapes/SVGPolygonalShapeTest.php +++ b/tests/Nodes/Shapes/SVGPolygonalShapeTest.php @@ -9,7 +9,7 @@ */ class SVGPolygonalShapeSubclass extends SVGPolygonalShape { - const TAG_NAME = 'test_subclass'; + public const TAG_NAME = 'test_subclass'; public function __construct(array $points = null) { @@ -32,7 +32,7 @@ class SVGPolygonalShapeTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should not set attribute if nothing is provided $obj = new SVGPolygonalShapeSubclass(); @@ -62,7 +62,7 @@ public function test__construct() /** * @covers ::addPoint */ - public function testAddPoint() + public function testAddPoint(): void { $obj = new SVGPolygonalShapeSubclass(); @@ -91,7 +91,7 @@ public function testAddPoint() /** * @covers ::removePoint */ - public function testRemovePoint() + public function testRemovePoint(): void { $obj = new SVGPolygonalShapeSubclass([ [42.5, 43.5], @@ -121,7 +121,7 @@ public function testRemovePoint() /** * @covers ::countPoints */ - public function testCountPoints() + public function testCountPoints(): void { $obj = new SVGPolygonalShapeSubclass([ [42.5, 43.5], @@ -155,7 +155,7 @@ public function testCountPoints() /** * @covers ::getPoints */ - public function testGetPoints() + public function testGetPoints(): void { $obj = new SVGPolygonalShapeSubclass(); @@ -187,7 +187,7 @@ public function testGetPoints() /** * @covers ::getPoint */ - public function testGetPoint() + public function testGetPoint(): void { $obj = new SVGPolygonalShapeSubclass([ [42.5, 43.5], @@ -202,7 +202,7 @@ public function testGetPoint() /** * @covers ::setPoint */ - public function testSetPoint() + public function testSetPoint(): void { $obj = new SVGPolygonalShapeSubclass([ [42.5, 43.5], diff --git a/tests/Nodes/Shapes/SVGPolylineTest.php b/tests/Nodes/Shapes/SVGPolylineTest.php index cfa139ef..8313a4db 100644 --- a/tests/Nodes/Shapes/SVGPolylineTest.php +++ b/tests/Nodes/Shapes/SVGPolylineTest.php @@ -15,7 +15,7 @@ class SVGPolylineTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should set empty points by default $obj = new SVGPolyline(); @@ -33,7 +33,7 @@ public function test__construct() /** * @covers ::rasterize */ - public function testRasterize() + public function testRasterize(): void { $points = [ [42.5, 42.5], @@ -42,7 +42,7 @@ public function testRasterize() $obj = new SVGPolyline($points); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -73,7 +73,7 @@ public function testRasterize() /** * @covers ::rasterize */ - public function testRasterizeShouldRespectFillRule() + public function testRasterizeShouldRespectFillRule(): void { $points = [ [42.5, 42.5], @@ -94,7 +94,7 @@ public function testRasterizeShouldRespectFillRule() 'foo' => 'foo', ]; foreach ($attributeToExpectedFillRule as $attribute => $expectedFillRule) { - $rasterizer = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rasterizer = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGRectTest.php b/tests/Nodes/Shapes/SVGRectTest.php index f24b92c2..1f56a75a 100644 --- a/tests/Nodes/Shapes/SVGRectTest.php +++ b/tests/Nodes/Shapes/SVGRectTest.php @@ -15,7 +15,7 @@ class SVGRectTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should not set any attributes by default $obj = new SVGRect(); @@ -34,7 +34,7 @@ public function test__construct() /** * @covers ::getX */ - public function testGetX() + public function testGetX(): void { $obj = new SVGRect(); @@ -46,7 +46,7 @@ public function testGetX() /** * @covers ::setX */ - public function testSetX() + public function testSetX(): void { $obj = new SVGRect(); @@ -61,7 +61,7 @@ public function testSetX() /** * @covers ::getY */ - public function testGetY() + public function testGetY(): void { $obj = new SVGRect(); @@ -73,7 +73,7 @@ public function testGetY() /** * @covers ::setY */ - public function testSetY() + public function testSetY(): void { $obj = new SVGRect(); @@ -88,7 +88,7 @@ public function testSetY() /** * @covers ::getWidth */ - public function testGetWidth() + public function testGetWidth(): void { $obj = new SVGRect(); @@ -100,7 +100,7 @@ public function testGetWidth() /** * @covers ::setWidth */ - public function testSetWidth() + public function testSetWidth(): void { $obj = new SVGRect(); @@ -115,7 +115,7 @@ public function testSetWidth() /** * @covers ::getHeight */ - public function testGetHeight() + public function testGetHeight(): void { $obj = new SVGRect(); @@ -127,7 +127,7 @@ public function testGetHeight() /** * @covers ::setHeight */ - public function testSetHeight() + public function testSetHeight(): void { $obj = new SVGRect(); @@ -142,7 +142,7 @@ public function testSetHeight() /** * @covers ::getRX */ - public function testGetRX() + public function testGetRX(): void { $obj = new SVGRect(); @@ -154,7 +154,7 @@ public function testGetRX() /** * @covers ::setRX */ - public function testSetRX() + public function testSetRX(): void { $obj = new SVGRect(); @@ -169,7 +169,7 @@ public function testSetRX() /** * @covers ::getRY */ - public function testGetRY() + public function testGetRY(): void { $obj = new SVGRect(); @@ -181,7 +181,7 @@ public function testGetRY() /** * @covers ::setRY */ - public function testSetRY() + public function testSetRY(): void { $obj = new SVGRect(); @@ -196,13 +196,13 @@ public function testSetRY() /** * @covers ::rasterize */ - public function testRasterize() + public function testRasterize(): void { $obj = new SVGRect(37, 42, 100, 200); $obj->setAttribute('rx', 15); $obj->setAttribute('ry', 25); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Structures/SVGDefsTest.php b/tests/Nodes/Structures/SVGDefsTest.php index 00a6e166..08256b9d 100644 --- a/tests/Nodes/Structures/SVGDefsTest.php +++ b/tests/Nodes/Structures/SVGDefsTest.php @@ -15,7 +15,7 @@ class SVGDefsTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should not set any attributes by default $obj = new SVGDefs(); @@ -25,14 +25,14 @@ public function test__construct() /** * @covers ::rasterize */ - public function testRasterize() + public function testRasterize(): void { $obj = new SVGDefs(); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $obj->addChild($mockChild); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Structures/SVGDocumentFragmentTest.php b/tests/Nodes/Structures/SVGDocumentFragmentTest.php index 7deba0a5..540280f2 100644 --- a/tests/Nodes/Structures/SVGDocumentFragmentTest.php +++ b/tests/Nodes/Structures/SVGDocumentFragmentTest.php @@ -16,7 +16,7 @@ class SVGDocumentFragmentTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { $container = new \SVG\Nodes\Structures\SVGGroup(); @@ -34,7 +34,7 @@ public function test__construct() /** * @covers ::isRoot */ - public function testIsRoot() + public function testIsRoot(): void { // should return true by default $obj = new SVGDocumentFragment(); @@ -49,7 +49,7 @@ public function testIsRoot() /** * @covers ::getWidth */ - public function testGetWidth() + public function testGetWidth(): void { $obj = new SVGDocumentFragment(); @@ -61,7 +61,7 @@ public function testGetWidth() /** * @covers ::setWidth */ - public function testSetWidth() + public function testSetWidth(): void { $obj = new SVGDocumentFragment(); @@ -76,7 +76,7 @@ public function testSetWidth() /** * @covers ::getHeight */ - public function testGetHeight() + public function testGetHeight(): void { $obj = new SVGDocumentFragment(); @@ -88,7 +88,7 @@ public function testGetHeight() /** * @covers ::setHeight */ - public function testSetHeight() + public function testSetHeight(): void { $obj = new SVGDocumentFragment(); @@ -103,7 +103,7 @@ public function testSetHeight() /** * @covers ::getComputedStyle */ - public function testGetComputedStyle() + public function testGetComputedStyle(): void { $obj = new SVGDocumentFragment(); @@ -125,7 +125,7 @@ public function testGetComputedStyle() /** * @covers ::getSerializableNamespaces */ - public function testGetSerializableNamespaces() + public function testGetSerializableNamespaces(): void { // should include 'xmlns' and 'xmlns:xlink' namespaces for root $obj = new SVGDocumentFragment(); @@ -161,7 +161,7 @@ public function testGetSerializableNamespaces() /** * @covers ::getSerializableAttributes */ - public function testGetSerializableAttributes() + public function testGetSerializableAttributes(): void { $container = new \SVG\Nodes\Structures\SVGGroup(); @@ -196,7 +196,7 @@ public function testGetSerializableAttributes() /** * @covers ::getElementById */ - public function testGetElementById() + public function testGetElementById(): void { // should return null if not found $obj = new SVGDocumentFragment(); @@ -211,14 +211,14 @@ public function testGetElementById() $obj = new SVGDocumentFragment(); $obj->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNodeContainer')->addChild( + $this->getMockForAbstractClass(\SVG\Nodes\SVGNodeContainer::class)->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNode') + $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class) )->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNodeContainer')->addChild( + $this->getMockForAbstractClass(\SVG\Nodes\SVGNodeContainer::class)->addChild( // - $expected = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode') + $expected = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class) ->setAttribute('id', 'foobar') ) // @@ -227,9 +227,9 @@ public function testGetElementById() ); $obj->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNodeContainer')->addChild( + $this->getMockForAbstractClass(\SVG\Nodes\SVGNodeContainer::class)->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNode') + $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class) ->setAttribute('id', 'foobar') ) // @@ -243,7 +243,7 @@ public function testGetElementById() * @requires extension gd * @coversNothing */ - public function testRasterize_empty() + public function testRasterize_empty(): void { $obj = new SVGDocumentFragment('2px', '2px'); @@ -264,7 +264,7 @@ public function testRasterize_empty() * @requires extension gd * @coversNothing */ - public function testRasterize_object_unscaled() + public function testRasterize_object_unscaled(): void { $obj = new SVGDocumentFragment('20px', '40px'); @@ -289,7 +289,7 @@ public function testRasterize_object_unscaled() * @requires extension gd * @coversNothing */ - public function testRasterize_object_scaledUp() + public function testRasterize_object_scaledUp(): void { $obj = new SVGDocumentFragment('10px', '20px'); @@ -314,7 +314,7 @@ public function testRasterize_object_scaledUp() * @requires extension gd * @coversNothing */ - public function testRasterize_object_scaledDown() + public function testRasterize_object_scaledDown(): void { $obj = new SVGDocumentFragment('40px', '80px'); @@ -339,7 +339,7 @@ public function testRasterize_object_scaledDown() * @requires extension gd * @coversNothing */ - public function testRasterize_object_viewBox() + public function testRasterize_object_viewBox(): void { $obj = new SVGDocumentFragment('100%', '100%'); $obj->setAttribute('viewBox', '100 100 2 4'); diff --git a/tests/Nodes/Structures/SVGScriptTest.php b/tests/Nodes/Structures/SVGScriptTest.php index 4b4ba884..1a9f21d9 100644 --- a/tests/Nodes/Structures/SVGScriptTest.php +++ b/tests/Nodes/Structures/SVGScriptTest.php @@ -14,7 +14,7 @@ class SVGScriptTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should default to empty CSS, type = text/css $obj = new SVGScript(); @@ -28,11 +28,11 @@ public function test__construct() /** * @covers ::rasterize */ - public function testRasterize() + public function testRasterize(): void { $obj = new SVGScript(); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Structures/SVGStyleTest.php b/tests/Nodes/Structures/SVGStyleTest.php index 161d30ac..15fb73e3 100644 --- a/tests/Nodes/Structures/SVGStyleTest.php +++ b/tests/Nodes/Structures/SVGStyleTest.php @@ -14,7 +14,7 @@ class SVGStyleTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should default to empty CSS, type = text/css $obj = new SVGStyle(); @@ -30,7 +30,7 @@ public function test__construct() /** * @covers ::getType */ - public function testGetType() + public function testGetType(): void { $obj = new SVGStyle(); $obj->setAttribute('type', 'test-type'); @@ -41,10 +41,10 @@ public function testGetType() /** * @covers ::setType */ - public function testSetType() + public function testSetType(): void { $obj = new SVGStyle(); - $this->assertInstanceOf('SVG\Nodes\Structures\SVGStyle', $obj->setType('test-type')); + $this->assertInstanceOf(\SVG\Nodes\Structures\SVGStyle::class, $obj->setType('test-type')); $this->assertEquals('test-type', $obj->getAttribute('type')); @@ -54,11 +54,11 @@ public function testSetType() /** * @covers ::rasterize */ - public function testRasterize() + public function testRasterize(): void { $obj = new SVGStyle(); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Texts/SVGTextTest.php b/tests/Nodes/Texts/SVGTextTest.php index b0f38b10..9dc59f98 100644 --- a/tests/Nodes/Texts/SVGTextTest.php +++ b/tests/Nodes/Texts/SVGTextTest.php @@ -15,13 +15,13 @@ class SVGTextTest extends \PHPUnit\Framework\TestCase /** * @covers ::rasterize */ - public function testRasterizeShouldHaveDefaultFontSize() + public function testRasterizeShouldHaveDefaultFontSize(): void { // Test for https://github.com/meyfa/php-svg/issues/195 $obj = new SVGText('foo', 10, 10); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(\SVG\Rasterization\SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Rasterization/Path/ArcApproximatorTest.php b/tests/Rasterization/Path/ArcApproximatorTest.php index 75efdbea..2c03ee69 100644 --- a/tests/Rasterization/Path/ArcApproximatorTest.php +++ b/tests/Rasterization/Path/ArcApproximatorTest.php @@ -11,7 +11,7 @@ */ class ArcApproximatorTest extends \PHPUnit\Framework\TestCase { - public function testApproximate() + public function testApproximate(): void { $approx = new ArcApproximator(); $p0 = [10.5, 10.5]; @@ -27,7 +27,7 @@ public function testApproximate() $this->assertCount(0, $result); } - public function testApproximateWithXaIsLessThanZero() + public function testApproximateWithXaIsLessThanZero(): void { $approx = new ArcApproximator(); $p0 = [10.5, 10.5]; @@ -43,7 +43,7 @@ public function testApproximateWithXaIsLessThanZero() $this->assertCount(0, $result); } - public function testApproximateWithRxAndRyAreZero() + public function testApproximateWithRxAndRyAreZero(): void { $approx = new ArcApproximator(); $p0 = [10.5, 10.5]; @@ -62,7 +62,7 @@ public function testApproximateWithRxAndRyAreZero() $this->assertSame(10.6, $result[1][1]); } - public function testApproximateWithRxAndRyAreNotZero() + public function testApproximateWithRxAndRyAreNotZero(): void { $approx = new ArcApproximator(); $p0 = [10.5, 10.5]; @@ -83,7 +83,7 @@ public function testApproximateWithRxAndRyAreNotZero() $this->assertEqualsWithDelta(10.6, $result[2][1], 10e-12); } - public function testApproximateFlags() + public function testApproximateFlags(): void { $approx = new ArcApproximator(); $p0 = [10, 10]; @@ -122,7 +122,7 @@ public function testApproximateFlags() $this->assertEqualsWithDelta(-8.65, $result[count($result) / 2][1], 0.5); } - public function testApproximateRadiusScaling() + public function testApproximateRadiusScaling(): void { $approx = new ArcApproximator(); $p0 = [10, 10]; diff --git a/tests/Rasterization/Path/BezierApproximatorTest.php b/tests/Rasterization/Path/BezierApproximatorTest.php index 6a105abe..d88197f5 100644 --- a/tests/Rasterization/Path/BezierApproximatorTest.php +++ b/tests/Rasterization/Path/BezierApproximatorTest.php @@ -11,7 +11,7 @@ */ class BezierApproximatorTest extends \PHPUnit\Framework\TestCase { - public function testQuadratic() + public function testQuadratic(): void { $bezier = new BezierApproximator(); $p0 = [20, 10]; @@ -26,7 +26,7 @@ public function testQuadratic() $this->assertEqualsWithDelta(20, $result[$n - 1][1], 1); } - public function testCubic() + public function testCubic(): void { $bezier = new BezierApproximator(); $p0 = [20, 10]; diff --git a/tests/Rasterization/Path/PathApproximatorTest.php b/tests/Rasterization/Path/PathApproximatorTest.php index 41992958..e5eb851e 100644 --- a/tests/Rasterization/Path/PathApproximatorTest.php +++ b/tests/Rasterization/Path/PathApproximatorTest.php @@ -14,7 +14,7 @@ class PathApproximatorTest extends \PHPUnit\Framework\TestCase { // general tests - public function testApproximate() + public function testApproximate(): void { $approx = new PathApproximator(Transform::identity()); $cmds = [ @@ -35,7 +35,7 @@ public function testApproximate() ], $result); } - public function testApproximateWithTransform() + public function testApproximateWithTransform(): void { $transform = Transform::identity(); $transform->scale(3, 5); @@ -59,7 +59,7 @@ public function testApproximateWithTransform() ], $result); } - public function testApproximateStopsAtInvalidCommand() + public function testApproximateStopsAtInvalidCommand(): void { $approx = new PathApproximator(Transform::identity()); $cmds = [ @@ -82,7 +82,7 @@ public function testApproximateStopsAtInvalidCommand() // tests more specific to each path command - public function testMoveTo() + public function testMoveTo(): void { // https://www.w3.org/TR/SVG/paths.html#PathDataMovetoCommands // "A path data segment (if there is one) must begin with a "moveto" command." @@ -106,7 +106,7 @@ public function testMoveTo() $this->assertSame([], $approx->getSubpaths()); } - public function testLineTo() + public function testLineTo(): void { $approx = new PathApproximator(Transform::identity()); $approx->approximate([ @@ -155,7 +155,7 @@ public function testLineTo() ], $approx->getSubpaths()); } - public function testLineToHorizontal() + public function testLineToHorizontal(): void { $approx = new PathApproximator(Transform::identity()); $approx->approximate([ @@ -190,7 +190,7 @@ public function testLineToHorizontal() ], $approx->getSubpaths()); } - public function testLineToVertical() + public function testLineToVertical(): void { $approx = new PathApproximator(Transform::identity()); $approx->approximate([ @@ -225,7 +225,7 @@ public function testLineToVertical() ], $approx->getSubpaths()); } - public function testCurveToCubic() + public function testCurveToCubic(): void { // Simple test: draw cubic curves representing straight lines $approx = new PathApproximator(Transform::identity()); @@ -249,16 +249,16 @@ public function testCurveToCubic() $this->assertLessThan(0.6 * count($subpaths[0]), $corner); // expect everything before to be a straight horizontal line for ($i = 1; $i <= $corner; ++$i) { - list($xPrev, $yPrev) = $subpaths[0][$i - 1]; - list($x, $y) = $subpaths[0][$i]; + [$xPrev, $yPrev] = $subpaths[0][$i - 1]; + [$x, $y] = $subpaths[0][$i]; $this->assertGreaterThanOrEqual($xPrev, $x); $this->assertLessThanOrEqual(20, $x); $this->assertEquals($yPrev, $y); } // expect everything after to be a straight vertical line for ($i = $corner + 1; $i < count($subpaths[0]); ++$i) { - list($xPrev, $yPrev) = $subpaths[0][$i - 1]; - list($x, $y) = $subpaths[0][$i]; + [$xPrev, $yPrev] = $subpaths[0][$i - 1]; + [$x, $y] = $subpaths[0][$i]; $this->assertEquals($xPrev, $x); $this->assertGreaterThanOrEqual($yPrev, $y); $this->assertLessThanOrEqual(30, $y); @@ -278,7 +278,7 @@ public function testCurveToCubic() $this->assertLessThan(4.5 * count($subpaths[0]), count($subpaths2[0])); } - public function testCurveToCubicSmooth() + public function testCurveToCubicSmooth(): void { // without preceding CurveToCubic $approx = new PathApproximator(Transform::identity()); @@ -293,7 +293,7 @@ public function testCurveToCubicSmooth() $this->assertEquals([10, 20], $subpaths[0][0]); $this->assertEquals([20, 20], $subpaths[0][count($subpaths[0]) - 1]); // check center (the curve should bend downwards about halfway to the only control point) - list($x, $y) = $subpaths[0][ceil(count($subpaths[0]) / 2)]; + [$x, $y] = $subpaths[0][ceil(count($subpaths[0]) / 2)]; $this->assertEqualsWithDelta(15, $x, 1.0); $this->assertEqualsWithDelta(25, $y, 1.0); @@ -313,20 +313,20 @@ public function testCurveToCubicSmooth() $this->assertEquals([30, 20], $subpaths[0][count($subpaths[0]) - 1]); // The curve should first bend down due to 'C', then bend up due to the reflected 's'. // - check at 1/4 from beginning - list($x, $y) = $subpaths[0][ceil(count($subpaths[0]) * 0.25)]; + [$x, $y] = $subpaths[0][ceil(count($subpaths[0]) * 0.25)]; $this->assertEqualsWithDelta(15, $x, 1.0); $this->assertEqualsWithDelta(27.5, $y, 1.0); // - check at 1/2 from beginning - list($x, $y) = $subpaths[0][ceil(count($subpaths[0]) * 0.5)]; + [$x, $y] = $subpaths[0][ceil(count($subpaths[0]) * 0.5)]; $this->assertEqualsWithDelta(20, $x, 1.0); $this->assertEqualsWithDelta(20, $y, 1.0); // - check at 3/4 from beginning - list($x, $y) = $subpaths[0][ceil(count($subpaths[0]) * 0.75)]; + [$x, $y] = $subpaths[0][ceil(count($subpaths[0]) * 0.75)]; $this->assertEqualsWithDelta(25, $x, 1.0); $this->assertEqualsWithDelta(12.5, $y, 1.0); } - public function testCurveToQuadratic() + public function testCurveToQuadratic(): void { // Simple test: draw quadratic curves representing straight lines $approx = new PathApproximator(Transform::identity()); @@ -350,16 +350,16 @@ public function testCurveToQuadratic() $this->assertLessThan(0.6 * count($subpaths[0]), $corner); // expect everything before to be a straight horizontal line for ($i = 1; $i <= $corner; ++$i) { - list($xPrev, $yPrev) = $subpaths[0][$i - 1]; - list($x, $y) = $subpaths[0][$i]; + [$xPrev, $yPrev] = $subpaths[0][$i - 1]; + [$x, $y] = $subpaths[0][$i]; $this->assertGreaterThanOrEqual($xPrev, $x); $this->assertLessThanOrEqual(20, $x); $this->assertEqualsWithDelta($yPrev, $y, 10e-12); } // expect everything after to be a straight vertical line for ($i = $corner + 1; $i < count($subpaths[0]); ++$i) { - list($xPrev, $yPrev) = $subpaths[0][$i - 1]; - list($x, $y) = $subpaths[0][$i]; + [$xPrev, $yPrev] = $subpaths[0][$i - 1]; + [$x, $y] = $subpaths[0][$i]; $this->assertEqualsWithDelta($xPrev, $x, 10e-12); $this->assertGreaterThanOrEqual($yPrev, $y); $this->assertLessThanOrEqual(30, $y); @@ -379,7 +379,7 @@ public function testCurveToQuadratic() $this->assertLessThan(4.5 * count($subpaths[0]), count($subpaths2[0])); } - public function testCurveToQuadraticSmooth() + public function testCurveToQuadraticSmooth(): void { // without preceding CurveToQuadratic $approx = new PathApproximator(Transform::identity()); @@ -394,7 +394,7 @@ public function testCurveToQuadraticSmooth() $this->assertEquals([10, 20], $subpaths[0][0]); $this->assertEquals([20, 20], $subpaths[0][count($subpaths[0]) - 1]); // check center (the curve should represent a flat horizontal line) - list($x, $y) = $subpaths[0][ceil(count($subpaths[0]) / 2)]; + [$x, $y] = $subpaths[0][ceil(count($subpaths[0]) / 2)]; $this->assertEqualsWithDelta(15, $x, 1.0); $this->assertEqualsWithDelta(20, $y, 1.0); @@ -414,20 +414,20 @@ public function testCurveToQuadraticSmooth() $this->assertEquals([30, 20], $subpaths[0][count($subpaths[0]) - 1]); // The curve should first bend down due to 'Q', then bend up due to the reflected 't'. // - check at 1/4 from beginning - list($x, $y) = $subpaths[0][ceil(count($subpaths[0]) * 0.25)]; + [$x, $y] = $subpaths[0][ceil(count($subpaths[0]) * 0.25)]; $this->assertEqualsWithDelta(15, $x, 1.0); $this->assertEqualsWithDelta(25, $y, 1.0); // - check at 1/2 from beginning - list($x, $y) = $subpaths[0][ceil(count($subpaths[0]) * 0.5)]; + [$x, $y] = $subpaths[0][ceil(count($subpaths[0]) * 0.5)]; $this->assertEqualsWithDelta(20, $x, 1.0); $this->assertEqualsWithDelta(20, $y, 1.0); // - check at 3/4 from beginning - list($x, $y) = $subpaths[0][ceil(count($subpaths[0]) * 0.75)]; + [$x, $y] = $subpaths[0][ceil(count($subpaths[0]) * 0.75)]; $this->assertEqualsWithDelta(25, $x, 1.0); $this->assertEqualsWithDelta(15, $y, 1.0); } - public function testArcTo() + public function testArcTo(): void { // Run the following test once for the absolute command and once for the relative command. // The coordinates are chosen so that the output should be equal. @@ -449,14 +449,14 @@ public function testArcTo() $this->assertEquals([20, 20], $subpaths[0][count($subpaths[0]) - 1]); // points in between should have x >= 10 && x <= 20 and y >= 20, y <= 30 foreach ($subpaths[0] as $point) { - list($x, $y) = $point; + [$x, $y] = $point; $this->assertGreaterThanOrEqual(10, $x); $this->assertLessThanOrEqual(20, $x); $this->assertGreaterThanOrEqual(20, $y); $this->assertLessThanOrEqual(30, $y); } // midpoint should roughly be at [15, 30] - list($x, $y) = $subpaths[0][ceil(count($subpaths[0]) / 2)]; + [$x, $y] = $subpaths[0][ceil(count($subpaths[0]) / 2)]; $this->assertEqualsWithDelta(15, $x, 0.5); $this->assertEqualsWithDelta(30, $y, 0.5); } @@ -474,7 +474,7 @@ public function testArcTo() $this->assertLessThan(4.5 * count($subpaths[0]), count($subpaths2[0])); } - public function testClosePath() + public function testClosePath(): void { // try with both 'z' and 'Z', which should behave the same foreach (['z', 'Z'] as $closeCommand) { diff --git a/tests/Rasterization/Path/PathParserTest.php b/tests/Rasterization/Path/PathParserTest.php index 5d213274..b1a1992f 100644 --- a/tests/Rasterization/Path/PathParserTest.php +++ b/tests/Rasterization/Path/PathParserTest.php @@ -11,7 +11,7 @@ */ class PathParserTest extends \PHPUnit\Framework\TestCase { - public function testShouldSplitCorrectly() + public function testShouldSplitCorrectly(): void { $obj = new PathParser(); @@ -29,7 +29,7 @@ public function testShouldSplitCorrectly() ], $obj->parse(' M10,10 l +10 -10 h .5e2 v 100e-1 l7-7 h.5 z H0z')); } - public function testShouldSupportRepeatedCommands() + public function testShouldSupportRepeatedCommands(): void { $obj = new PathParser(); @@ -45,7 +45,7 @@ public function testShouldSupportRepeatedCommands() ], $obj->parse('L10,10 20,20 h 5 5 5 q 10 10 20 20 50 50 60 60')); } - public function testShouldTreatImplicitMoveToLikeLineTo() + public function testShouldTreatImplicitMoveToLikeLineTo(): void { $obj = new PathParser(); @@ -59,7 +59,7 @@ public function testShouldTreatImplicitMoveToLikeLineTo() ], $obj->parse('M10,10 20,20, 20,10 m-10,0 -10,-5')); } - public function testShouldAbortOnError() + public function testShouldAbortOnError(): void { $obj = new PathParser(); diff --git a/tests/Rasterization/Path/PolygonBuilderTest.php b/tests/Rasterization/Path/PolygonBuilderTest.php index 19d86971..9d1bb6e8 100644 --- a/tests/Rasterization/Path/PolygonBuilderTest.php +++ b/tests/Rasterization/Path/PolygonBuilderTest.php @@ -15,7 +15,7 @@ class PolygonBuilderTest extends \PHPUnit\Framework\TestCase /** * @covers ::__construct */ - public function test__construct() + public function test__construct(): void { // should set position to origin by default $obj = new PolygonBuilder(); @@ -29,7 +29,7 @@ public function test__construct() /** * @covers ::build */ - public function testBuild() + public function testBuild(): void { // should return an array of float 2-tuples $obj = new PolygonBuilder(); @@ -44,7 +44,7 @@ public function testBuild() /** * @covers ::getFirstPoint */ - public function testGetFirstPoint() + public function testGetFirstPoint(): void { $obj = new PolygonBuilder(); @@ -60,7 +60,7 @@ public function testGetFirstPoint() /** * @covers ::getLastPoint */ - public function testGetLastPoint() + public function testGetLastPoint(): void { $obj = new PolygonBuilder(); @@ -76,7 +76,7 @@ public function testGetLastPoint() /** * @covers ::getPosition */ - public function testGetPosition() + public function testGetPosition(): void { $obj = new PolygonBuilder(10, 20); @@ -91,7 +91,7 @@ public function testGetPosition() /** * @covers ::addPoint */ - public function testAddPoint() + public function testAddPoint(): void { $obj = new PolygonBuilder(); @@ -120,7 +120,7 @@ public function testAddPoint() /** * @covers ::addPointRelative */ - public function testAddPointRelative() + public function testAddPointRelative(): void { $obj = new PolygonBuilder(); @@ -147,7 +147,7 @@ public function testAddPointRelative() /** * @covers ::addPoints */ - public function testAddPoints() + public function testAddPoints(): void { $obj = new PolygonBuilder(); diff --git a/tests/Rasterization/Renderers/ImageRendererTest.php b/tests/Rasterization/Renderers/ImageRendererTest.php index e9ecc628..901226c4 100644 --- a/tests/Rasterization/Renderers/ImageRendererTest.php +++ b/tests/Rasterization/Renderers/ImageRendererTest.php @@ -9,7 +9,7 @@ class SVGNodeClass extends SVGNode { - const TAG_NAME = 'test_subclass'; + public const TAG_NAME = 'test_subclass'; /** * @inheritdoc @@ -27,7 +27,7 @@ public function rasterize(\SVG\Rasterization\SVGRasterizer $rasterizer): void */ class ImageRendererTest extends \PHPUnit\Framework\TestCase { - public function testRender() + public function testRender(): void { $obj = new ImageRenderer(); @@ -46,7 +46,7 @@ public function testRender() $this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-image.png')); } - public function testDefaultsXAndYToZero() + public function testDefaultsXAndYToZero(): void { $obj = new ImageRenderer(); diff --git a/tests/Rasterization/Renderers/MultiPassRendererTest.php b/tests/Rasterization/Renderers/MultiPassRendererTest.php index a62983f4..e9fd2d33 100644 --- a/tests/Rasterization/Renderers/MultiPassRendererTest.php +++ b/tests/Rasterization/Renderers/MultiPassRendererTest.php @@ -33,30 +33,30 @@ private function isGdImage() } } - public function testRenderShouldCallPrepare() + public function testRenderShouldCallPrepare(): void { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); // should call prepareRenderParams with correct arguments - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(\SVG\Rasterization\Renderers\MultiPassRenderer::class); $obj->expects($this->once())->method('prepareRenderParams')->with( $this->identicalTo(self::$sampleOptions), - $this->isInstanceOf('\SVG\Rasterization\Transform\Transform') + $this->isInstanceOf(\SVG\Rasterization\Transform\Transform::class) )->willReturn(self::$sampleParams); $obj->render($rasterizer, self::$sampleOptions, $node); imagedestroy($rasterizer->getImage()); } - public function testRenderShouldCallRenderFill() + public function testRenderShouldCallRenderFill(): void { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); // should call renderFill with correct fill color $node->setStyle('fill', '#AAAAAA'); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(\SVG\Rasterization\Renderers\MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->once())->method('renderFill')->with( $this->isGdImage(), @@ -67,7 +67,7 @@ public function testRenderShouldCallRenderFill() // should not call renderFill with 'fill: none' style $node->setStyle('fill', 'none'); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(\SVG\Rasterization\Renderers\MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->never())->method('renderFill'); $obj->render($rasterizer, self::$sampleOptions, $node); @@ -75,15 +75,15 @@ public function testRenderShouldCallRenderFill() imagedestroy($rasterizer->getImage()); } - public function testRenderShouldCallRenderStroke() + public function testRenderShouldCallRenderStroke(): void { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); // should call renderStroke with correct stroke color and width $node->setStyle('stroke', '#BBBBBB'); $node->setStyle('stroke-width', '2px'); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(\SVG\Rasterization\Renderers\MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->once())->method('renderStroke')->with( $this->isGdImage(), @@ -95,7 +95,7 @@ public function testRenderShouldCallRenderStroke() // should not call renderStroke with 'stroke: none' style $node->setStyle('stroke', 'none'); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(\SVG\Rasterization\Renderers\MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->never())->method('renderStroke'); $obj->render($rasterizer, self::$sampleOptions, $node); @@ -103,16 +103,16 @@ public function testRenderShouldCallRenderStroke() imagedestroy($rasterizer->getImage()); } - public function testRenderShouldRespectFillOpacity() + public function testRenderShouldRespectFillOpacity(): void { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); // should use fill-opacity for the alpha value (try with a few different notations) foreach (['0.5', '.5', '50%', ' 0.5 ', ' 50% '] as $fillOpacity) { $node->setStyle('fill', '#AAAAAA'); $node->setStyle('fill-opacity', $fillOpacity); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(\SVG\Rasterization\Renderers\MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->once())->method('renderFill')->with( $this->isGdImage(), @@ -125,17 +125,17 @@ public function testRenderShouldRespectFillOpacity() imagedestroy($rasterizer->getImage()); } - public function testRenderShouldRespectStrokeOpacity() + public function testRenderShouldRespectStrokeOpacity(): void { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); // should use stroke-opacity for the alpha value (try with a few different notations) foreach (['0.5', '.5', '50%', ' 0.5 ', ' 50% '] as $strokeOpacity) { $node->setStyle('stroke', '#BBBBBB'); $node->setStyle('stroke-opacity', $strokeOpacity); $node->setStyle('stroke-width', '2px'); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(\SVG\Rasterization\Renderers\MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->once())->method('renderStroke')->with( $this->isGdImage(), diff --git a/tests/Rasterization/Renderers/PolygonRendererTest.php b/tests/Rasterization/Renderers/PolygonRendererTest.php index 378df1fe..1daabf48 100644 --- a/tests/Rasterization/Renderers/PolygonRendererTest.php +++ b/tests/Rasterization/Renderers/PolygonRendererTest.php @@ -14,7 +14,7 @@ */ class PolygonRendererTest extends \PHPUnit\Framework\TestCase { - public function testShouldNotFailForTooFewPoints() + public function testShouldNotFailForTooFewPoints(): void { // ensures that there is no crash in case fewer than 3 points are provided, // which might trip up the fill or stroke algorithms if they don't check for it @@ -22,7 +22,7 @@ public function testShouldNotFailForTooFewPoints() $obj = new PolygonRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', '#0000FF'); $context->setStyle('stroke-width', '1px'); @@ -51,11 +51,11 @@ public function testShouldNotFailForTooFewPoints() ], $context); } - public function testShouldRespectFillRule() + public function testShouldRespectFillRule(): void { $obj = new PolygonRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', 'none'); diff --git a/tests/Rasterization/Renderers/RectRendererTest.php b/tests/Rasterization/Renderers/RectRendererTest.php index 518e7402..7d0b921a 100644 --- a/tests/Rasterization/Renderers/RectRendererTest.php +++ b/tests/Rasterization/Renderers/RectRendererTest.php @@ -14,11 +14,11 @@ */ class RectRendererTest extends \PHPUnit\Framework\TestCase { - public function testShouldRenderStroke() + public function testShouldRenderStroke(): void { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', 'none'); $context->setStyle('stroke', '#FF0000'); $context->setStyle('stroke-width', '1px'); @@ -33,11 +33,11 @@ public function testShouldRenderStroke() $this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-rect-stroke.png')); } - public function testShouldRenderStrokeThick() + public function testShouldRenderStrokeThick(): void { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', 'none'); $context->setStyle('stroke', '#FF0000'); $context->setStyle('stroke-width', '3px'); @@ -52,11 +52,11 @@ public function testShouldRenderStrokeThick() $this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-rect-stroke-thick.png')); } - public function testShouldRenderStrokeAlpha() + public function testShouldRenderStrokeAlpha(): void { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', 'none'); $context->setStyle('stroke', 'rgba(255, 0, 0, 0.5)'); $context->setStyle('stroke-width', '3px'); @@ -71,11 +71,11 @@ public function testShouldRenderStrokeAlpha() $this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-rect-stroke-alpha.png')); } - public function testShouldRenderFill() + public function testShouldRenderFill(): void { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', 'none'); @@ -89,11 +89,11 @@ public function testShouldRenderFill() $this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-rect-fill.png')); } - public function testShouldRenderFillAlpha() + public function testShouldRenderFillAlpha(): void { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', 'rgba(255, 0, 0, 0.5)'); $context->setStyle('stroke', 'none'); @@ -107,11 +107,11 @@ public function testShouldRenderFillAlpha() $this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-rect-fill-alpha.png')); } - public function testShouldRenderStrokeAndFill() + public function testShouldRenderStrokeAndFill(): void { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', 'rgba(255, 255, 255, 0.5)'); $context->setStyle('stroke', 'rgba(0, 0, 0, 0.5)'); $context->setStyle('stroke-width', '5px'); @@ -126,11 +126,11 @@ public function testShouldRenderStrokeAndFill() $this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-rect-stroke-fill.png')); } - public function testShouldRenderStrokeRounded() + public function testShouldRenderStrokeRounded(): void { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', 'none'); $context->setStyle('stroke', '#FF0000'); $context->setStyle('stroke-width', '1px'); @@ -146,11 +146,11 @@ public function testShouldRenderStrokeRounded() $this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-rect-stroke-rounded.png')); } - public function testShouldRenderFillRounded() + public function testShouldRenderFillRounded(): void { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', 'none'); @@ -165,11 +165,11 @@ public function testShouldRenderFillRounded() $this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-rect-fill-rounded.png')); } - public function testDoesNotRenderIfWidthZero() + public function testDoesNotRenderIfWidthZero(): void { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', '#0000FF'); $context->setStyle('stroke-width', '1px'); @@ -185,11 +185,11 @@ public function testDoesNotRenderIfWidthZero() $this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-rect-empty.png')); } - public function testDoesNotRenderIfHeightZero() + public function testDoesNotRenderIfHeightZero(): void { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', '#0000FF'); $context->setStyle('stroke-width', '1px'); @@ -205,11 +205,11 @@ public function testDoesNotRenderIfHeightZero() $this->assertThat($img, new GDSimilarityConstraint('./tests/images/renderer-rect-empty.png')); } - public function testDefaultsXAndYToZero() + public function testDefaultsXAndYToZero(): void { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $context->setStyle('fill', '#FFFFFF'); $context->setStyle('stroke', '#000000'); $context->setStyle('stroke-width', '5px'); diff --git a/tests/Rasterization/Renderers/TextRendererTest.php b/tests/Rasterization/Renderers/TextRendererTest.php index 88a6ef6c..d4d85e58 100644 --- a/tests/Rasterization/Renderers/TextRendererTest.php +++ b/tests/Rasterization/Renderers/TextRendererTest.php @@ -13,11 +13,11 @@ */ class TextRendererTest extends \PHPUnit\Framework\TestCase { - public function testShouldNotFailWithoutRegisteredFont() + public function testShouldNotFailWithoutRegisteredFont(): void { $obj = new TextRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $rasterizer = new SVGRasterizer('40px', '80px', null, 4, 8); $obj->render($rasterizer, [ diff --git a/tests/Rasterization/SVGRasterizerTest.php b/tests/Rasterization/SVGRasterizerTest.php index 87d48a9b..1f3945bb 100644 --- a/tests/Rasterization/SVGRasterizerTest.php +++ b/tests/Rasterization/SVGRasterizerTest.php @@ -18,7 +18,7 @@ class SVGRasterizerTest extends \PHPUnit\Framework\TestCase /** * @covers ::getDocumentWidth */ - public function testGetDocumentWidth() + public function testGetDocumentWidth(): void { // should return parsed unit relative to target size $obj = new SVGRasterizer('50%', '50%', null, 100, 200); @@ -34,7 +34,7 @@ public function testGetDocumentWidth() /** * @covers ::getDocumentHeight */ - public function testGetDocumentHeight() + public function testGetDocumentHeight(): void { // should return parsed unit relative to target size $obj = new SVGRasterizer('50%', '50%', null, 100, 200); @@ -50,7 +50,7 @@ public function testGetDocumentHeight() /** * @covers ::getNormalizedDiagonal */ - public function testGetNormalizedDiagonal() + public function testGetNormalizedDiagonal(): void { // should return the correct length $obj = new SVGRasterizer('50%', '50%', null, 100, 200); @@ -61,7 +61,7 @@ public function testGetNormalizedDiagonal() /** * @covers ::getWidth */ - public function testGetWidth() + public function testGetWidth(): void { // should return the constructor parameter $obj = new SVGRasterizer(10, 20, null, 100, 200); @@ -72,7 +72,7 @@ public function testGetWidth() /** * @covers ::getHeight */ - public function testGetHeight() + public function testGetHeight(): void { // should return the constructor parameter $obj = new SVGRasterizer(10, 20, null, 100, 200); @@ -83,7 +83,7 @@ public function testGetHeight() /** * @covers ::getDiagonalScale */ - public function testGetDiagonalScale() + public function testGetDiagonalScale(): void { // should use viewBox dimension when available $obj = new SVGRasterizer(10, 20, [37, 42, 25, 100], 100, 200); @@ -100,7 +100,7 @@ public function testGetDiagonalScale() /** * @covers ::getViewbox */ - public function testGetViewbox() + public function testGetViewbox(): void { // should return the constructor parameter $obj = new SVGRasterizer(10, 20, [37, 42, 25, 100], 100, 200); @@ -116,7 +116,7 @@ public function testGetViewbox() /** * @covers ::getImage */ - public function testGetImage() + public function testGetImage(): void { $obj = new SVGRasterizer(10, 20, [], 100, 200); @@ -139,7 +139,7 @@ public function testGetImage() /** * @covers ::getCurrentTransform */ - public function testGetCurrentTransform() + public function testGetCurrentTransform(): void { // should use viewBox dimension when available $obj = new SVGRasterizer(10, 20, [37, 42, 25, 80], 100, 160); @@ -164,7 +164,7 @@ public function testGetCurrentTransform() * @covers ::pushTransform * @covers ::popTransform */ - public function testTransformStack() + public function testTransformStack(): void { $obj = new SVGRasterizer(10, 20, [37, 42, 25, 80], 100, 160); @@ -206,19 +206,19 @@ public function testTransformStack() /** * @covers ::render */ - public function testRenderWithNoSuchRenderId() + public function testRenderWithNoSuchRenderId(): void { $this->expectException('\InvalidArgumentException'); $obj = new SVGRasterizer(10, 20, [], 100, 200); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(\SVG\Nodes\SVGNode::class); $obj->render('invalid_render_id', ['option' => 'value'], $mockChild); } /** * @covers \SVG\Rasterization\SVGRasterizer */ - public function testShouldRenderBackgroundTransparent() + public function testShouldRenderBackgroundTransparent(): void { $obj = new SVGRasterizer(32, 32, [], 32, 32, null); $img = $obj->finish(); @@ -231,7 +231,7 @@ public function testShouldRenderBackgroundTransparent() /** * @covers \SVG\Rasterization\SVGRasterizer */ - public function testShouldRenderBackgroundSolidWhite() + public function testShouldRenderBackgroundSolidWhite(): void { $obj = new SVGRasterizer(32, 32, [], 32, 32, "#FFFFFF"); $img = $obj->finish(); @@ -244,7 +244,7 @@ public function testShouldRenderBackgroundSolidWhite() /** * @covers \SVG\Rasterization\SVGRasterizer */ - public function testShouldRenderBackgroundWhiteSemitransparent() + public function testShouldRenderBackgroundWhiteSemitransparent(): void { $obj = new SVGRasterizer(32, 32, [], 32, 32, "rgba(255,255,255,.5)"); $img = $obj->finish(); diff --git a/tests/Rasterization/Transform/TransformParserTest.php b/tests/Rasterization/Transform/TransformParserTest.php index 5d0cb2df..66ba1708 100644 --- a/tests/Rasterization/Transform/TransformParserTest.php +++ b/tests/Rasterization/Transform/TransformParserTest.php @@ -12,13 +12,13 @@ */ class TransformParserTest extends \PHPUnit\Framework\TestCase { - private function assertMap(Transform $t, array $expected, array $source) + private function assertMap(Transform $t, array $expected, array $source): void { $t->map($source[0], $source[1]); $this->assertEquals($expected, $source); } - public function testParseTransformString() + public function testParseTransformString(): void { $transform = TransformParser::parseTransformString('translate(10,20) scale(3,7) rotate(90)'); $this->assertMap($transform, [-290, 720], [100, 100]); diff --git a/tests/Rasterization/Transform/TransformTest.php b/tests/Rasterization/Transform/TransformTest.php index 3c39c8fd..4cdc1bcd 100644 --- a/tests/Rasterization/Transform/TransformTest.php +++ b/tests/Rasterization/Transform/TransformTest.php @@ -11,21 +11,21 @@ */ class TransformTest extends \PHPUnit\Framework\TestCase { - private function assertMap(Transform $t, array $expected, array $source) + private function assertMap(Transform $t, array $expected, array $source): void { $t->map($source[0], $source[1]); $this->assertEqualsWithDelta($expected[0], $source[0], 10e-12); $this->assertEqualsWithDelta($expected[1], $source[1], 10e-12); } - private function assertResized(Transform $t, array $expected, array $source) + private function assertResized(Transform $t, array $expected, array $source): void { $t->resize($source[0], $source[1]); $this->assertEqualsWithDelta($expected[0], $source[0], 10e-12); $this->assertEqualsWithDelta($expected[1], $source[1], 10e-12); } - public function testIdentity() + public function testIdentity(): void { $t = Transform::identity(); $this->assertMap($t, [0, 0], [0, 0]); @@ -36,7 +36,7 @@ public function testIdentity() /** * @covers ::resize */ - public function testResize() + public function testResize(): void { $t = Transform::identity(); $this->assertResized($t, [123, 456], [123, 456]); @@ -87,7 +87,7 @@ public function testResize() $this->assertResized($t, [123 * 3, 456 * 5 * M_SQRT2], [123, 456]); } - public function testMultiply() + public function testMultiply(): void { $t = Transform::identity(); @@ -108,7 +108,7 @@ public function testMultiply() $this->assertMap($t, [-1411, 2993], [123, 456]); } - public function testTranslate() + public function testTranslate(): void { $t = Transform::identity(); @@ -130,7 +130,7 @@ public function testTranslate() $this->assertMap($t, [713, 1015], [59, 61]); } - public function testScale() + public function testScale(): void { $t = Transform::identity(); @@ -153,7 +153,7 @@ public function testScale() $this->assertMap($t, [16882, 24069], [59, 61]); } - public function testRotate() + public function testRotate(): void { $t = Transform::identity(); @@ -172,7 +172,7 @@ public function testRotate() $this->assertMap($t, [11 + 298 * M_SQRT2, 13 + 417 * M_SQRT2], [59, 61]); } - public function testSkewX() + public function testSkewX(): void { $t = Transform::identity(); @@ -192,7 +192,7 @@ public function testSkewX() $this->assertMap($t, [312 + 122 * M_SQRT2, 434 + 183 * M_SQRT2], [59, 61]); } - public function testSkewY() + public function testSkewY(): void { $t = Transform::identity(); diff --git a/tests/Reading/AttributeRegistryTest.php b/tests/Reading/AttributeRegistryTest.php index c53aea2a..849c5be6 100644 --- a/tests/Reading/AttributeRegistryTest.php +++ b/tests/Reading/AttributeRegistryTest.php @@ -16,7 +16,7 @@ class AttributeRegistryTest extends \PHPUnit\Framework\TestCase /** * @covers ::isStyle */ - public function testIsStyle() + public function testIsStyle(): void { $this->assertTrue(AttributeRegistry::isStyle('font-size')); $this->assertTrue(AttributeRegistry::isStyle('stroke')); @@ -27,7 +27,7 @@ public function testIsStyle() /** * @covers ::convertStyleAttribute */ - public function testConvertStyleAttribute() + public function testConvertStyleAttribute(): void { $this->assertSame('42px', AttributeRegistry::convertStyleAttribute('font-size', '42')); $this->assertSame('42%', AttributeRegistry::convertStyleAttribute('font-size', '42%')); diff --git a/tests/Reading/LengthAttributeConverterTest.php b/tests/Reading/LengthAttributeConverterTest.php index 09d1063b..5ca1eab4 100644 --- a/tests/Reading/LengthAttributeConverterTest.php +++ b/tests/Reading/LengthAttributeConverterTest.php @@ -11,7 +11,7 @@ */ class LengthAttributeConverterTest extends \PHPUnit\Framework\TestCase { - public function testShouldQualifyUnitlessNumbers() + public function testShouldQualifyUnitlessNumbers(): void { $obj = LengthAttributeConverter::getInstance(); @@ -24,7 +24,7 @@ public function testShouldQualifyUnitlessNumbers() $this->assertSame('-42.123px', $obj->convert('-42.123')); } - public function testShouldTrimWhitespace() + public function testShouldTrimWhitespace(): void { $obj = LengthAttributeConverter::getInstance(); @@ -33,7 +33,7 @@ public function testShouldTrimWhitespace() $this->assertSame('-42.123px', $obj->convert(" \n -42.123 \n ")); } - public function testShouldIgnoreOtherValues() + public function testShouldIgnoreOtherValues(): void { $obj = LengthAttributeConverter::getInstance(); diff --git a/tests/Reading/NodeRegistryTest.php b/tests/Reading/NodeRegistryTest.php index 24030ed5..dbc6c2a5 100644 --- a/tests/Reading/NodeRegistryTest.php +++ b/tests/Reading/NodeRegistryTest.php @@ -11,15 +11,15 @@ */ class NodeRegistryTest extends \PHPUnit\Framework\TestCase { - public function testShouldConstructKnownTypes() + public function testShouldConstructKnownTypes(): void { $result = NodeRegistry::create('rect'); - $this->assertInstanceOf('SVG\Nodes\Shapes\SVGRect', $result); + $this->assertInstanceOf(\SVG\Nodes\Shapes\SVGRect::class, $result); } - public function testShouldUseGenericTypeForOthers() + public function testShouldUseGenericTypeForOthers(): void { $result = NodeRegistry::create('div'); - $this->assertInstanceOf('SVG\Nodes\SVGGenericNodeType', $result); + $this->assertInstanceOf(\SVG\Nodes\SVGGenericNodeType::class, $result); } } diff --git a/tests/Reading/SVGReaderTest.php b/tests/Reading/SVGReaderTest.php index a9fb7bbc..e5d5b27d 100644 --- a/tests/Reading/SVGReaderTest.php +++ b/tests/Reading/SVGReaderTest.php @@ -74,19 +74,19 @@ public function setUp(): void $this->xmlEntities .= ''; } - public function testShouldReturnAnImageOrNull() + public function testShouldReturnAnImageOrNull(): void { // should return an instance of SVG $svgReader = new SVGReader(); $result = $svgReader->parseString($this->xml); - $this->assertInstanceOf('\SVG\SVG', $result); + $this->assertInstanceOf(\SVG\SVG::class, $result); // should return null when parsing fails $result = $svgReader->parseString(''); $this->assertNull($result); } - public function testShouldSetAllAttributesAndNamespaces() + public function testShouldSetAllAttributesAndNamespaces(): void { // should retain all document attributes and namespaces $svgReader = new SVGReader(); @@ -128,7 +128,7 @@ public function testShouldSetAllAttributesAndNamespaces() ], $rect->getSerializableAttributes()); } - public function testShouldSetStyles() + public function testShouldSetStyles(): void { $svgReader = new SVGReader(); $result = $svgReader->parseString($this->xml); @@ -143,7 +143,7 @@ public function testShouldSetStyles() $this->assertEquals('#AABBCC', $rect->getStyle('stroke')); } - public function testShouldConvertUnitlessCSSLengths() + public function testShouldConvertUnitlessCSSLengths(): void { $code = ''; $code .= 'foo'; @@ -159,7 +159,7 @@ public function testShouldConvertUnitlessCSSLengths() $this->assertSame('3px', $text->getStyle('word-spacing')); } - public function testShouldRecursivelyAddChildren() + public function testShouldRecursivelyAddChildren(): void { // should recursively add all child nodes $svgReader = new SVGReader(); @@ -184,7 +184,7 @@ public function testShouldRecursivelyAddChildren() ], $ellipse->getSerializableAttributes()); } - public function testShouldWorkWithoutAnyXmlns() + public function testShouldWorkWithoutAnyXmlns(): void { $svgReader = new SVGReader(); $result = $svgReader->parseString($this->xmlNoXmlns); @@ -195,7 +195,7 @@ public function testShouldWorkWithoutAnyXmlns() $this->assertSame('10', $doc->getChild(0)->getAttribute('cx')); } - public function testShouldWorkWithoutMainXmlns() + public function testShouldWorkWithoutMainXmlns(): void { $svgReader = new SVGReader(); $result = $svgReader->parseString($this->xmlOnlyOtherXmlns); @@ -207,7 +207,7 @@ public function testShouldWorkWithoutMainXmlns() $this->assertSame('bar', $doc->getChild(0)->getAttribute('xlink:foo')); } - public function testShouldRetrieveUnknownNodes() + public function testShouldRetrieveUnknownNodes(): void { $svgReader = new SVGReader(); $result = $svgReader->parseString($this->xmlUnknown); @@ -227,7 +227,7 @@ public function testShouldRetrieveUnknownNodes() $this->assertSame('baz', $doc->getChild(1)->getChild(0)->getName()); } - public function testShouldSetValue() + public function testShouldSetValue(): void { $svgReader = new SVGReader(); $result = $svgReader->parseString($this->xmlValue); @@ -237,7 +237,7 @@ public function testShouldSetValue() $this->assertSame('hello world', $doc->getChild(0)->getValue()); } - public function testShouldDecodeEntities() + public function testShouldDecodeEntities(): void { $svgReader = new SVGReader(); $result = $svgReader->parseString($this->xmlEntities); @@ -254,7 +254,7 @@ public function testShouldDecodeEntities() $this->assertSame('" foo&bar>', $doc->getChild(1)->getValue()); } - public function testShouldRemoveCDataForStyles() + public function testShouldRemoveCDataForStyles(): void { // should remove CDATA $code = ''; @@ -266,7 +266,7 @@ public function testShouldRemoveCDataForStyles() $this->assertSame('g {display:none;}', $doc->getChild(0)->getValue()); } - public function testChildKeepsNamespaces() + public function testChildKeepsNamespaces(): void { $code = ''; $code .= ''; @@ -282,7 +282,7 @@ public function testChildKeepsNamespaces() $this->assertStringContainsString('
', '' . $result); } - public function testParsesChildNamespacedAttributes() + public function testParsesChildNamespacedAttributes(): void { $code = ''; $code .= ''; @@ -298,7 +298,7 @@ public function testParsesChildNamespacedAttributes() $this->assertStringContainsString('

', '' . $result); } - public function testShouldRetrieveNamespacedNodes() + public function testShouldRetrieveNamespacedNodes(): void { $code = ''; $code .= ''; diff --git a/tests/SVGTest.php b/tests/SVGTest.php index c62c41e1..a75b8cc9 100644 --- a/tests/SVGTest.php +++ b/tests/SVGTest.php @@ -32,7 +32,7 @@ public function setUp(): void /** * @covers ::__construct */ - public function testConstructSetsDocumentDimensions() + public function testConstructSetsDocumentDimensions(): void { $image = new SVG(); $doc = $image->getDocument(); @@ -48,13 +48,13 @@ public function testConstructSetsDocumentDimensions() /** * @covers ::getDocument */ - public function testGetDocument() + public function testGetDocument(): void { $image = new SVG(); $doc = $image->getDocument(); // should be instanceof the correct class - $docFragClass = '\SVG\Nodes\Structures\SVGDocumentFragment'; + $docFragClass = \SVG\Nodes\Structures\SVGDocumentFragment::class; $this->assertInstanceOf($docFragClass, $doc); // should be set to root @@ -65,7 +65,7 @@ public function testGetDocument() * @requires extension gd * @covers ::toRasterImage */ - public function testToRasterImage() + public function testToRasterImage(): void { $image = new SVG(37, 42); $rasterImage = $image->toRasterImage(100, 200); @@ -87,7 +87,7 @@ public function testToRasterImage() /** * @covers ::__toString */ - public function test__toString() + public function test__toString(): void { $image = new SVG(37, 42); @@ -98,7 +98,7 @@ public function test__toString() /** * @covers ::toXMLString */ - public function testToXMLString() + public function testToXMLString(): void { $image = new SVG(37, 42); @@ -112,13 +112,13 @@ public function testToXMLString() /** * @covers ::fromString */ - public function testFromString() + public function testFromString(): void { $image = SVG::fromString($this->xml); $doc = $image->getDocument(); // should return an instance of SVG - $this->assertInstanceOf('\SVG\SVG', $image); + $this->assertInstanceOf(\SVG\SVG::class, $image); // should have correct width and height $this->assertSame('37', $doc->getWidth()); @@ -127,7 +127,7 @@ public function testFromString() // should succeed without xml declaration $image = SVG::fromString($this->xmlNoDeclaration); $doc = $image->getDocument(); - $this->assertInstanceOf('\SVG\SVG', $image); + $this->assertInstanceOf(\SVG\SVG::class, $image); $this->assertSame('37', $doc->getWidth()); $this->assertSame('42', $doc->getHeight()); } @@ -135,10 +135,10 @@ public function testFromString() /** * @covers ::fromFile */ - public function testFromFile() + public function testFromFile(): void { $image = SVG::fromFile(__DIR__ . '/php_test.svg'); - $this->assertInstanceOf('\SVG\SVG', $image); + $this->assertInstanceOf(\SVG\SVG::class, $image); } } diff --git a/tests/Shims/StrTest.php b/tests/Shims/StrTest.php index d413677f..92398cc2 100644 --- a/tests/Shims/StrTest.php +++ b/tests/Shims/StrTest.php @@ -7,7 +7,7 @@ class StrTest extends TestCase { /** @dataProvider provideTrimsWithDefaultCharacters */ - public function testTrimsWithDefaultCharacters($input, $expectedResult) + public function testTrimsWithDefaultCharacters($input, $expectedResult): void { $result = Str::trim($input); $this->assertSame($expectedResult, $result); @@ -31,7 +31,7 @@ public function provideTrimsWithDefaultCharacters() } /** @dataProvider provideTrimsWithCustomCharacters */ - public function testTrimsWithCustomCharacters($input, $expectedResult) + public function testTrimsWithCustomCharacters($input, $expectedResult): void { $result = Str::trim($input, "NeverGonnaGiveYouUp"); $this->assertSame($expectedResult, $result); diff --git a/tests/Utilities/Colors/ColorLookupTest.php b/tests/Utilities/Colors/ColorLookupTest.php index 499cf282..6dedeca6 100644 --- a/tests/Utilities/Colors/ColorLookupTest.php +++ b/tests/Utilities/Colors/ColorLookupTest.php @@ -11,7 +11,7 @@ */ class ColorLookupTest extends \PHPUnit\Framework\TestCase { - public function testGet() + public function testGet(): void { // named colors $this->assertEquals([0, 0, 0, 255], ColorLookup::get('black')); diff --git a/tests/Utilities/Colors/ColorTest.php b/tests/Utilities/Colors/ColorTest.php index 91fbe144..87eb1541 100644 --- a/tests/Utilities/Colors/ColorTest.php +++ b/tests/Utilities/Colors/ColorTest.php @@ -11,7 +11,7 @@ */ class ColorTest extends \PHPUnit\Framework\TestCase { - public function testParse() + public function testParse(): void { // named colors $this->assertEquals([0, 0, 0, 255], Color::parse('black')); diff --git a/tests/Utilities/SVGStyleParserTest.php b/tests/Utilities/SVGStyleParserTest.php index e396fd90..5034a29a 100644 --- a/tests/Utilities/SVGStyleParserTest.php +++ b/tests/Utilities/SVGStyleParserTest.php @@ -11,26 +11,26 @@ */ class SVGStyleParserTest extends \PHPUnit\Framework\TestCase { - public function testParseStylesWithEmptyString() + public function testParseStylesWithEmptyString(): void { $this->assertCount(0, SVGStyleParser::parseStyles('')); } - public function testParseCssWithMatchedElement() + public function testParseCssWithMatchedElement(): void { $result = SVGStyleParser::parseCss('svg {background-color: beige;}'); $this->assertSame('beige', $result['svg']['background-color']); } - public function testParseCssWithSkippedElement() + public function testParseCssWithSkippedElement(): void { $result = SVGStyleParser::parseCss('@font-face {font-family: "Bitstream Vera Serif Bold";}'); $this->assertCount(0, $result); } - public function testParseDuplicateSelectors() + public function testParseDuplicateSelectors(): void { $result = SVGStyleParser::parseCss('svg {background-color: beige;}; svg {stroke: none;} svg { fill: blue }'); diff --git a/tests/Utilities/Units/AngleTest.php b/tests/Utilities/Units/AngleTest.php index d9991f9d..fdd202a0 100644 --- a/tests/Utilities/Units/AngleTest.php +++ b/tests/Utilities/Units/AngleTest.php @@ -11,7 +11,7 @@ */ class AngleTest extends \PHPUnit\Framework\TestCase { - public function testConvert() + public function testConvert(): void { // degrees $this->assertEquals(15.5, Angle::convert('15.5deg')); diff --git a/tests/Utilities/Units/LengthTest.php b/tests/Utilities/Units/LengthTest.php index f21f7bea..475fbeea 100644 --- a/tests/Utilities/Units/LengthTest.php +++ b/tests/Utilities/Units/LengthTest.php @@ -11,7 +11,7 @@ */ class LengthTest extends \PHPUnit\Framework\TestCase { - public function testConvert() + public function testConvert(): void { // units $this->assertEquals(16, Length::convert('12pt', 100)); diff --git a/tests/Writing/SVGWriterTest.php b/tests/Writing/SVGWriterTest.php index 8e53d8bb..d97e9985 100644 --- a/tests/Writing/SVGWriterTest.php +++ b/tests/Writing/SVGWriterTest.php @@ -13,21 +13,21 @@ class SVGWriterTest extends \PHPUnit\Framework\TestCase { private $xmlDeclaration = ''; - public function testShouldIncludeXMLDeclaration() + public function testShouldIncludeXMLDeclaration(): void { // should start with the XML declaration $obj = new SVGWriter(); $this->assertEquals($this->xmlDeclaration, $obj->getString()); } - public function testShouldSupportStandaloneFalse() + public function testShouldSupportStandaloneFalse(): void { // should not prepend the XML declaration $obj = new SVGWriter(false); $this->assertEquals('', $obj->getString()); } - public function testShouldWriteTags() + public function testShouldWriteTags(): void { // should write opening and closing tags for containers $obj = new SVGWriter(); @@ -44,7 +44,7 @@ public function testShouldWriteTags() $this->assertEquals($expect, $obj->getString()); } - public function testShouldWriteAttributes() + public function testShouldWriteAttributes(): void { // should write attributes for containers $obj = new SVGWriter(); @@ -55,7 +55,7 @@ public function testShouldWriteAttributes() $this->assertEquals($expect, $obj->getString()); } - public function testShouldWriteStyles() + public function testShouldWriteStyles(): void { // should serialize styles correctly $obj = new SVGWriter(); @@ -66,7 +66,7 @@ public function testShouldWriteStyles() $this->assertEquals($expect, $obj->getString()); } - public function testShouldWriteChildren() + public function testShouldWriteChildren(): void { // should write children $obj = new SVGWriter(); @@ -81,7 +81,7 @@ public function testShouldWriteChildren() $this->assertEquals($expect, $obj->getString()); } - public function testShouldWriteStyleTagInCDATA() + public function testShouldWriteStyleTagInCDATA(): void { // should enclose style tag content in ... $obj = new SVGWriter(); @@ -92,7 +92,7 @@ public function testShouldWriteStyleTagInCDATA() $this->assertEquals($expect, $obj->getString()); } - public function testShouldEncodeEntities() + public function testShouldEncodeEntities(): void { // should encode entities in attributes $obj = new SVGWriter(); @@ -119,7 +119,7 @@ public function testShouldEncodeEntities() $this->assertEquals($expect, $obj->getString()); } - public function testShouldWriteValue() + public function testShouldWriteValue(): void { // should add value before closing tag $obj = new SVGWriter();