News Feed

News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way Blog:
Howto write a Rule for PHPMD
March 21, 2011 @ 09:16:57

On the QaFoo blog today Manuel Pichler has written up a guide to help you write a custom rule to use with the PHP Mess Detector (PHPMD) as extended from some of the current rules (it's always easier to start from examples).

Let us start with some architecture basics behind PHPMD. All rules in PHPMD must at least implement the PHP_PMD_Rule interface. You can also extend the abstract rule base class PHP_PMD_AbstractRule which already provides an implementation of all required infrastructure methods and application logic, so that the only task which is left to you is the implementation of the concrete validation code of your rule.

He walks you through some sample code and talks about some of the common interfaces that are available to your testing. He takes one of them, IFunctionAware, and looks at it specifically, showing how to use it to detect and add violations for the validation. He includes an example of writing a rule based on an existing software metric (in this case, the number of public methods). There's also bit at the end showing how to write a rule based on the "abstract syntax tree" to be able to check just about anything in the code you're looking to test.

0 comments voice your opinion now!
phpmd mess detector rule tutorial

Francesco Montefoschi's Blog:
PHPADD abandoned docblocks detector
December 14, 2010 @ 13:34:34

Francesco Montefoschi has a recent post to his blog looking at a tool you could use to ensure the quality of your code comments - PHPADD, the abandoned docblock detector.

PHPADD can analyze a directory with PHP source code and detect (for each file, for each class, for each method) if the parameters in the function declaration are compatible with the parameters found in the docblock, reporting the outdated ones. This can be easily integrated in your build script and the result can be published in build result. Using Hudson, you just need HTML Publisher plugin.

The include the (super simple) installation instructions for pulling it in via the PEAR installer and running it on your codebase. There's even some sample output included. If you're interested in the source, check out (or fork) the latest code on github.

0 comments voice your opinion now!
phpadd abandoned docblock comment detector github

Sameer Borate's Blog:
Detecting duplicate code in PHP files
April 08, 2009 @ 11:16:17

On his blog today Sameer looks at a method for finding duplicate code in your applications with the help of PHPCPD.

Duplicated code in projects is a frequent thing and also the one ripe for factoring out in a new class or function. Cut/Paste coding is a common development practice among programmers, a lot of which can lead to code size increase and maintenance nightmares. PHPCPD (php copy paste detector) is a PEAR tool that makes it easier to detect duplicate code in php projects. Below is a short tutorial on the PHPCPD package.

You can either install the tool via a PEAR channel or directly from the github site. Once its downloaded and extracted you can immediately run it on the subdirectory of your choice. He also includes a more extended example - a search on a minimum of 5 lines of 70 tokens found to trip the filter in finding cloned functionality.

0 comments voice your opinion now!
phpcpd pear channel install tutorial copy paste detector

Sebastian Bergmann's Blog:
Copy & Paste Detection in PHPUnit 3.2
August 22, 2007 @ 09:31:00

Sebastian Bergmann spotlights another feature of the upcoming PHPUnit version 3.2 - the inclusion of a Project Mess Detector's ability to help find duplicate code.

Duplicate code can be hard to find, especially in a large project. Johann-Peter Hartmann of MAYFLOWER GmbH recently implemented Copy & Paste Detection for PHPUnit's growing set of features that extends its usage scenarios beyond "just unit testing" to a one-stop solution for quality assurance in PHP-based projects.

In his example, Sebastian shows what the response will look like when the tests find duplicate code - giving details like the files involved and the code fragment that was duplicated.

Check out this list in another post on Sebastian's blog for more of the metrics that will be included in the upcoming version.

1 comment voice your opinion now!
phpunit unittest metric software copyandpaste detection mess detector phpunit unittest metric software copyandpaste detection mess detector

Community Events

Don't see your event here?
Let us know!

performance extension community framework release introduction laravel voicesoftheelephpant library series version example opinion composer api symfony2 podcast php7 interview application

All content copyright, 2015 :: - Powered by the Solar PHP Framework