Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Leonid Mamchenkov:
Quick and easy introduction into PHP Mess Detector (PHPMD)
Dec 13, 2016 @ 16:07:54

Leonid Mamchenkov has posted a "quick and easy introduction" to PHPMD, the "PHP mess detector" tool. PHPMD automatically scans your code looking for potential issues including "suboptimal code, overcomplicated expressions and unused parameters, methods, properties".

PHP Mess Detector is yet another one of those tools that help to keep the code base manageable and clean. Here is how you can jump right in. It’s super easy. It only takes 6 steps.

He gives an example of it in use on a CakePHP plugin showing the process to install, execute and view the report it provides. He looks in detail at one of the issues it found, an unused local variable, and how he fixed the issue and pushed the result back to the main repository. He finishes up with some suggestions about ways to run the tool, integrating it into your automated workflow and using it on other Open Source projects to find "low hanging" issues to fix and contribute back.

tagged: phpmd mess detector tool automation introduction tutorial code quality

Link: http://mamchenkov.net/wordpress/2016/12/12/quick-and-easy-introduction-into-php-mess-detector-phpmd/

Symfony Blog:
Paving the way for Symfony 3 with the "Deprecation Detector" tool
Oct 22, 2015 @ 15:48:31

On the Symfony blog there's a post talking about a tool they've introduced that is helping to "pave the way" for the upcoming version 3 release of the Symfony framework - the Deprecation Detector tool.

Symfony 3 will be released at the end of November 2015. Learning from our own history, the transition from Symfony 2 to 3 will be much more pleasant than the transition from symfony 1 to 2 that happened in July 2011.

Technically speaking, Symfony 3 includes no new features comparing it with Symfony 2.8, which will be released at the same time. [...] This means that your Symfony applications won't work on Symfony 3 unless you remove all their deprecations. In order to simplify the task of finding which deprecations affect your applications, a new tool called Deprecation Detector has just been released.

The tool runs static analysis against your codebase and finds locations where you're using deprecated methods/classes/interfaces/etc and reports them back for fixing. The post includes the commands you'll need to get the tool installed and how to run it against your code. You can find out more about the project and get details on command line options on its GitHub repository.

tagged: deprecation detector symfony2 symfony3 method interface class service tool tutorial

Link: http://symfony.com/blog/paving-the-way-for-symfony-3-with-the-deprecation-detector-tool

QaFoo.com Blog:
Howto write a Rule for PHPMD
Mar 21, 2011 @ 14: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.

tagged: phpmd mess detector rule tutorial

Link:

Francesco Montefoschi's Blog:
PHPADD: abandoned docblocks detector
Dec 14, 2010 @ 19: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.

tagged: phpadd abandoned docblock comment detector github

Link:

Sameer Borate's Blog:
Detecting duplicate code in PHP files
Apr 08, 2009 @ 16: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.

tagged: phpcpd pear channel install tutorial copy paste detector

Link:

Sebastian Bergmann's Blog:
Copy & Paste Detection in PHPUnit 3.2
Aug 22, 2007 @ 14: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.

tagged: phpunit unittest metric software copyandpaste detection mess detector phpunit unittest metric software copyandpaste detection mess detector

Link:

Sebastian Bergmann's Blog:
Copy & Paste Detection in PHPUnit 3.2
Aug 22, 2007 @ 14: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.

tagged: phpunit unittest metric software copyandpaste detection mess detector phpunit unittest metric software copyandpaste detection mess detector

Link:


Trending Topics: