View Source

<ac:macro ac:name="note"><ac:parameter ac:name="title">Under Construction</ac:parameter><ac:rich-text-body>
<p>This proposal is under construction and is not ready for review.</p></ac:rich-text-body></ac:macro>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

{zone-data:component-name}
Zend_Pmd
{zone-data}

{zone-data:proposer-list}
[jakub.mrozek@gmail.com|mailto:jakub.mrozek@gmail.com]
{zone-data}

{zone-data:revision}

{zone-data}

{zone-data:overview}
Zend_Pmd is Zend Framework coding standards checker. This component helps your developer team keep the same coding standards.
{zone-data}

{zone-data:references}
* [PMD for Java programmers|http://pmd.sourceforge.net/]
{zone-data}

{zone-data:requirements}
{zone-data}

{zone-data:dependencies}
* Zend_Exception
* Zend_Loader
{zone-data}

{zone-data:operation}
{zone-data}

{zone-data:milestones}
{zone-data}

{zone-data:class-list}
* Zend_Pmd
* Zend_Pmd_Result
* Zend_Pmd_Exception
* Zend_Pmd_Plugins_Interface
* Zend_Pmd_Plugins_StartTag
* Zend_Pmd_Plugins_EndTag
...
{zone-data}

{zone-data:use-cases}
||UC-01||

{code}
<?php
$pmd = new Zend_Pmd('file.php');
$pmd->addPluginsDir('path/to/plugins');

//Process PMD
$pmd->process();

//Is there any warnings or errors?
if (!$num_errors = count($pmd)) {
echo 'Your PHP file is without warnings or errors!';
} else {
echo 'You have <strong>' . $num_errors . '</strong> errors and warnings' ;
}

//If you want show errors or warnings, you can do it by 2 ways:

//1. Echo results by calling __toSring() method:
//set line separator
$pmd->setLineSeparator('<br />\n');
echo $pmd;
//The output is for example:
// Line: 1, error: PHP file must start with <?php<br />\n
// Line: 18, error: dont't use else if, use elseif insted<br />\n
// Line: 332, error: PHP file cannot be ended with ?><br />\n

//2. Retrive results by foreach loop (don't call Zend_Pmd::process() first!)
foreach ($pmd as $value) {
echo 'Line: ' . $value->getLine() . ', message: ' . $value->getMessage() . '<br />\n';
}
{code}
{zone-data}

{zone-data:skeletons}
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>