-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot add custom ruleset via .phpcs.xml.dist (try to add phpcompatibility/php-compatibility) #2776
Comments
same result with phpcs.phar version 3.5.3 |
As far as I know there's currently no way to have these paths be relative to the |
@cdayjr even if i switch to the non phar version in |
Ah, I see now. I believe
I imagine you'd get something similar. |
correction: all three types of path specification work:
|
@cdayjr oh thanks, i have seen you where faster :) as far as i read the code, the problem is, that the current code only allows to load code from another phar file if using a phar file. in
in a phar file
in if i change
|
I'm using the codacy.com code quality reporting tool.. the only error I see is
I don't know the absolute path Edit: /**
* update phpcs.xml.dist
* convert relative dirs to absolute
*
* called from post-update-cmd script
*
* @return void
*/
public static function updatePhpcsXml()
{
$phpcsPath = __DIR__ . '/../../phpcs.xml.dist';
$regex = '#(<config name="installed_paths" value=")([^"]+)#';
$xml = \file_get_contents($phpcsPath);
$xml = \preg_replace_callback($regex, function ($matches) {
$baseDir = \realpath(__DIR__ . '/../..') . '/';
$paths = \preg_split('/,\s*/', $matches[2]);
foreach ($paths as $i => $path) {
if (\strpos($path, 'vendor') === 0) {
$paths[$i] = $baseDir . $path;
}
}
return $matches[1] . \join(', ', $paths);
}, $xml);
\file_put_contents($phpcsPath, $xml);
} |
currently
should phpcs.xml installed_paths have the option to supplement command line installed paths? |
Can confirm.
Can not confirm this, it seems this suggestion (also commented in #2764) is a little brittle or outdated, at least it does not work as here in the original report, given the path starts with a dot and then the next path segment also starts with a dot (but is not a single dot alone or a double-dot path segment, like in "
Can confirm, but not for the part it would be strange. it is basically just relative to the PHP_CodeSniffer installation directory. The leading dot is the marker for being a relative path. That is perhaps non-standard (on the file-system a relative path is a path not starting with To use phpcompatibility/php-compatibility with dependencies managed by composer (vendor folder) with a relative path like in the example from @c33s :
(relative path; it is mandatory it starts with a dot " it needs to resolve on the file-system relative to the installation path of PHP_CodeSniffer by Given the
The two dir-up The following is equivalent:
(comment against PHP_CodeSniffer 3.6.0) |
related to #2764
i try to get
phpcompatibility/php-compatibility
ruleset up and running by defining theinstalled_paths
in.phpcs.xml.dist
.project root and its relevant directories:
part of the content of
.phpcs.xml.dist
tried the following paths:
none of them worked.
some sort of debug output would be awesome to see which is the base path from where i can relatively access the vendor for the php-compatibility ruleset. also it would be good to know where the the path should exactly point to.
running
php .robo/bin/phpcs.phar
correctly runs the style check with my defined rulesets (choosen from the pre installed sets) but runningphp .robo/bin/phpcs.phar -i
doesn't show the php-compat ruleset.i only get them show up if i run
php .robo/bin/phpcs.phar --config-set installed_paths C:\project1\src\.robo\vendor\phpcompatibility\php-compatibility
with an absolute path.then i get a
CodeSniffer.conf
file in.robo/bin
and i get the PHPCompatibility ruleset listedchanging the content of
CodeSniffer.conf
to a relative path'installed_paths' => '.\\.robo\\vendor\\phpcompatibility\\php-compatibility'
also don't work.any hints?
The text was updated successfully, but these errors were encountered: