TheBitBang / php-svg-framework-SVGF

SVGF (Scalable Vector Graphics Framework) is a PHP library for creating and modifying SVG files.
https://packagist.org/packages/the-bit-bang/php-svg-framework-svgf
MIT License
30 stars 4 forks source link

Error in examples #2

Open anJka opened 5 years ago

anJka commented 5 years ago

Hello running the examples I get error (PHP 7.3): php-svg-framework-SVGF/examples/BasicShapesExample.php

_Notice: Undefined variable: attribute_value in /opt/lampp/htdocs/dev/php-svg-framework-SVGF/src/css/CSSStyleDeclaration.php on line 168

Notice: Undefined variable: item in /opt/lampp/htdocs/dev/php-svg-framework-SVGF/src/svgf/SVGFElement.php on line 69

Fatal error: Uncaught Error: Using $this when not in object context in /opt/lampp/htdocs/dev/php-svg-framework-SVGF/src/svg/SVGElement.php:23 Stack trace: #0 [internal function]: b1t\svg\SVGSVGElement::setId('a4') #1 /opt/lampp/htdocs/dev/php-svg-framework-SVGF/src/svg/SVGObject.php(62): call_user_func(Array, 'a4') #2 /opt/lampp/htdocs/dev/php-svg-framework-SVGF/src/svgf/SVGFElement.php(72): b1t\svg\SVGObject->_set('id', 'a4') #3 /opt/lampp/htdocs/dev/php-svg-framework-SVGF/examples/BasicShapesExample.php(20): b1t\svgf\SVGFElement::svg(Object(DOMDocument), 'a4', Array) #4 {main} thrown in /opt/lampp/htdocs/dev/php-svg-framework-SVGF/src/svg/SVGElement.php on line 23

xavier-atero commented 5 years ago

Hello,

I cannot reproduce the error in PHP 7.0. Based on the error log, the problem seems to happen when the id of the SVG element is set, but as I said, it works ok for me. Are the other examples working for you?

anJka commented 5 years ago

no in fact all examples throw error maybe I installed it wrong with composer?

bogart0324 commented 3 years ago

I got similar fatatFatal error: Uncaught Error: Using $this when not in object context in /opt/lampp/htdocs/php-svg/src/svg/SVGElement.php:23 Stack trace: #0 [internal function]: b1t\svg\SVGSVGElement::setId('a4') #1 /opt/lampp/htdocs/php-svg/src/svg/SVGObject.php(62): call_user_func(Array, 'a4') #2 /opt/lampp/htdocs/php-svg/src/svgf/SVGFElement.php(72): b1t\svg\SVGObject->__set('id', 'a4') #3 /opt/lampp/htdocs/php-svg/examples/BasicShapesExample.php(20): b1t\svgf\SVGFElement::svg(Object(DOMDocument), 'a4', Array) #4 {main} thrown in /opt/lampp/htdocs/php-svg/src/svg/SVGElement.php on line 23

marioschlipf commented 3 years ago

Same here. I'm looking at the code trying to fix it..

momolafrooo commented 3 years ago

me too i got the same problem who can help me ?

PulfordN commented 3 years ago

Ok the original problem is a NOTICE in statement in b1t\svgf\SVGFElement.pgo line 69

$variable = $item ?: NULL;

$item is undefined and $cariable is never use just comment it out.

PulfordN commented 3 years ago

The later problem is a call of call_user_func in b1t\svg\SVGObject.php one in the setter and one in the getter.

wanting a quick fix I did the following setter call_user_func($call_to_user_func,$attribute_value); replaced with $this->$string_set_method_name = $attribute_value;

getter return call_user_func($call_to_user_func,$attribute_value); replaced with return $this->$string_get_method_name();

It works for trhe examples