FAQ
Edit report at http://pear.php.net/bugs/bug.php?id=11314&edit=1

ID: 11314
Updated by: sergiosgc@gmail.com
Reported By: lars at legestue dot net
Summary: Following codesniffer standards param docs mess up
-Status: Verified
+Status: Closed
Type: Bug
Package: XML_RPC2
Operating System: ir
Package Version: 1.0.1
PHP Version: 5.2.2
-Assigned To:
+Assigned To: sergiosgc
Roadmap Versions:
New Comment:

-Status: Verified
+Status: Closed
-Assigned To:
+Assigned To: sergiosgc
This bug has been fixed in SVN.

If this was a documentation problem, the fix will appear on pear.php.net
by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should
be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.




Previous Comments:
------------------------------------------------------------------------

[2008-03-19 14:06:30] dfischer

I believe this bug has to do with the .../XML/RPC2/Server/Method.php
file on lines 222-229 for version XML_RPC2_v1.0.2.

The strpos on line 222-223:
$tmp = '$' . $parameter->getName() . ' ';
if (strpos($matches[2], '$' . $tmp) === 0) {
will basically never equate to 0. It appends the '$' character twice and
would only match docstrings of the form '@param int $$myparam text'. So
the else clause on 225 is always taken. Because $tmp contains the
parameter name from your method signature (not your doc string) and $tmp
assumes you have exactly one space (not tab, not newline) after
$myparam, the substr function can sometimes truncate the string or add
extra characters.

As a current workaround, the best solution is to not bother attempting
to whitespace justify your @params. Simply put one space between tokens
like so:
/**
* does something with a string and an int
*
* @param string $mystr mystr that does something
* @param int $someinteger myint that does something
*
* @return string some string
**/
Also, your parameter name in your doc string (eg. $build) must exactly
match your method signature. That is part of the problem with Lars'
example. He has $return in the doc string but the method signature has
$credentials.

Hopefully this was helpful.

------------------------------------------------------------------------

[2007-06-13 12:37:37] lsolesen

Description:
------------
When following codesniffer standards and aligning the params in the
codeblocks XML_RPC2 messes up the descriptions. It happens when the
variable type is different lengths.

Test script:
---------------
Using this server:

<?php
/**
* Point to a problem with the autodocumentation of servers which
follows the specifications
* in PHPCodeSniffer.
*
* PHP version 5
*
* @category XML
* @package XML_RPC2
* @author Lars Olesen <lars@legestue.net>
* @copyright 2007 Lars Olesen
* @license GPL http://www.opensource.org/licenses/gpl-license.php
* @version @package-version@
* @link http://pear.php.net/package/XML_RPC2
*/
require_once 'XML/RPC2/Server.php';

/**
* The implementation
*
* @category XML
* @package XML_RPC2
* @author Lars Olesen <lars@legestue.net>
* @copyright 2007 Lars Olesen
* @license GPL http://www.opensource.org/licenses/gpl-license.php
* @version @package-version@
* @link http://pear.php.net/package/XML_RPC2
*/
class DocumentationServer {

/**
* returns something
*
* @param array $something A description
* @param string $another_thing A description of another thing
* @param boolean $return Whether to return nothing - server
doesn't care though
*
* @return string An international string
*/
public static function getSomething($something, $another_thing,
$credentials) {
return 'nothing interesting';
}

}

$options = array(
'prefix' => 'test.',
'encoding' => 'ISO-8859-1'
);

$server = XML_RPC2_Server::create('DocumentationServer', $options);
$server->handleCall();
?>

With this test:

--TEST--
Following codesniffer standards docs should still be correct
--FILE--
<?php
include('DocumentationServer.php');
?>
--EXPECT--
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/HTML;
charset=ISO-8859-1" />
<title>Available XMLRPC methods for this server</title>
<style type="text/css">
li,p { font-size: 10pt; font-family: Arial,Helvetia,sans-serif; }
a:link { background-color: white; color: blue; text-decoration:
underline; font-weight: bold; }
a:visited { background-color: white; color: blue; text-decoration:
underline; font-weight: bold; }
table { border-collapse:collapse; width: 100% }
table,td { padding: 5px; border: 1px solid black; }
div.bloc { border: 1px dashed gray; padding: 10px; margin-bottom:
20px; }
div.description { border: 1px solid black; padding: 10px; }
span.type { background-color: white; color: gray; font-weight:
normal; }
span.paratype { background-color: white; color: gray; font-weight:
normal; }
span.name { background-color: white; color: #660000; }
span.paraname { background-color: white; color: #336600; }
img { border: 0px; }
li { font-size: 12pt; }
</style>
</head>
<body>
<h1>Available XMLRPC methods for this server</h1>
<h2><a name="index">Index</a></h2>
<ul>
<li><a
href="#2d6b7f96be69b46a6523f48b4a288864">test.getSomething()</a></li>
</ul>
<h2>Details</h2>
<div class="bloc">
<h3><a name="2d6b7f96be69b46a6523f48b4a288864"><span
class="type">(string)</span> <span
class="name">test.getSomething</span><span class="other">(</span><span
class="paratype">(array) </span><span class="paraname">something</span>,
<span class="paratype">(string) </span><span
class="paraname">another_thing</span>, <span class="paratype">(boolean)
</span><span class="paraname">credentials</span><span
class="other">)</span></a></h3>
<p><b>Description :</b></p>
<div class="description">
returns something
</div>
<p><b>Parameters : </b></p>
<table>

<tr><td><b>Type</b></td><td><b>Name</b></td><td><b>Documentation</b></td></tr>
<tr><td>array</td><td>something</td><td> A
description</td></tr>
<tr><td>string</td><td>another_thing</td><td> A description of
another thing</td></tr>
<tr><td>boolean</td><td>credentials</td><td> Whether to return
nothing - server doesn't care though</td></tr>
</table>
<p>(return to <a href="#index">index</a>)</p>
</div>
</body>
</html>


Expected result:
----------------
Test should pass.

Actual result:
--------------
Test fails because the server takes one character from the variable name
and adds it to the description also.

------------------------------------------------------------------------

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppear-bugs @
categoriesphp
postedFeb 24, '11 at 8:32p
activeFeb 24, '11 at 8:32p
posts1
users1
websitepear.php.net

1 user in discussion

Sergiosgc: 1 post

People

Translate

site design / logo © 2022 Grokbase