Ticket #444 (closed defect: fixed)
PhpCodeSnifferTask fails to generate a checkstyle-like output
| Reported by: | alex@… | Owned by: | mrook |
|---|---|---|---|
| Priority: | major | Milestone: | 2.4.1 |
| Component: | phing-tasks-ext | Version: | 2.4.0 |
| Keywords: | Cc: |
Description
I would like to use the PhpCodeSnifferTask to generate a checkstyle-like output for rendering it using phpUnderControl/CruiseControl. The phing-target I have been using so far:
<target name="code-style-report">
<phpcodesniffer standard="PEAR" showSniffs="true" showWarnings="true">
<fileset dir="${repository.wcdir}">
<patternset refid="ownCodeFiles" />
</fileset>
<formatter type="checkstyle" outfile="${project.buildlogdir}/checkstyle.xml" />
</phpcodesniffer>
</target>
But with the redone setup of my buildserver this results in a
Fatal error: Call to undefined method PHP_CodeSniffer::printCheckstyleErrorReport() in /usr/share/php/phing/tasks/ext/PhpCodeSnifferTask.php on line 319
which previously did not happen and is caused by the following method-call:
case 'checkstyle': $codeSniffer->printCheckstyleErrorReport($this->showWarnings);
Obviously the interfaces used in the phing 2.4.0 ext PhpCodeSnifferTask are outdated. Changelog: http://pear.php.net/package/PHP_CodeSniffer/download/All
Version 1.2.2 - All reports have been broken into separate classes -- Command line usage and report output remains the same
I peeked into the issue, but despite the idea to replace the call to printCheckstyleErrorReport() with a call to the new
public function generateDocs($standard, array $sniffs=array(), $generator='Text')
I had no further insights into how it would be done best. I guess there should be some correlation between the phing phpcodesniffer tasks formatter and the CodeSniffers Reports.
Attachments
Change History
comment:5 Changed 2 years ago by mrook
Your comment does not really help. Please explain in detail your issues with the new branch, we will merge this to the trunk soon.
comment:6 Changed 2 years ago by bschultz
Just for leaving a comment to your description:
The generateDocs function is NOT for generating the error reports. It only generates the documentation of the coding standard. The generating or printing of the error report is done in a separate reporting class.
comment:8 Changed 2 years ago by mrook
- Status changed from new to closed
- Resolution set to fixed
r739 adds the phpcs 1.2.2 integration to the main trunk, please test this and reopen the ticket if you continue to experience this issue.
comment:9 Changed 2 years ago by alex@…
Ok, last try:
I did test the class above from http://phing.info/trac/browser/branches/bschultz-phpcs_1.2.2 . It worked like a charm - thank you very much for your work and effort.
But your SPAM-Filter is driving me insane. And your max-posts limit is very low, too. So after 15 minutes of rewriting my reply I simply gave up on it. This is the long story behind the six words in this three posts I wrote.

Efforts are being made to integrate PhpCodeSniffer 1.2.2, see http://phing.info/trac/browser/branches/bschultz-phpcs_1.2.2