PHP Code Sniffer xml is ignoring the . dist file with rules

Asked

Viewed 9 times

-1

I’m using the package "squizlabs/php_codesniffer": "^3.6" to adjust my code using Code Sniffer in a project with Laravel 8.

But my phpcs.xml.dist file is ignoring the rules defined without php_cs.dist. Both are at the root of the project.

./phpcs.xml.dist

<?xml version="1.0" encoding="UTF-8"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
    <arg name="basepath" value="."/>
    <arg name="cache" value=".phpcs-cache"/>
    <arg name="colors"/>
    <arg name="extensions" value="php"/>
    <rule ref="PSR1"/>
    <rule ref="PSR2">
        <exclude name="PSR1.Methods.CamelCapsMethodName"/>
    </rule>
    <file>app/</file>
    <file>tests/</file>
    <exclude-pattern>vendor/</exclude-pattern>
    <exclude-pattern>database/</exclude-pattern>
    <exclude-pattern>storage/</exclude-pattern>
    <exclude-pattern>tests/TestCase.php</exclude-pattern>
</ruleset>

./php_cs.dist

<?php

$path = __DIR__ . DIRECTORY_SEPARATOR;

$finder = PhpCsFixer\Finder::create()
    ->in($path . 'application')
    ->exclude($path . 'application' . DIRECTORY_SEPARATOR . 'views')
    ->name('*.php')
    ->ignoreDotFiles(true)
    ->ignoreVCS(true);

$rules = [
    'align_multiline_comment' => true,
    ...
];

return PhpCsFixer\Config::create()
    ->setRiskyAllowed(true)
    ->setFinder($finder)
    ->setRules($rules)
    ->setHideProgress(true)
    ->setUsingCache(true);

I’m using the command to execute: php vendor/bin/phpcs and php vendor/bin/phpcbf

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.