Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.4

Bug #15690 setSameStyle() produces E_USER_NOTICE
Submitted: 2009-01-20 12:28 UTC
From: hkrems Assigned: farell
Status: Closed Package: HTML_CSS (version 1.5.2)
PHP Version: 5.2.8 OS: irrelevant
Roadmaps: (Not assigned)    
Subscription  


 [2009-01-20 12:28 UTC] hkrems (Harald Kremsner)
Description: ------------ setting a comma separated list of selectors to the same style as a previous defined style (p) results in repeated Notices: Undefined index: p in /PEAR/HTML/CSS.php on line 1535 Exchanging lines 1543 and 1544 (moving unset($this->_css[$old]); after the closing foreach ($others as $other) - bracked resolved this problem for me. hkrems$ diff /usr/lib/php/HTML/CSS.php ~/test/CSS.php 1543d1542 < unset($this->_css[$old]); 1544a1544 > unset($this->_css[$old]); Test script: --------------- <?php require_once 'HTML/CSS.php'; $css = new HTML_CSS; $css->setStyle('p','font-size','12px'); $css->setSameStyle('body, td, th, li, dt, dd', 'p'); echo '<pre>'; die(print_r($css->toInline())); ?> Expected result: ---------------- no Error p, body, td, th, li, dt, dd { font-size: 12px; } Actual result: -------------- Warning: Invalid argument supplied for foreach() in /PEAR/HTML/CSS.php on line 1535 Warning: Invalid argument supplied for foreach() in /PEAR/HTML/CSS.php on line 1535 Warning: Invalid argument supplied for foreach() in /PEAR/HTML/CSS.php on line 1535 Warning: Invalid argument supplied for foreach() in /PEAR/HTML/CSS.php on line 1535 Warning: Invalid argument supplied for foreach() in /PEAR/HTML/CSS.php on line 1535 p, body, td, th, li, dt, dd { font-size: 12px; } 1

Comments

 [2009-01-20 12:33 UTC] hkrems (Harald Kremsner)
sorry - the last line of the test script should be die(print_r($css->toString()));
 [2009-01-20 15:35 UTC] farell (Laurent Laville)
Thank you for taking the time to write to us, but this is not a bug. ================ Hello Harald, Until (in next future) it is not yet include into PEAR Manual, please read the TDG online at URI http://www.laurent-laville.org/pear/HTML_CSS/docs/TDG/en/ch05.html You should use the createGroup() and setGroupStyle() functions. I will prevent this kind of error in next version Laurent
 [2009-01-21 11:04 UTC] farell (Laurent Laville)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/HTML_CSS Even if I consider usage of setSameStyle() as bogus (see warning in new PEAR Manual, setSameStyle page Example section) ; I cannot allow such error
 [2009-01-21 12:34 UTC] hkrems (Harald Kremsner)
First - Thank You for the link to your documentation. That will help. Regarding the 'no-bug': now I get this Error : invalid input, parameter #1 "$new" was expecting "string without comma", instead got "body, td, th, li, dt, dd" which in's very nice since the API Documentation says : * Set or change the properties of new selectors * to the values of an existing selector * @param string $new New selector(s) that should share the same * definitions, separated by commas which clearly states that $new can be more than one selector, separated by commas. So by now it seems that either the API has been changed without notice or documentation or it wasn't correct since a while. Could you please send me a link to the "warning in new PEAR Manual, setSameStyle page Example section" you mentioned because I cannot find it. Best regards - Harald
 [2009-01-21 13:12 UTC] farell (Laurent Laville)
Ok, I've clarified the API doc (committed into PEAR CVS) on file CSS.php,v 1.86 BTW, I cannot provide you a link to the new PEAR Manual pages, because it's not yet available online. When the new server euk1.php.net will be replaced the current one, you can see it. In summary, I've added an example section in setSameStyle API ref page, with links as below : - see HTML_CSS::setStyle, if you want only to apply the same style as a basic selector. - see HTML_CSS::createGroup, if you want to apply the same style to a list of selectors. Hope now, all purpose are clarified