PHP_CodeSniffer | PHP_CodeSniffer tokenizes PHP files and detects violations | Code Analyzer library

 by   squizlabs PHP Version: 3.7.2 License: BSD-3-Clause

kandi X-RAY | PHP_CodeSniffer Summary

kandi X-RAY | PHP_CodeSniffer Summary

PHP_CodeSniffer is a PHP library typically used in Code Quality, Code Analyzer applications. PHP_CodeSniffer has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

PHP_CodeSniffer is a set of two PHP scripts; the main phpcs script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second phpcbf script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              PHP_CodeSniffer has a medium active ecosystem.
              It has 10233 star(s) with 1518 fork(s). There are 204 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 257 open issues and 1988 have been closed. On average issues are closed in 264 days. There are 110 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of PHP_CodeSniffer is 3.7.2

            kandi-Quality Quality

              PHP_CodeSniffer has 0 bugs and 0 code smells.

            kandi-Security Security

              PHP_CodeSniffer has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              PHP_CodeSniffer code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              PHP_CodeSniffer is licensed under the BSD-3-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              PHP_CodeSniffer releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.
              PHP_CodeSniffer saves you 55159 person hours of effort in developing the same functionality from scratch.
              It has 68349 lines of code, 2601 functions and 1242 files.
              It has medium code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PHP_CodeSniffer
            Get all kandi verified functions for this library.

            PHP_CodeSniffer Key Features

            No Key Features are available at this moment for PHP_CodeSniffer.

            PHP_CodeSniffer Examples and Code Snippets

            No Code Snippets are available at this moment for PHP_CodeSniffer.

            Community Discussions

            QUESTION

            PHP Codesniffer phpcs: ERROR: the squizlabs/php_codesniffer/CodeSniffer.conf.dist coding standard is not installed in PhpStorm
            Asked 2022-Mar-13 at 11:20

            I have a Drupal 8 installation where I want to use the squizlabs/php_codesniffer with PhpStorm.

            I installed phpcs with Composer by following this documentation from Drupal itself https://www.drupal.org/docs/contributed-modules/code-review-module/installing-coder-sniffer#s-composer-installer-plugin. I installed it with this command composer global require drupal/coder dealerdirect/phpcodesniffer-composer-installer which also installs squizlabs/php_codesniffer. At this point everything is working and phpcs is installed in my users .composer folder.

            When I execute phpcs --config-show I get this output: (version 3.6.1)

            ...

            ANSWER

            Answered 2022-Mar-13 at 11:20

            I managed to fix it myself. For those who still need a solution I need to disappoint you. I just deleted my project and installed it again. After that the error doesn't appear anymore. This proves that phpcs or Drupal isn't the issue. It was my project setup.

            Source https://stackoverflow.com/questions/69569509

            QUESTION

            Referenced sniff "SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator" does not exist
            Asked 2022-Feb-14 at 11:59

            Just installed php_codesniffer and coder:

            ...

            ANSWER

            Answered 2022-Feb-14 at 11:59

            QUESTION

            composer.json script, returns 'event returned with error code 2', why?
            Asked 2022-Feb-09 at 22:07

            I was studying composer, and when creating this script, it returns 'event returned with error code 2', but it doesn't prevent execution, when I run it directly without composer it also works, and it doesn't give this error, I would like to know why this error occurs and how to resolve it. Thanks.

            ...

            ANSWER

            Answered 2022-Feb-09 at 22:07
            First Warning

            End of line character is invalid; expected "\n" but found "\r\n"

            Your line endings need to be LF and not CRLF, here's an article which explains the difference. If you're using VSCode then you can change the line ending in the bottom right where it uses CRLF by default. If you're not using VSCode then you will need to Google how to change the line endings for your IDE.

            Second Warning

            Expected 1 newline at end of file; 0 found

            PSR12 coding standards require an empty line at the end of your PHP files.

            Third Warning

            A closing tag is not permitted at the end of a PHP file

            PSR12 coding standards state that closing PHP tags at the end of the file should be omitted.

            Source https://stackoverflow.com/questions/71057286

            QUESTION

            why vscode phpcs extension fails after removing PEAR coding standard folder
            Asked 2022-Feb-01 at 05:05

            I was going to remove (uninstall) PEAR and Zend standards from my phpcs (provided by composer installation in my windows 11)

            according to this answer i manually deleted these two folders (PEAR and Zend) from below location:

            C:\Users\myusername\AppData\Roaming\Composer\vendor\squizlabs\php_codesniffer\src\Standards

            Now there is no PEAR and Zend in the result of phpcs -i command as expected but I've encountered below error every time I run vscode:

            ERROR: Referenced sniff "PEAR.Functions.ValidDefaultValue" does not exist Run "phpcs --help" for usage information

            https://s21.picofile.com/file/8447163976/vscode_error.PNG

            Also "PHP sniffer" extension doesn't work any more and doesn't show violations anymore in my php script!

            I checked vscode's "settings.json" file but there is not any rule containing PEAR or Zend in it!

            Further information:

            Composer is installed using compower-setup.exe file in windows 11.

            vscode version 1.63.2

            vscode extension: php Sniffer by wongjn

            What's wrong with this? was manually deleting those standard folders there right way to uninstall those standards from system?

            ...

            ANSWER

            Answered 2022-Feb-01 at 05:05

            The included coding standards all borrow from each other. PEAR is the oldest standard and so most of the newer ones build upon it, including PSR2. PSR12 then builds on PSR2. So these standards reference sniffs in other standards.

            Do not remove any folders from the core PHPCS installation, even if you don't need the standards. Especially the Generic, PEAR, and Squiz folders. You will 100% break other standards if you remove any of these.

            If you want to see what sniffs are used by a standard, you can run phpcs -e --standard=STANDARD

            For example, running phpcs -e --standard=PSR12 shows that the PSR12 standard includes 60 sniffs from 6 different standards.

            Source https://stackoverflow.com/questions/70916847

            QUESTION

            How can I install a single specific package from composer.json, to install developer tools?
            Asked 2021-Sep-09 at 14:57

            I'm using PHP_CodeSniffer in my GitLab CI/CD pipelines to ensure my code is properly formatted. The job looks like follows:

            ...

            ANSWER

            Answered 2021-Sep-08 at 14:38

            Why not download any tagged version from Github through https://github.com/squizlabs/PHP_CodeSniffer/releases, like https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.6.0/phpcs.phar?

            Using a PHAR is better than installing such stuff using Composer, as you might install other incompatible dependencies that way (this is not the case with phpcs, but other tools like phpmd install other dependencies from Symfony)

            Source https://stackoverflow.com/questions/69104456

            QUESTION

            Git Pre-Commit hook for PHPCS is giving me error in Windows for Laravel
            Asked 2021-Aug-13 at 08:43

            I have installed PHPCS from composer.json

            ...

            ANSWER

            Answered 2021-Jul-31 at 19:50

            This hook comes from "How to setup Git commit hooks for PHP " from Benjamin Delespierre.

            You have a similar example in fdemiramon gist, with the comment:

            Assumed that you have both phpcs and phpcbf in bin/ folder.
            Best practice is to use the dedicated package for phpcs: squizlabs/PHP_CodeSniffer

            That means: include a dependency for squizlabs/php_codesniffer in your composer.json file (which you did).
            For example:

            Source https://stackoverflow.com/questions/68570839

            QUESTION

            Composer/Symfony: dependency issues
            Asked 2021-May-24 at 14:48
            Context

            I'm currently working on an OroPlatform project, which is based on Symfony 4.4 and deployed on Platform.sh.

            I'm facing the following issue during the build phase of the deployment:

            • My app needs the package symfony/process 4.4.X
            • I don't know why, but on the Platform.sh server my app uses the symfony/process package installed for the composer binary installed globally, but this one is a 5.X version
            • So, I've got an error and I can't install my app because it uses the 5.X version instead of the 4.X
            • That's why I've found a workaround by using Composer 1.9.3 because it uses symfony/process 4.4.X, the same used by my app.

            It was working well, but yesterday I have to bump the composer version to latest 1.X due to the Github OAuth token changes: https://nono.ma/github-oauth-token-for-github-com-contains-invalid-characters-on-composer-install

            Issue

            So, I'm still facing this issue with the 4.X version and the 5.X version.

            I've tried to install the dependencies of my project this way : composer install -n -o -a but the bug still occurs.

            I'm looking for a way to force my project to use the dependencies located in the vendor folder of my app and not the ones installed globally. Here is a screenshot of the issue on the Platform.sh server:

            And here is a schema of the path of my app and composer on a Platform.sh server:

            ...

            ANSWER

            Answered 2021-May-23 at 17:17

            Try installing the package, so it will be added to your composer.json file.

            Source https://stackoverflow.com/questions/67657342

            QUESTION

            Can't update October CMS with "php artisan october:update" command or with Backend Function
            Asked 2021-Jan-06 at 09:19

            I can't update all of my October CMS website because I'm getting this error.

            When I use "composer install" it works fine, after "php artisan october:update" the website is broken again and I get this error message.

            Because of this problem, the plugins are not updated either.

            ...

            ANSWER

            Answered 2021-Jan-06 at 09:19

            I updated October CMS System with "composer update", but plugins with "php artisan october:update" command.

            I found solution on the docs:

            IMPORTANT: If you are using using composer do NOT run this command without first making sure that cms.disableCoreUpdates is set to true. Doing so will cause conflicts between the marketplace version of October and the version available through composer. In order to update the core October installation when using composer run composer update instead.

            So i set "disableCoreUpdates = true" on the cms config file and works fine. I can update all plugins without to update a system.

            Source https://stackoverflow.com/questions/65581990

            QUESTION

            Composer 2.0.8 issue package-versions-deprecated
            Asked 2020-Dec-17 at 14:30

            Using php 7.2

            ...

            ANSWER

            Answered 2020-Dec-17 at 14:30

            This seems to be a problem with the virtual box filesystem. I created an issue to composer and hopefully more insight will be gained.

            https://github.com/composer/package-versions-deprecated/issues/21

            Source https://stackoverflow.com/questions/65149298

            QUESTION

            PhpStorm Custom Severity Levels No Longer Function with CodeSniffer
            Asked 2020-Dec-03 at 15:48
            UPDATE (2020/12/03):

            This has been fixed in PHP Storm 2020.3

            I utilize PHP CodeSniffer and PHP Mess Detector to lint my code in PhpStorm. Until recently, I have been able to create custom severity levels (as shown below) and it will highlight my code accordingly if there is a violation.

            What I found is that if I used one of the built in severity levels (e.g. Weak Error, Error, Sever Problem), the inspections and highlighting appear as I would expect, so it is not a problem with the installation of CodeSniffer or Mess Detector.

            What I do to replicate the problem

            1. Go under Inspections -> Quality Tools -> PHP_CodeSniffer Validation
            2. Choose "Error" severity (all scopes)
            3. Linting works as configured -- see below.

            1. Click Edit Severity -> "Edit Severities" and create a custom Profile (e.g. CS Violation)
            2. Set Colors and promote severity level to the top.
            3. Click Apply
            4. Editor now says "No Violations Found" and Syntax highlighting, feedback is missing as show below.

            Question:

            Is this a known bug or are there now additional tasks that must be completed in order to use custom severity levels in PhpStorm?

            ...

            ANSWER

            Answered 2020-Jul-01 at 17:13

            It's a known issue (if I'm getting your description correctly): https://youtrack.jetbrains.com/issue/WI-52633

            Watch that ticket (star/vote/comment) to get notified on any progress.

            Source https://stackoverflow.com/questions/62681772

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install PHP_CodeSniffer

            The easiest way to get started with PHP_CodeSniffer is to download the Phar files for each of the commands:.
            The default coding standard used by PHP_CodeSniffer is the PEAR coding standard. To check a file against the PEAR coding standard, simply specify the file's location:. Or if you wish to check an entire directory you can specify the directory location instead of a file.

            Support

            The documentation for PHP_CodeSniffer is available on the Github wiki.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/squizlabs/PHP_CodeSniffer.git

          • CLI

            gh repo clone squizlabs/PHP_CodeSniffer

          • sshUrl

            git@github.com:squizlabs/PHP_CodeSniffer.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Reuse Pre-built Kits with PHP_CodeSniffer

            Consider Popular Code Analyzer Libraries

            javascript

            by airbnb

            standard

            by standard

            eslint

            by eslint

            tools

            by rome

            mypy

            by python

            Try Top Libraries by squizlabs

            HTML_CodeSniffer

            by squizlabsJavaScript

            sublime-PHP_CodeSniffer

            by squizlabsPython

            php-sikuli

            by squizlabsPHP

            Viper

            by squizlabsPHP

            bootstrap-content-templates

            by squizlabsJavaScript