Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#4 | drupalcs-version-detection-1716000-4.patch | 2.35 KB | decafdennis |
#1 | drupalcs-version-detection-1716000-1.patch | 580 bytes | decafdennis |
Comments
Comment #1
decafdennis CreditAttribution: decafdennis commentedThe problem is that
_drupalcs_get_phpcs_version_number
calls ondrush_shell_exec_output
to get the output of the last shell command, and in that relying on_drupalcs_get_phpcs_version
to calldrush_shell_exec
. Unfortunately,_drupalcs_get_phpcs_version
statically caches its result and doesn't calldrush_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.Comment #2
klausiBut that is the wrong fix - the function should examine the returned $result to extract the version number.
Comment #3
klausiCurrently _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.
Comment #4
decafdennis CreditAttribution: decafdennis commentedThe attached patch has
_drupalcs_get_phpcs_version()
return the version number from the output ofphpcs --version
, as you requested. It also gets rid of_drupalcs_get_phpcs_version_number()
, which is now redundant.Comment #5
klausiThanks, committed!
Comment #6
deverman CreditAttribution: deverman commentedHi 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
Comment #7
klausiWhat version of phpcs have you installed?
Comment #8
klausiReopen if this is still an issue.