Trying out online PHPlint tool ( http://www.icosaedro.it/phplint/phplint-on-line...
authorNick Jenkins <nickj@users.mediawiki.org>
Thu, 17 May 2007 08:05:00 +0000 (08:05 +0000)
committerNick Jenkins <nickj@users.mediawiki.org>
Thu, 17 May 2007 08:05:00 +0000 (08:05 +0000)
commitac677bf354f284cc9f56f8280db283dd3b27a534
tree1817cca4ac0a5eb34752177b6f2995aabd12af93
parent7d5558edf2c09823caccaf8d898aa68da354533e
Trying out online PHPlint tool ( icosaedro.it/phplint/phplint-on-line.html ) using the includes/Image.php file as sample input, to see what it does.

PHPlint seems to fit somewhere in the continuum between Documentation Systems and Static Code Analysis, although most of the things it found related to documentation tags (for example, it guesses a function's parameter types where they are not specified in the @param tags, based on the way the code is used). In terms of type-of-thing-found per quantity-of-output, it's much closer to a Documentation System. However, it'll also find unused variables, and a few other things in code.

However, it's quite chatty / noisy, unless you add a number of special-purpose tags & notations to define globals and specify which PHP functions are used in the code - so it's ''probably'' not currently useful for production purposes.

Some example output, plus my notes (marked as indented, with an asterisk) -
-------------------------------------------------------
We guess the method `Image::newFromName()' returns a value of type Image

77: Warning: missing `@param Title $title' in DocBlock above:
                function newFromTitle( $title ) {

81: notice: the constructor `Image' has the same name of the class. PHP 5 states it should be called `__construct()' :
                function Image( $title ) {
 * Have not changed this.

Line 101:
 * @param $ext string (without the .)
change to:
 * @param string $ext (without the .)

132: notice: from this `return' we guess the method `Image::getCacheKeys()' returns a value of type array[int]mixed

480: notice: invalid type `$', presuming mixed and trying to continue anyway - was:
 * @param $mime "text/html" etc
change to:
 * @param string $mime "text/html" etc

551: Warning: missing `@param TYPE $page' in DocBlock above
Add:
 * @param int $page Page number to find the width of.

571: Warning: missing `@param TYPE $page' in DocBlock above
Add:
 * @param int $page Page number to find the height of.

672: notice: guessed signature of the method `Image::isSafeFile()' as public boolean()
       * @public
       * @return boolean

711: Warning: missing `@param TYPE $query' in DocBlock above
 * @param string $query URL query string

759: Warning: missing `@param TYPE $thumbName' in DocBlock above
 * @param string $thumbName

798: notice: from this `return' we guess the method `Image::getTransformScript()' returns a value of type string
       * @return mixed

823: declare the return type of thumbName
       * @return string file name of a thumbnail with the specified parameters

919: notice: variable `$thumbMime' assigned but never used
919: notice: variable `$thumbExt' assigned but never used
 * deleted these local variables.

961: Warning: missing `@param TYPE $thumbName' in DocBlock above
 * @param string $thumbName File name of thumbnail.

1001: ERROR: the name `$try' is a keyword. This is deprecated by PHP and forbidden by PHPLint.
       * renamed $try to $icons.

                                          if ( $file{0} != '.' ) {
                                                     \_ HERE
1034: Warning: using deprecated character selector operator `{'. The support for this operator dropped from PHP 5.1. Use `[' instead.
       * done

1060: Warning: missing `@param TYPE $archiveFiles' in DocBlock above
1060: Warning: missing `@param TYPE $shared' in DocBlock above
 * @param array $archiveFiles
 * @param boolean $shared

1106: notice: invalid type `$', presuming mixed and trying to continue anyway
1106: notice: unknown/unexpected symbol `urlArray' in type
change from
 * @param $urlArray array
to:
 * @param array $urlArray

1204: notice: from this `return' we guess the method `Image::getFullPath()' returns a value of type string
line 1189, add:
* @return string Full filesystem path to the file.

                public static function isHashed( $shared ) {
                                                        \_ HERE
1210: Warning: missing `@param TYPE $shared' in DocBlock above
 * @param boolean $shared

                function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '', $watch = false ) {
                                              \_ HERE
1218: Warning: missing `@param TYPE $oldver' in DocBlock above
       * (whinges about other params too)
1218: notice: guessed signature of the method `Image::recordUpload()' as public boolean(mixed, mixed [, string, string, string, boolean])
 * @param string $oldver
 * @param string $desc
 * @param string $license
 * @param string $copyStatus
 * @param string $source
 * @param boolean $watch

1400: notice: from this `return' we guess the method `Image::getLinksTo()' returns a value of type array[]
1374: notice: guessed signature of the method `Image::getLinksTo()' as public array[]([string])
1374: add:
         * @return array[int]Title

1406: notice: from this `return' we guess the method `Image::getExifData()' returns a value of type array[]
1402, add:
         * @return array

1451: notice: invalid type `$', presuming mixed and trying to continue anyway
1451: notice: unknown/unexpected symbol `reason' in type
1451: notice: missing parameter $name for @param no. 1
1451: notice: unknown type/class `true'
 * @param string $reason
 * @param boolean $suppress
 * @return boolean true on success, false on some kind of failure
-------------------------------------------------------
includes/Image.php