Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSSRule->__toString doesn't work with sized values #3

Closed
lieutdan13 opened this issue Dec 22, 2010 · 8 comments
Closed

CSSRule->__toString doesn't work with sized values #3

lieutdan13 opened this issue Dec 22, 2010 · 8 comments

Comments

@lieutdan13
Copy link

If I have a CSS rule as follows (this is in your example css):
div.rating-cancel,div.star-rating{width:17px;height:15px;}

The CSSRule->__toString either throws an error, or it looks like this:
width: Object;

The problem is on line 707 when it tries to implode a comma into the values. When a value is a CSSSize, it produces the above result.

For you to test this, in your CSSParserTests.php file,
change line 19 to:
$oDoc = $oParser->parse();
and add this line after the catch clause
echo $oDoc->__toString();

@sabberworm
Copy link
Contributor

The code in question is taking advantage of the fact that implode will call __toString() on any object it encounters (which is needed for all CSSValues, not just CSSSize). Unfortunately, older versions of PHP (pre-5.2) do not support this. I’m not sure whether to work around this or to mark it wontfix and set PHP 5.2 as the minimum requirement for this library.

@lieutdan13
Copy link
Author

I have fixed the issue by looping through the array and calling __toString if the element is an object, using the string if it is not, and adding commas accordingly. I can send you a diff if you would like.
I also added a few methods of my own to CSSDocument that returns a style as a string instead of the entire rule.

@sabberworm
Copy link
Contributor

I would be very interested in those changes you made to the CSSDocument. Just fork my repository and push your changes.

@lieutdan13
Copy link
Author

I think I have committed my changes. I am a noob @ both git and github, so please let me know either way if you can or cannot see my changes or if I did it incorrectly.

@sabberworm
Copy link
Contributor

You need to use the “git push” command to push changes that you’ve checked in to the github repository.

@lieutdan13
Copy link
Author

Ok. Done.

@sabberworm
Copy link
Contributor

I’ve commented on your commits. Please send a pull request after having worked through them so I can merge your changes.

@sabberworm
Copy link
Contributor

I think we’re dropping PHP pre-5.2 so I’ll close this.

TimWolla added a commit to WoltLab/PHP-CSS-Parser that referenced this issue Oct 29, 2021
> Error Message: preg_split(): Passing null to parameter MyIntervals#3 ($limit) of type int is deprecated

see MyIntervals#338

(cherry picked from commit 84b3ba7)
raxbg referenced this issue in raxbg/PHP-CSS-Parser Sep 15, 2022
> Error Message: preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated

see MyIntervals#338
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants