diff --git a/src/Rasterization/Renderers/PathRendererImplementation.php b/src/Rasterization/Renderers/PathRendererImplementation.php index 397e1cbc..70b73e2b 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, [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, [PathRendererEdge::class, 'compareX']); $windingNumber = $evenOdd ? 0 : $activeEdges[0]->direction; diff --git a/src/Reading/AttributeRegistry.php b/src/Reading/AttributeRegistry.php index 09030583..9dc3c189 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' => LengthAttributeConverter::class, + 'letter-spacing' => LengthAttributeConverter::class, + 'word-spacing' => LengthAttributeConverter::class, ]; /** diff --git a/src/Reading/NodeRegistry.php b/src/Reading/NodeRegistry.php index c4ff1791..c9f0b2f3 100644 --- a/src/Reading/NodeRegistry.php +++ b/src/Reading/NodeRegistry.php @@ -2,8 +2,71 @@ namespace SVG\Reading; +use SVG\Nodes\Embedded\SVGForeignObject; +use SVG\Nodes\Embedded\SVGImage; +use SVG\Nodes\Filters\SVGFEBlend; +use SVG\Nodes\Filters\SVGFEColorMatrix; +use SVG\Nodes\Filters\SVGFEComponentTransfer; +use SVG\Nodes\Filters\SVGFEComposite; +use SVG\Nodes\Filters\SVGFEConvolveMatrix; +use SVG\Nodes\Filters\SVGFEDiffuseLighting; +use SVG\Nodes\Filters\SVGFEDisplacementMap; +use SVG\Nodes\Filters\SVGFEDistantLight; +use SVG\Nodes\Filters\SVGFEDropShadow; +use SVG\Nodes\Filters\SVGFEFlood; +use SVG\Nodes\Filters\SVGFEFuncA; +use SVG\Nodes\Filters\SVGFEFuncB; +use SVG\Nodes\Filters\SVGFEFuncG; +use SVG\Nodes\Filters\SVGFEFuncR; +use SVG\Nodes\Filters\SVGFEGaussianBlur; +use SVG\Nodes\Filters\SVGFEImage; +use SVG\Nodes\Filters\SVGFEMerge; +use SVG\Nodes\Filters\SVGFEMergeNode; +use SVG\Nodes\Filters\SVGFEMorphology; +use SVG\Nodes\Filters\SVGFEOffset; +use SVG\Nodes\Filters\SVGFEPointLight; +use SVG\Nodes\Filters\SVGFESpecularLighting; +use SVG\Nodes\Filters\SVGFESpotLight; +use SVG\Nodes\Filters\SVGFETile; +use SVG\Nodes\Filters\SVGFETurbulence; +use SVG\Nodes\Filters\SVGFilter; +use SVG\Nodes\Presentation\SVGAnimate; +use SVG\Nodes\Presentation\SVGAnimateMotion; +use SVG\Nodes\Presentation\SVGAnimateTransform; +use SVG\Nodes\Presentation\SVGLinearGradient; +use SVG\Nodes\Presentation\SVGMPath; +use SVG\Nodes\Presentation\SVGRadialGradient; +use SVG\Nodes\Presentation\SVGSet; +use SVG\Nodes\Presentation\SVGStop; +use SVG\Nodes\Presentation\SVGView; +use SVG\Nodes\Shapes\SVGCircle; +use SVG\Nodes\Shapes\SVGEllipse; +use SVG\Nodes\Shapes\SVGLine; +use SVG\Nodes\Shapes\SVGPath; +use SVG\Nodes\Shapes\SVGPolygon; +use SVG\Nodes\Shapes\SVGPolyline; +use SVG\Nodes\Shapes\SVGRect; +use SVG\Nodes\Structures\SVGClipPath; +use SVG\Nodes\Structures\SVGDefs; +use SVG\Nodes\Structures\SVGDocumentFragment; +use SVG\Nodes\Structures\SVGGroup; +use SVG\Nodes\Structures\SVGLinkGroup; +use SVG\Nodes\Structures\SVGMarker; +use SVG\Nodes\Structures\SVGMask; +use SVG\Nodes\Structures\SVGMetadata; +use SVG\Nodes\Structures\SVGPattern; +use SVG\Nodes\Structures\SVGScript; +use SVG\Nodes\Structures\SVGStyle; +use SVG\Nodes\Structures\SVGSwitch; +use SVG\Nodes\Structures\SVGSymbol; +use SVG\Nodes\Structures\SVGUse; use SVG\Nodes\SVGNode; use SVG\Nodes\SVGGenericNodeType; +use SVG\Nodes\Texts\SVGDesc; +use SVG\Nodes\Texts\SVGText; +use SVG\Nodes\Texts\SVGTextPath; +use SVG\Nodes\Texts\SVGTitle; +use SVG\Nodes\Texts\SVGTSpan; /** * This class contains a list of all known SVG node types, and enables dynamic @@ -15,74 +78,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' => SVGForeignObject::class, + 'image' => 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' => SVGFEBlend::class, + 'feColorMatrix' => SVGFEColorMatrix::class, + 'feComponentTransfer' => SVGFEComponentTransfer::class, + 'feComposite' => SVGFEComposite::class, + 'feConvolveMatrix' => SVGFEConvolveMatrix::class, + 'feDiffuseLighting' => SVGFEDiffuseLighting::class, + 'feDisplacementMap' => SVGFEDisplacementMap::class, + 'feDistantLight' => SVGFEDistantLight::class, + 'feDropShadow' => SVGFEDropShadow::class, + 'feFlood' => SVGFEFlood::class, + 'feFuncA' => SVGFEFuncA::class, + 'feFuncB' => SVGFEFuncB::class, + 'feFuncG' => SVGFEFuncG::class, + 'feFuncR' => SVGFEFuncR::class, + 'feGaussianBlur' => SVGFEGaussianBlur::class, + 'feImage' => SVGFEImage::class, + 'feMerge' => SVGFEMerge::class, + 'feMergeNode' => SVGFEMergeNode::class, + 'feMorphology' => SVGFEMorphology::class, + 'feOffset' => SVGFEOffset::class, + 'fePointLight' => SVGFEPointLight::class, + 'feSpecularLighting' => SVGFESpecularLighting::class, + 'feSpotLight' => SVGFESpotLight::class, + 'feTile' => SVGFETile::class, + 'feTurbulence' => SVGFETurbulence::class, + 'filter' => 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' => SVGAnimate::class, + 'animateMotion' => SVGAnimateMotion::class, + 'animateTransform' => SVGAnimateTransform::class, + 'linearGradient' => SVGLinearGradient::class, + 'mpath' => SVGMPath::class, + 'radialGradient' => SVGRadialGradient::class, + 'set' => SVGSet::class, + 'stop' => SVGStop::class, + 'view' => 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' => SVGCircle::class, + 'ellipse' => SVGEllipse::class, + 'line' => SVGLine::class, + 'path' => SVGPath::class, + 'polygon' => SVGPolygon::class, + 'polyline' => SVGPolyline::class, + 'rect' => 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' => SVGClipPath::class, + 'defs' => SVGDefs::class, + 'svg' => SVGDocumentFragment::class, + 'g' => SVGGroup::class, + 'a' => SVGLinkGroup::class, + 'marker' => SVGMarker::class, + 'mask' => SVGMask::class, + 'metadata' => SVGMetadata::class, + 'pattern' => SVGPattern::class, + 'script' => SVGScript::class, + 'style' => SVGStyle::class, + 'switch' => SVGSwitch::class, + 'symbol' => SVGSymbol::class, + 'use' => 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' => SVGDesc::class, + 'text' => SVGText::class, + 'textPath' => SVGTextPath::class, + 'title' => SVGTitle::class, + 'tspan' => SVGTSpan::class, ]; /** diff --git a/tests/Nodes/Embedded/SVGImageTest.php b/tests/Nodes/Embedded/SVGImageTest.php index 564f6e93..fc4af259 100644 --- a/tests/Nodes/Embedded/SVGImageTest.php +++ b/tests/Nodes/Embedded/SVGImageTest.php @@ -1,8 +1,8 @@ getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/SVGNodeContainerTest.php b/tests/Nodes/SVGNodeContainerTest.php index e5c415d0..4b7fa9f1 100644 --- a/tests/Nodes/SVGNodeContainerTest.php +++ b/tests/Nodes/SVGNodeContainerTest.php @@ -1,8 +1,8 @@ getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(SVGNode::class); $obj->addChild($mockChild); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -265,7 +265,7 @@ public function testGetContainerStyleForNode() { $obj = new SVGNodeContainerSubclass(); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(SVGNode::class); $obj->addChild($mockChild); $this->assertCount(0, $obj->getContainerStyleForNode($mockChild)); @@ -278,7 +278,7 @@ public function testGetContainerStyleByPattern() { $obj = new SVGNodeContainerSubclass(); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(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..0631d2b7 100644 --- a/tests/Nodes/SVGNodeTest.php +++ b/tests/Nodes/SVGNodeTest.php @@ -1,8 +1,6 @@ getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGEllipseTest.php b/tests/Nodes/Shapes/SVGEllipseTest.php index ba7903fc..f8ebd1f4 100644 --- a/tests/Nodes/Shapes/SVGEllipseTest.php +++ b/tests/Nodes/Shapes/SVGEllipseTest.php @@ -1,8 +1,8 @@ getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGLineTest.php b/tests/Nodes/Shapes/SVGLineTest.php index d5160bf7..72b19a29 100644 --- a/tests/Nodes/Shapes/SVGLineTest.php +++ b/tests/Nodes/Shapes/SVGLineTest.php @@ -1,8 +1,8 @@ getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGPathTest.php b/tests/Nodes/Shapes/SVGPathTest.php index a41284e0..fdf3663d 100644 --- a/tests/Nodes/Shapes/SVGPathTest.php +++ b/tests/Nodes/Shapes/SVGPathTest.php @@ -1,8 +1,8 @@ getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -88,7 +88,7 @@ public function testRasterize() $obj = new SVGPath(self::$sampleDescription); // setup mocks - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -134,7 +134,7 @@ public function testRasterizeShouldRespectFillRule() 'foo' => 'foo', ]; foreach ($attributeToExpectedFillRule as $attribute => $expectedFillRule) { - $rasterizer = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rasterizer = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGPolygonTest.php b/tests/Nodes/Shapes/SVGPolygonTest.php index 3d23d29c..4eaca8c1 100644 --- a/tests/Nodes/Shapes/SVGPolygonTest.php +++ b/tests/Nodes/Shapes/SVGPolygonTest.php @@ -1,8 +1,8 @@ getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -94,7 +94,7 @@ public function testRasterizeShouldRespectFillRule() 'foo' => 'foo', ]; foreach ($attributeToExpectedFillRule as $attribute => $expectedFillRule) { - $rasterizer = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rasterizer = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGPolygonalShapeTest.php b/tests/Nodes/Shapes/SVGPolygonalShapeTest.php index 63339ad5..044aad51 100644 --- a/tests/Nodes/Shapes/SVGPolygonalShapeTest.php +++ b/tests/Nodes/Shapes/SVGPolygonalShapeTest.php @@ -1,8 +1,6 @@ getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); @@ -94,7 +94,7 @@ public function testRasterizeShouldRespectFillRule() 'foo' => 'foo', ]; foreach ($attributeToExpectedFillRule as $attribute => $expectedFillRule) { - $rasterizer = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rasterizer = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Shapes/SVGRectTest.php b/tests/Nodes/Shapes/SVGRectTest.php index f24b92c2..0100b187 100644 --- a/tests/Nodes/Shapes/SVGRectTest.php +++ b/tests/Nodes/Shapes/SVGRectTest.php @@ -1,8 +1,8 @@ setAttribute('rx', 15); $obj->setAttribute('ry', 25); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Structures/SVGDefsTest.php b/tests/Nodes/Structures/SVGDefsTest.php index 00a6e166..531a28b7 100644 --- a/tests/Nodes/Structures/SVGDefsTest.php +++ b/tests/Nodes/Structures/SVGDefsTest.php @@ -1,8 +1,9 @@ getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(SVGNode::class); $obj->addChild($mockChild); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Structures/SVGDocumentFragmentTest.php b/tests/Nodes/Structures/SVGDocumentFragmentTest.php index 7deba0a5..7bc5ca84 100644 --- a/tests/Nodes/Structures/SVGDocumentFragmentTest.php +++ b/tests/Nodes/Structures/SVGDocumentFragmentTest.php @@ -1,9 +1,10 @@ addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNodeContainer')->addChild( + $this->getMockForAbstractClass(SVGNodeContainer::class)->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNode') + $this->getMockForAbstractClass(SVGNode::class) )->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNodeContainer')->addChild( + $this->getMockForAbstractClass(SVGNodeContainer::class)->addChild( // - $expected = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode') + $expected = $this->getMockForAbstractClass(SVGNode::class) ->setAttribute('id', 'foobar') ) // @@ -227,9 +228,9 @@ public function testGetElementById() ); $obj->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNodeContainer')->addChild( + $this->getMockForAbstractClass(SVGNodeContainer::class)->addChild( // - $this->getMockForAbstractClass('\SVG\Nodes\SVGNode') + $this->getMockForAbstractClass(SVGNode::class) ->setAttribute('id', 'foobar') ) // diff --git a/tests/Nodes/Structures/SVGScriptTest.php b/tests/Nodes/Structures/SVGScriptTest.php index 4b4ba884..322a6a8d 100644 --- a/tests/Nodes/Structures/SVGScriptTest.php +++ b/tests/Nodes/Structures/SVGScriptTest.php @@ -1,8 +1,8 @@ getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Structures/SVGStyleTest.php b/tests/Nodes/Structures/SVGStyleTest.php index 161d30ac..c04b67b3 100644 --- a/tests/Nodes/Structures/SVGStyleTest.php +++ b/tests/Nodes/Structures/SVGStyleTest.php @@ -1,8 +1,8 @@ assertInstanceOf('SVG\Nodes\Structures\SVGStyle', $obj->setType('test-type')); + $this->assertInstanceOf(SVGStyle::class, $obj->setType('test-type')); $this->assertEquals('test-type', $obj->getAttribute('type')); @@ -58,7 +58,7 @@ public function testRasterize() { $obj = new SVGStyle(); - $rast = $this->getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Nodes/Texts/SVGTextTest.php b/tests/Nodes/Texts/SVGTextTest.php index b0f38b10..9cc1f695 100644 --- a/tests/Nodes/Texts/SVGTextTest.php +++ b/tests/Nodes/Texts/SVGTextTest.php @@ -1,8 +1,8 @@ getMockBuilder('\SVG\Rasterization\SVGRasterizer') + $rast = $this->getMockBuilder(SVGRasterizer::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Rasterization/Path/ArcApproximatorTest.php b/tests/Rasterization/Path/ArcApproximatorTest.php index 75efdbea..6912ca7d 100644 --- a/tests/Rasterization/Path/ArcApproximatorTest.php +++ b/tests/Rasterization/Path/ArcApproximatorTest.php @@ -1,11 +1,9 @@ getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(SVGNode::class); // should call prepareRenderParams with correct arguments - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(MultiPassRenderer::class); $obj->expects($this->once())->method('prepareRenderParams')->with( $this->identicalTo(self::$sampleOptions), - $this->isInstanceOf('\SVG\Rasterization\Transform\Transform') + $this->isInstanceOf(Transform::class) )->willReturn(self::$sampleParams); $obj->render($rasterizer, self::$sampleOptions, $node); @@ -52,11 +53,11 @@ public function testRenderShouldCallPrepare() public function testRenderShouldCallRenderFill() { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(SVGNode::class); // should call renderFill with correct fill color $node->setStyle('fill', '#AAAAAA'); - $obj = $this->getMockForAbstractClass('\SVG\Rasterization\Renderers\MultiPassRenderer'); + $obj = $this->getMockForAbstractClass(MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->once())->method('renderFill')->with( $this->isGdImage(), @@ -67,7 +68,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(MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->never())->method('renderFill'); $obj->render($rasterizer, self::$sampleOptions, $node); @@ -78,12 +79,12 @@ public function testRenderShouldCallRenderFill() public function testRenderShouldCallRenderStroke() { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(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(MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->once())->method('renderStroke')->with( $this->isGdImage(), @@ -95,7 +96,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(MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->never())->method('renderStroke'); $obj->render($rasterizer, self::$sampleOptions, $node); @@ -106,13 +107,13 @@ public function testRenderShouldCallRenderStroke() public function testRenderShouldRespectFillOpacity() { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(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(MultiPassRenderer::class); $obj->method('prepareRenderParams')->willReturn(self::$sampleParams); $obj->expects($this->once())->method('renderFill')->with( $this->isGdImage(), @@ -128,14 +129,14 @@ public function testRenderShouldRespectFillOpacity() public function testRenderShouldRespectStrokeOpacity() { $rasterizer = new \SVG\Rasterization\SVGRasterizer(10, 20, null, 100, 200); - $node = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $node = $this->getMockForAbstractClass(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(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..ee1587f9 100644 --- a/tests/Rasterization/Renderers/PolygonRendererTest.php +++ b/tests/Rasterization/Renderers/PolygonRendererTest.php @@ -1,9 +1,9 @@ getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', '#0000FF'); $context->setStyle('stroke-width', '1px'); @@ -55,7 +55,7 @@ public function testShouldRespectFillRule() { $obj = new PolygonRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(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..783b9c13 100644 --- a/tests/Rasterization/Renderers/RectRendererTest.php +++ b/tests/Rasterization/Renderers/RectRendererTest.php @@ -1,10 +1,10 @@ getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', 'none'); $context->setStyle('stroke', '#FF0000'); $context->setStyle('stroke-width', '1px'); @@ -37,7 +37,7 @@ public function testShouldRenderStrokeThick() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', 'none'); $context->setStyle('stroke', '#FF0000'); $context->setStyle('stroke-width', '3px'); @@ -56,7 +56,7 @@ public function testShouldRenderStrokeAlpha() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', 'none'); $context->setStyle('stroke', 'rgba(255, 0, 0, 0.5)'); $context->setStyle('stroke-width', '3px'); @@ -75,7 +75,7 @@ public function testShouldRenderFill() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', 'none'); @@ -93,7 +93,7 @@ public function testShouldRenderFillAlpha() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', 'rgba(255, 0, 0, 0.5)'); $context->setStyle('stroke', 'none'); @@ -111,7 +111,7 @@ public function testShouldRenderStrokeAndFill() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(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'); @@ -130,7 +130,7 @@ public function testShouldRenderStrokeRounded() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', 'none'); $context->setStyle('stroke', '#FF0000'); $context->setStyle('stroke-width', '1px'); @@ -150,7 +150,7 @@ public function testShouldRenderFillRounded() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', 'none'); @@ -169,7 +169,7 @@ public function testDoesNotRenderIfWidthZero() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', '#0000FF'); $context->setStyle('stroke-width', '1px'); @@ -189,7 +189,7 @@ public function testDoesNotRenderIfHeightZero() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(SVGNode::class); $context->setStyle('fill', '#FF0000'); $context->setStyle('stroke', '#0000FF'); $context->setStyle('stroke-width', '1px'); @@ -209,7 +209,7 @@ public function testDefaultsXAndYToZero() { $obj = new RectRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(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..3ded455d 100644 --- a/tests/Rasterization/Renderers/TextRendererTest.php +++ b/tests/Rasterization/Renderers/TextRendererTest.php @@ -3,6 +3,7 @@ namespace SVG\Rasterization\Renderers; use AssertGD\GDSimilarityConstraint; +use SVG\Nodes\SVGNode; use SVG\Rasterization\SVGRasterizer; /** @@ -17,7 +18,7 @@ public function testShouldNotFailWithoutRegisteredFont() { $obj = new TextRenderer(); - $context = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $context = $this->getMockForAbstractClass(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..b1bd2650 100644 --- a/tests/Rasterization/SVGRasterizerTest.php +++ b/tests/Rasterization/SVGRasterizerTest.php @@ -1,10 +1,10 @@ expectException('\InvalidArgumentException'); $obj = new SVGRasterizer(10, 20, [], 100, 200); - $mockChild = $this->getMockForAbstractClass('\SVG\Nodes\SVGNode'); + $mockChild = $this->getMockForAbstractClass(SVGNode::class); $obj->render('invalid_render_id', ['option' => 'value'], $mockChild); } diff --git a/tests/Rasterization/Transform/TransformParserTest.php b/tests/Rasterization/Transform/TransformParserTest.php index 5d0cb2df..9f0205e9 100644 --- a/tests/Rasterization/Transform/TransformParserTest.php +++ b/tests/Rasterization/Transform/TransformParserTest.php @@ -1,9 +1,6 @@ assertInstanceOf('SVG\Nodes\Shapes\SVGRect', $result); + $this->assertInstanceOf(SVGRect::class, $result); } public function testShouldUseGenericTypeForOthers() { $result = NodeRegistry::create('div'); - $this->assertInstanceOf('SVG\Nodes\SVGGenericNodeType', $result); + $this->assertInstanceOf(SVGGenericNodeType::class, $result); } } diff --git a/tests/Reading/SVGReaderTest.php b/tests/Reading/SVGReaderTest.php index a9fb7bbc..4abe476a 100644 --- a/tests/Reading/SVGReaderTest.php +++ b/tests/Reading/SVGReaderTest.php @@ -1,11 +1,11 @@ parseString($this->xml); - $this->assertInstanceOf('\SVG\SVG', $result); + $this->assertInstanceOf(SVG::class, $result); // should return null when parsing fails $result = $svgReader->parseString(''); diff --git a/tests/SVGTest.php b/tests/SVGTest.php index c62c41e1..6b65656b 100644 --- a/tests/SVGTest.php +++ b/tests/SVGTest.php @@ -2,6 +2,7 @@ namespace SVG; +use SVG\Nodes\Structures\SVGDocumentFragment; use SVG\SVG; /** @@ -54,7 +55,7 @@ public function testGetDocument() $doc = $image->getDocument(); // should be instanceof the correct class - $docFragClass = '\SVG\Nodes\Structures\SVGDocumentFragment'; + $docFragClass = SVGDocumentFragment::class; $this->assertInstanceOf($docFragClass, $doc); // should be set to root @@ -118,7 +119,7 @@ public function testFromString() $doc = $image->getDocument(); // should return an instance of SVG - $this->assertInstanceOf('\SVG\SVG', $image); + $this->assertInstanceOf(SVG::class, $image); // should have correct width and height $this->assertSame('37', $doc->getWidth()); @@ -127,7 +128,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::class, $image); $this->assertSame('37', $doc->getWidth()); $this->assertSame('42', $doc->getHeight()); } @@ -139,6 +140,6 @@ public function testFromFile() { $image = SVG::fromFile(__DIR__ . '/php_test.svg'); - $this->assertInstanceOf('\SVG\SVG', $image); + $this->assertInstanceOf(SVG::class, $image); } } diff --git a/tests/Utilities/Colors/ColorLookupTest.php b/tests/Utilities/Colors/ColorLookupTest.php index 499cf282..5017eac6 100644 --- a/tests/Utilities/Colors/ColorLookupTest.php +++ b/tests/Utilities/Colors/ColorLookupTest.php @@ -1,8 +1,6 @@