Edit report at https://pear.php.net/bugs/bug.php?id=20357&edit=1
ID: 20357
Updated by: [email protected]
Reported By: aik dot bold at gmail dot com
Summary: The "FunctionComment" mistaking DocBlock comments
Status: Feedback
Type: Bug
Package: PHP_CodeSniffer
Operating System: Linux
Package Version: 1.5.3
PHP Version: 5.4.20
Assigned To: squiz
Roadmap Versions:
New Comment:
The 2 versions use different tokens, so you should be able to detect
which version of
the sniff to use. If you want to send me the custom sniffs you have,
I'll convert them
over for you and make sure I can detect both versions.
Previous Comments:
------------------------------------------------------------------------
[2014-08-06 09:53:42] aik099
That's what I'm afraid of. Since I'm using modified versions of comment
sniffs in my
ruleset I'm pretty sure that they'll end up in Fatal Error if I run them
via PHPCS 2.0
version.
Since I can't control what version of PHPCS people have installed
locally (or on
Scrutinizer CI), then I don't know what will happen with PHPCS 2.0
release.
Currently I have 2 comment related sniffs:
* CodingStandard_Sniffs_Commenting_FunctionCommentSniff extends
Squiz_Sniffs_Commenting_FunctionCommentSniff
* CodingStandard_Sniffs_Commenting_InlineCommentSniff implements
PHP_CodeSniffer_Sniff
Is there any way to make them work on both PHPCS 1.5.x and 2.0.x?
------------------------------------------------------------------------
[2014-08-06 00:57:27] squiz
Thanks, I can replicate it now.
This is caused by the current method of comment parsing in
PHP_CodeSniffer,
which is fairly buggy. I've rewritten this parsing, along with all the
included
commenting sniffs, in the 2.x version. Those 2.x releases don't suffer
from this
bug.
I'm not making any changes to the commenting code in the current stable
versions
at the moment because 2.0 is about to go RC this week.
Please give one of the available 2.x alpha versions a try, wait for the
RC this week,
or grab the code from the phpcs-fixer branch in Github. It's worth
making sure
you're custom ruleset is working ok with the new version as well;
especially that
custom sniff you are using.
------------------------------------------------------------------------
[2014-08-05 09:24:56] aik099
Here is full file: https://gist.github.com/aik099/ff1b4e87c73fefc17428
I've tried with both Squiz.Commenting.FunctionComment and
PEAR.Commenting.FunctionComment and got same error.
I've also included my ruleset.xml . Maybe problems hides there between
TABs (I'm
using tabs, not spaces for indentation).
------------------------------------------------------------------------
[2014-08-05 05:33:50] squiz
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: squiz
I'm not getting any unexpected errors with that code.
Do you have more code in that file? If so, do you get the same error
when you only
have that code in a file?
What standard are you using? Can you add the -s command line argument so
I can
see which sniffs are reporting the errors.
------------------------------------------------------------------------
[2014-08-04 10:39:16] aik099
Description:
------------
In case if function doesn't have DocBlock comment, then 1st
docblock comment in a function is considered as
such by mistake.
-- CODE --
class RadioGroupTest extends TypifiedElementTestCase
{
public function testGetButtonsWithName()
{
/** @var RadioGroup $radio_group */
$radio_group = $this->createElement(array('xpath'
=> self::XPATH_RADIO_GROUP));
$this->assertCount(4, $radio_group);
$this->assertInstanceOf(self::RADIO_CLASS,
$radio_group[0]);
}
}
-- CODE --
I have 2 errors reported in above code:
1. "Missing function doc comment" - on " public function
testGetButtonsWithName()" line
2. "You must use "*/" to end a function comment; found "/**
@var RadioGroup $radio_group */"" on "/** @var
RadioGroup $radio_group */" line
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=20357&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.