Re: [PEAR-BUG] Bug #19657 [Com]: TypeHintMissing not detecting invalid phpdoc var/type combination

[email protected] ("[email protected]") Tue, 13 Nov 2012 23:06:39 +0800
Newsgroups php.pear.qa
Message-ID <[email protected]>
[PEAR-BUG] Bug #19657 [Com]: TypeHintMissing not detecting invalid phpdoc va=
r/type combination

=B7=A2=D7=D4=CE=D2=B5=C4 iPhone

=D4=DA 2012-10-19=A3=AC18:58=A3=AC"[email protected]" <pear-qa=
@lists.php.net> =D0=B4=B5=C0=A3=BA

> Edit report at https://pear.php.net/bugs/bug.php?id=3D19657&edit=3D1
>=20
> ID:               19657
> Comment by:       [email protected]
> Reported By:      david dot gray at edigitalresearch dot com
> Summary:          TypeHintMissing not detecting invalid phpdoc var/type
>                    combination
> Status:           Open
> Type:             Bug
> Package:          PHP_CodeSniffer
> Operating System: CentOS release 6.3 (Final)
> Package Version:  1.4.0
> PHP Version:      5.3.16
> Roadmap Versions:=20
> New Comment:
>=20
> Hmmm, Ignore this, seems it is working as expected, meaning it must be a
> problem with my environment:
>=20
> <?php
> /**
> * Test Class.
> */
> class Test
> {
>=20
>    /**
>     * Foobar!
>     *
>     * @param $bar string|null Something.
>     *
>     * @return null
>     */
>    public function foo($bar =3D null)
>    {
>        return $bar;
>    }
> }
> ?>
>=20
> FILE: /tmp/test/test.php
> --------------------------------------------------------------------------=
------
> FOUND 7 ERROR(S) AFFECTING 3 LINE(S)
> --------------------------------------------------------------------------=
------
>  2 | ERROR | Missing file doc comment
>  4 | ERROR | Missing @category tag in class comment
>  4 | ERROR | Missing @package tag in class comment
>  4 | ERROR | Missing @author tag in class comment
>  4 | ERROR | Missing @license tag in class comment
>  4 | ERROR | Missing @link tag in class comment
> 11 | ERROR | Doc comment for var string|null does not match actual
> variable
>    |       | name $bar at position 1
> --------------------------------------------------------------------------=
------
>=20
> "Doc comment for var string|null does not match actual variable name
> $bar at position 1" is the expected error.
>=20
>=20
> Previous Comments:
> ------------------------------------------------------------------------
>=20
> [2012-10-19 11:29:16] slydave
>=20
> Description:
> ------------
> If you get your @param var and type the wrong way around and=20
> the type contains a pipe, the warning from code sniffer is ignored=20
> - this is using the TypeHintMissing Sniff.
>=20
> Test script:
> ---------------
> Class Test {
> /**
> * Foobar!
> *=20
> * @param $bar  null|string  Something.
> *
> * @return null
> */
> public function foo($bar =3D null)
> {
> return $bar;
> }
> }
>=20
> Expected result:
> ----------------
> The pipe used to separate different possible types shouldn't=20
> cause PHPStorm to suppress the error that the var and hint are=20
> the wrong way around.
>=20
> Actual result:
> --------------
> PHPCS doesn't report any problem with the file - despite the type=20
> and var declarations are the wrong way around.
>=20
> ------------------------------------------------------------------------
>=20
>=20
> --=20
> Edit this bug report at https://pear.php.net/bugs/bug.php?id=3D19657&edit=3D=
1
>=20
> ---------------------
>=20
>=20
> --=20
> Edit this bug report at https://pear.php.net/bugs/bug.php?id=3D19657&edit=3D=
1
>=20