PHPMD - the PHP Mess Detector -- is a code quality analysis tool for PHP, similar to PMD for Java.
Questions tagged [phpmd]
80 questions
0
votes
1 answer
Does PhpStan and Psalm measures cyclomatic complexity?
I've read the documentation from PhpStan and Psalm, and i couldn't find the rules where it checks the Cyclomatic Complexity like Phpmd does here
Also, is it possible to cusomise rules within levels for PhpStan and Psalm? Looking for a source.

Mali C.
- 11
- 4
0
votes
0 answers
Should I adjust PHPMD rules to fit Symfony project?
I have created a huge symfony application with many entity and their repository classes. Some of these repository classes contain more than 10 public methods named as findAppointmentCount, findReports, etc. where I keep my queries to database.
I…

Ignas Damunskis
- 1,515
- 1
- 17
- 44
0
votes
1 answer
How to fix Avoid unused parameters PHPMD of protected method in parent class
I have two class :
class EntityVoter
{
protected function canPutToBlockChain($entity, $viewer)
{
return false;
}
}
class VerificationVoter extends EntityVoter
{
public function canPutToBlockChain($entity, $viewer)
{
…

Tom Explore
- 9
- 2
0
votes
1 answer
After sending email page is not loaded properly in Php
I am using php mail() for sending email. with this function mail is being sent properly. But after sending mail page is not not loaded properly. Actually I want to land on same page after sending email.
following is the code that I have written
if…

Dheeraj Kumar
- 112
- 8
0
votes
1 answer
Avoid using static access to class '\Illuminate\Support\Facades\Schema' in method 'up'
I'm new to Laravel Framework and php I started doing basic Laravel project and got his error message while trying to make migrations(and without changing anything in the file just open it and the error was shown): Avoid using static access to class…
user13922709
0
votes
1 answer
How to exclude class name to phpmd, cleancode ruelset?
When I run phpmd I get this error (from cleancode ruleset):
Avoid using static access to class '\Namespace\Domain\Exception\UserExceptions'
I make a phpmd.xml with this content:
…

warlock_apprentice
- 75
- 4
0
votes
1 answer
PHPMD complains about static usage of "Log"
I added phpmd to my Laravel project.
Now I have a remark about static usage of "Log".
namespace App\Http\Controllers;
use Log;
class MyController extends Controller
{
/**
* Does something
*/
public function doSomething($var)
{
Log::info('Just…

frankfurt-laravel
- 3,731
- 2
- 20
- 29
0
votes
1 answer
Take a comma separated string and add it into a command
Anyone know what I'm doing wrong here? DIFFS contains a comma-separated list of file paths after line 1 (foo/bar,baz/bat.php). If I just copy paste that into the rest of what's on line 2 in the actual terminal, I get what I expect. Doing it via the…

Peter DeMarco
- 53
- 5
0
votes
7 answers
how should remove else blocks
PHPMD is telling me that I should avoid else block in this test, but in those case, I can't find a way to remove them.
Here is the code:
if ($fight->c1 == NULL) {
if ($fight->c2 == NULL) {
// C1 and C2 Is Bye
…

Juliatzin
- 18,455
- 40
- 166
- 325
0
votes
1 answer
Explicit variable declaration when using extract()
I have the following snippet:
protected function sendEmail($email)
{
extract($email);
$this->transmail->locale($locale)
->timezone($timezone)
->template($template)
…

alariva
- 2,051
- 1
- 22
- 37
0
votes
1 answer
PHPMD (PHP Mess Detector) integration in Eclipse Mars
Before the release of Mars it was possible to install PHPMD support in Eclipse, albeit with some caveats and difficulties.
Now support from PTI seems to have been removed completely, even if development of PHPMD hasn't stopped and PHPMD does offer…

LSerni
- 55,617
- 10
- 65
- 107
0
votes
0 answers
Gitlab-CI does not find PHPMD while running test
I started to experiment with Gitlab-CI but i have some problems while running my builds. At this point i started to run PHPMD from the building using the following .gitlab-ci.yml
phpmd:
script:
- /tmp/phpmd/src/bin/phpmd app/code/local text…

Dirkos
- 488
- 1
- 10
- 33
0
votes
1 answer
Unable to set up php MessDetector in PhpStorm on mac. @echo: command not found
I've installed phpmd and I'm trying to set up PhpStorm with it. When I add the path to the phpmd.bat file in PhpStorm "Settings | PHP | Mess Detector" and press validate I get the following error:
PHP Mess Detector
phpmd:…

Swoot
- 1,304
- 11
- 12
0
votes
1 answer
Jenkins on wamp build.xml ignore my ignoring folders
I have a problem using build.xml in jenkins.
I have to exlude some directories when i exec phpmd, phpcs phpcpd, phpdoc, pdepend, phploc...
For each of these above, my --exclude or --ignore params is not working.... and my build on jenkins is so…

Greco Jonathan
- 2,517
- 2
- 29
- 54
0
votes
2 answers
PHP static code analysis - disabling false-positive warnings
On our CI servers we run PHP codesniffer and phpmd. Some of issues raised are false-positive. How can I disable certain parts of PHP file to be analysed by those (as @SupressWarning(...) in Java) ? Thanks!

FazoM
- 4,777
- 6
- 43
- 61