To reproduce, install PHP_CodeSniffer 1.3.5 and run $ drush dcs. Expected result is the command to work without errors, since this version of PHP_CodeSniffer is version 1.3.4 or higher. Actual result is:

No compatible version of PHP_CodeSniffer was found; you must have 1.3.4 or higher.

I've tracked down the cause and will follow up with a patch.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

decafdennis’s picture

Status: Active » Needs review
FileSize
580 bytes

The problem is that _drupalcs_get_phpcs_version_number calls on drush_shell_exec_output to get the output of the last shell command, and in that relying on _drupalcs_get_phpcs_version to call drush_shell_exec. Unfortunately, _drupalcs_get_phpcs_version statically caches its result and doesn't call drush_shell_exec a second time and therefore doesn't have the side-effect that _drupalcs_get_phpcs_version_number relies on.

The attached patch resolves that problem.

Additionally, I want suggest _drupalcs_get_phpcs_version is renamed to _drupalcs_is_phpcs_installed or that some other refactoring takes place to have things make more sense.

klausi’s picture

Status: Needs review » Needs work
+++ b/drupalcs.drush.inc
@@ -200,7 +200,7 @@ function _drupalcs_get_phpcs_version_number($path_to_phpcs) {
   if (is_null($phpcs_version_number)) {
-    $result = _drupalcs_get_phpcs_version($path_to_phpcs);
+    $result = drush_shell_exec($path_to_phpcs . ' --version');
     if ($result) {
       $phpcs_version_array = explode(' ', array_pop(drush_shell_exec_output()));
       $phpcs_version_number = $phpcs_version_array[2];

But that is the wrong fix - the function should examine the returned $result to extract the version number.

klausi’s picture

Currently _drupalcs_get_phpcs_version() returns TRUE or FALSE, but it should return the version output from phpcs. Therefore we need to use drush_shell_exec_output() in that function.

decafdennis’s picture

Status: Needs work » Needs review
FileSize
2.35 KB

The attached patch has _drupalcs_get_phpcs_version() return the version number from the output of phpcs --version, as you requested. It also gets rid of _drupalcs_get_phpcs_version_number(), which is now redundant.

klausi’s picture

Status: Needs review » Fixed

Thanks, committed!

deverman’s picture

Status: Fixed » Needs work

Hi I downloaded the dev version of this module:

---
bash-3.2$ more drupalcs.info
; This file is populated by the drupal.org packaging script with date and
; version information for downloadable releases.
name = Drupal Code Sniffer

; Information added by drupal.org packaging script on 2012-08-08
version = "7.x-1.0-beta1+10-dev"
core = "7.x"
project = "drupalcs"
datestamp = "1344384957"
---

I still get this error message. I have tried clearing the drush cache. Still get tis error message. Please let me know if there is anything I can do to fix this?

--
No compatible version of PHP_CodeSniffer was found; you must have 1.3.4 or higher. Alternatively, you can symbolically link with the following command: sudo ln -sv /Users/username/.drush/drupalcs/Drupal $(pear config-get php_dir)/PHP/CodeSniffer/Standards/Drupal

klausi’s picture

Status: Needs work » Postponed (maintainer needs more info)

What version of phpcs have you installed?

phpcs --version
klausi’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Reopen if this is still an issue.