AtomLinter / linter-phpmd

Atom linter plugin for php, using phpmd.
21 stars 4 forks source link

Error When Running PHP 7.2 #116

Closed mikebronner closed 6 years ago

mikebronner commented 6 years ago

I'm receiving the following error when running linter-phpmd under PHP 7.2 in Atom:

[Linter] Error running PHPMD Error: PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /Users/mike/.composer/vendor/pdepend/pdepend/src/main/php/PDepend/Metrics/Analyzer/InheritanceAnalyzer.php on line 204
    at ChildProcess.<anonymous> (/Users/mike/.atom/packages/linter-phpcs/node_modules/sb-exec/lib/index.js:56:20)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:885:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)

I didn't seem to get this error when running PHPMD from the commandline.

linter-phpmd: 2.0.0 phpmd: 2.6.0 atom: 1.22.1

Arcanemagus commented 6 years ago

From the error it looks like one of phpmd's dependencies (pdepend) doesn't support PHP 7.2 yet, you'll need to downgrade (or check for updates to phpmd?) until that dependency updates.

You should be seeing the same issue when running phpmd on the CLI.

mikebronner commented 6 years ago

Wonder why it says childprocess linter-phpcs ... i'll check that as well. But the error notification in Atom clearly said PHPMD. But yea, command-line works without error.

Arcanemagus commented 6 years ago

Most of the linter-* providers use the same library to run external tools. In this case Atom is simply using the instance from linter-phpcs which it already loaded for linter-phpmd since they use the same one.

Arcanemagus commented 6 years ago

But yea, command-line works without error.

That doesn't make any sense.... do you have multiple php versions on your system?

If you close all instances of Atom and launch it from the CLI where phpmd is working (atom .) does it work?

mikebronner commented 6 years ago

phpmd app text cleancode, codesize, controversial, design, naming, unusedcode produces the following output:

/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/Auth/RegisterController.php:50     Avoid using static access to class '\Illuminate\Support\Facades\Validator' in method 'validator'.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/Auth/RegisterController.php:65     Avoid using static access to class '\App\User' in method 'create'.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/CemeteryRecordCsvExportController.php:30   Avoid using static access to class '\League\Csv\Writer' in method 'store'.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/CemeteryRecordsPageController.php:36       The method index uses an else expression. Else is never necessary and you can simplify the code to work without else.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/CemeteryRecordsPageController.php:55       The method index uses an else expression. Else is never necessary and you can simplify the code to work without else.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/CemeteryRecordsPageController.php:60       The method index uses an else expression. Else is never necessary and you can simplify the code to work without else.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/CemeteryRecordsPageController.php:65       The method index uses an else expression. Else is never necessary and you can simplify the code to work without else.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/EventExportController.php:16       Avoid using static access to class '\League\Csv\Writer' in method 'index'.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/FactExportController.php:16        Avoid using static access to class '\League\Csv\Writer' in method 'store'.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/GalleryCategoryExport.php:11       Avoid using static access to class '\League\Csv\Writer' in method 'show'.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/LinkPageExport.php:13      Avoid using static access to class '\League\Csv\Writer' in method 'show'.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/Member.php:136     The method index uses an else expression. Else is never necessary and you can simplify the code to work without else.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/Member.php:146     The method index uses an else expression. Else is never necessary and you can simplify the code to work without else.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/OnlineJoinPageController.php:199   The method index uses an else expression. Else is never necessary and you can simplify the code to work without else.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/OnlineJoinPageController.php:212   The method index uses an else expression. Else is never necessary and you can simplify the code to work without else.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/OnlineJoinPageController.php:261   The method index uses an else expression. Else is never necessary and you can simplify the code to work without else.
/Users/mike/Developer/Sites/ensdevc.com/app/Http/Controllers/StorePageController.php:102        The method index uses an else expression. Else is never necessary and you can simplify the code to work without else.
/Users/mike/Developer/Sites/ensdevc.com/app/Profile.php:140     The method formattedName has a boolean flag argument $showNamePrefix, which is a certain sign of a Single Responsibility Principle violation.
/Users/mike/Developer/Sites/ensdevc.com/app/Profile.php:140     The method formattedName has a boolean flag argument $showMiddleName, which is a certain sign of a Single Responsibility Principle violation.
/Users/mike/Developer/Sites/ensdevc.com/app/Profile.php:140     The method formattedName has a boolean flag argument $showNameSuffix, which is a certain sign of a Single Responsibility Principle violation.
/Users/mike/Developer/Sites/ensdevc.com/app/Providers/AppServiceProvider.php:11 Avoid using static access to class '\Braintree_Configuration' in method 'boot'.
/Users/mike/Developer/Sites/ensdevc.com/app/Providers/AppServiceProvider.php:12 Avoid using static access to class '\Braintree_Configuration' in method 'boot'.
/Users/mike/Developer/Sites/ensdevc.com/app/Providers/AppServiceProvider.php:13 Avoid using static access to class '\Braintree_Configuration' in method 'boot'.
/Users/mike/Developer/Sites/ensdevc.com/app/Providers/AppServiceProvider.php:14 Avoid using static access to class '\Braintree_Configuration' in method 'boot'.
/Users/mike/Developer/Sites/ensdevc.com/app/Providers/BroadcastServiceProvider.php:17   Avoid using static access to class '\Illuminate\Support\Facades\Broadcast' in method 'boot'.
/Users/mike/Developer/Sites/ensdevc.com/app/Services/PdfMultiCellTable.php:96   The method NbLines uses an else expression. Else is never necessary and you can simplify the code to work without else.
/Users/mike/Developer/Sites/ensdevc.com/app/Services/PdfMultiCellTable.php:103  The method NbLines uses an else expression. Else is never necessary and you can simplify the code to work without else.
/Users/mike/Developer/Sites/ensdevc.com/app/Traits/Queries/Profile.php:54       The method getEmailableMembers has a boolean flag argument $forceSendToAll, which is a certain sign of a Single Responsibility Principle violation.

But when I run phpmd resources/views/obituaries/create.blade.php text cleancode, codesize, controversial, design, naming, unusedcode, I do get the error:

PHP Warning:  count(): Parameter must be an array or an object that implements Countable in /Users/mike/.composer/vendor/pdepend/pdepend/src/main/php/PDepend/Metrics/Analyzer/InheritanceAnalyzer.php on line 204

Warning: count(): Parameter must be an array or an object that implements Countable in /Users/mike/.composer/vendor/pdepend/pdepend/src/main/php/PDepend/Metrics/Analyzer/InheritanceAnalyzer.php on line 204

It must be something specific to that file. Thanks!

Arcanemagus commented 6 years ago

Ah ha! Good to know.

Looks like this is just waiting on phpmd to update their version of pdepend: https://github.com/phpmd/phpmd/issues/501

mikebronner commented 6 years ago

Yea, was looking at that as well ... they haven't pushed an update since last January. :( In the meantime have reverted back to 7.1. Plenty of issues open there related to this problem. Hoping they can fix it soon. :)