Output standards
| From: | Cipriano Groenendal | Date: | Thu, 11 Mar 2004 15:38:42 +0000 |
| Subject: | Output standards | ||
| Groups: | php.pear.qa | ||
| Request: | Send a blank email to pear-qa+get-913@lists.php.net to get a copy of this message | ||
Hello Group.
The reason I'm mailing is two recent posts on the pear-dev list.
The first was Sebastien Person's
Proposal for XML_RPC[1], which contained
HTML printing code.
The second Richard York's wishlist for HTML_BBCode [2], in which he asked to
change the output from HTML 4.1 to XHTML 1.1.
I'd like to propose for the QA team to set up a standard of some sort for
when/what packages may output. Not everyone is using PEAR packages to create
webpages. Console applications, GTK-PHP apps, and code which has certain
layouts to keep to can't always accept whatever the package throws at them.
As such, here's what I suggest.
* Packages MUST work quietly with error_reporting set to E_ALL.
This is obvious, and most packages already follow this.
* Packages MUST NOT output anything to the screen.
* Packages MUST only produce output from functions marked as such.
This ensures once more that no output can and will be created without the
programmer's knowledge.
For example: We could decide that only a :display() function may produce
output, or a function whose name starts with print, etc.
If a function does produce output, this should perhaps also be noted in its
phpdoc header, with an @prints tag or something similar could be used.
* Packages MAY only output HTML code if they are located within the HTML
Subtree.
There are several packages that create HTML output and print this, located
outside the HTML Subtree. The Auth package's login screen comes to mind
here, but I'm sure there's others aswell.
* Packages SHOULD only produce compatible XHTML-1.1 HTML Code.
Since XHTML is backwards compatible with HTML 4, packages should output
XHTML whenever they print something in HTML. This means <br /> and not <Br>,
<emp> instead of <B>, and <img alt='' /> tags, among others.
* Packages SHOULD NOT include formatting in their output.
* Packages SHOULD make their output easily styleable.
Adding CSS-style tags to HTML output is encouraged. This'd best be made
unique by using the package-name in their name. IE: The <input /> tag
created by the Auth package would <input style='PEAR_AUTH_INPUT'>. QF's
radio button would be style='PEAR_HTML_QUICKFORM_RADIO'. This way authors of
webpages can exactly style their behaviour.
Now I /DO/ realize that there's currently a lot of packages that cannot meet
these suggestions without massive BC break. However, they might be worth
considering for new packages/releases.
That's why I just set up some ideas I had, and am now throwing them into the
lion-pit that is PEAR-QA. Any thoughts on all of this by anyone? :)
--
Cipri
[1] http://news.php.net/article.php?group=php.pear.dev&article=26248
[2] http://news.php.net/article.php?group=php.pear.dev&article=26271)