PHPQA all-in-one Analyzer CLI tool

Overview

PHPQA

PHPQA Analyzer CLI tool

Overview

This project aims to serve as a CLI tool to make easy the use of different PHP tools related to Quality Assurance and code analysis in PHP.

Every analyzer tool handles arguments and options using different formats, the goal of this project is to provide a single way to interact with those projects, you can also set options and arguments using a default configuration file when the project supports it.

This project was originally developed as part of Drupal Console and based on the blog post Write your git hooks in PHP and keep them under git control.

Available Analyzers

  • PHP Parallel Lint

    This tool check syntax of PHP files faster then serial check with fancier output.

    PHP-Parallel-Lint

  • PHP Coding Standards Fixer

    The PHP Coding Standards Fixer tool fixes most issues in your code when you want to follow the PHP coding standards as defined in the PSR-1 and PSR-2 documents.

    PHP-CS-Fixer

  • PHP_CodeSniffer

    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.

    PHPCBF

    PHPCS

  • PHPMD - PHP Mess Detector

    It is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD. PHPMD can be seen as an user friendly and easy to configure frontend for the raw metrics measured by PHP Depend.

    PHPMD

  • PHPLOC

    phploc is a tool for quickly measuring the size and analyzing the structure of a PHP project.

    PHPLOC

  • PHPDCD - PHP Dead Code Detector

    phpdcd is a Dead Code Detector (DCD) for PHP code. It scans a PHP project for all declared functions and methods and reports those as being "dead code" that are not called at least once.

    PHPDCD

  • PHPCPD - PHP Copy/Paste Detector

    phpcpd is a Copy/Paste Detector (CPD) for PHP code.

    PHPCPD

  • PHPUnit

    PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks.

    PHPUnit

Install

Cloning the project

$ git clone [email protected]:jmolivas/phpqa.git
$ cd phpqa
# download dependencies
$ composer install
# make phpqa globally accessible creating a symlink
$ ln -s /path/to/phpqa/bin/phpqa /usr/local/bin/phpqa

Usage

Copy configuration file(s)

$ cd to/project/path
$ phpqa init --project=PROJECT --override
$ phpqa init --global --override
Option Description
project Available values php, symfony and drupal.
global Copy configuration files to user home directory, instead of current working directory.
override If this option is set, files are copied using override flag.

NOTES:

  • Option global does not accept a value must be set as --global.
  • Option override does not accept a value must be set as --override.
  • Options project and global can not used in combination.

Analyze a project

$ cd to/project/path
$ phpqa analyze --project=PROJECT --files=FILES
$ phpqa analyze --project=PROJECT --git
Option Description
project Available values php, symfony and drupal
files Files or directories to analyze.
git If this option is set, all files added to git index will be scanned. This is useful when setting executing this tool on a pre-commit git-hook.

NOTES:

  • Option git does not accept a value must be set as --git.
  • Option project could be omitted if a phpqa.yml or phpqa.yml.dist file is available at current working directory.
  • Options files and git can not used in combination.

Override configuration

This project was built to be fully customizable, you can enable/disable analyzers and modify arguments/options passed to analyzers by updating the phpqa.yml or phpqa.yml.dist file on your project root copied when running init command, or the files ~/.phpqa/php/config.yml, ~/.phpqa/symfony/config.yml or ~/.phpqa/drupal/config.yml copied when running init command using --global option.

Nice to have features

This project is a work-in-progress and needs some love related to code clean up, test coverage and documentation.

Comments
  • Same project name, same purpose?

    Same project name, same purpose?

    Hey Jesus,

    very cool project. Thank you. I just want to drop a note that a project with the name phpqa is already out there. Checkout https://github.com/EdgedesignCZ/phpqa

    Analyze PHP code with one command https://edgedesigncz.github.io/phpqa

    I just want to let you know about this. Personally i dont mind, but this might raise confusion.

    opened by andygrunwald 5
  • Update dependencies drupal/coder and squizlabs/php_codesniffer

    Update dependencies drupal/coder and squizlabs/php_codesniffer

    - jmolivas/phpqa 0.4.0 requires squizlabs/php_codesniffer 2.5.1 -> satisfiable by squizlabs/php_codesniffer[2.5.1] but these conflict with your requirements or minimum-stability.

    Could we make it squizlabs/php_codesniffer >=2.5.1 <3.0

    opened by naveenvalecha 5
  • minimum stability error

    minimum stability error

    Hi.

    Newbie here. I tried to install through composer on Fedora 22 and got an error:

      [InvalidArgumentException]                                                   
      Could not find package jmolivas/phpqa at any version for your minimum-stabi  
      lity (stable). Check the package spelling or your minimum-stability 
    

    It's very likely that I lack some configuration, but I don't know where or what to look.

    Attaching a screenshot of my console just because I can.

    nnieto mx-nnieto-lt _034

    bug 
    opened by misaelnieto 5
  • Interactive Init

    Interactive Init

    An interactive phpqa init would be great, asking to enable tools, and where their config files (or whatever makes sense config options) should be set to.

    enhancement 
    opened by dshafik 3
  • Options in phpqa.yml are not cmd options

    Options in phpqa.yml are not cmd options

    The entered options are for proc_open.

    This example needs to rewrite ...

    phpcs:
          enabled: true
          exception: false
          options:
            standard: PSR2
            severity: 0
            ignore: /vendor
          arguments:
            - '-n'
    

    ...in this one.

    phpcs:
          enabled: true
          exception: false
          arguments:
            - '--standard=PSR2'
            - '--severity=0'
            - '--ignore=/vendor'
            - '-n'
    

    Drupal 7 example:

        phpcs:
          enabled: true
          exception: false
          file:
            standard: vendor/drupal/coder/coder_sniffer/Drupal/ruleset.xml
          arguments:
            - '--extensions=php,module,inc,install,test,profile,theme'
    
    opened by tobiasbaehr 2
  • Support installation via composer

    Support installation via composer

    I'd like to add phpca to a project via composer require jmolivas/phpqa=@dev --dev

    But that errors as phpca does not find its binaries, e.g.

    [Exception]
    bin/parallel-lint do not exist!

    The binary exits in vendor/bin, also linking it to bin does not help.

    opened by fago 2
  • Project specific configuration

    Project specific configuration

    It would be great if this looked for the configuration file within the current working directory (like box, phpunit, phpdox, etc) as well as supporting both phpqa.yml and phpqa.yml.dist.

    This way I could specify the type of project, and what tools/config to use on a per-project basis.

    enhancement 
    opened by dshafik 2
  • Added MIT LICENSE file

    Added MIT LICENSE file

    In the composer.json you mark this project as MIT licensed. Sadly i can't found a LICENSE file.

    With this PR i add a LICENSE file to reflect the same license.

    opened by andygrunwald 1
  • Fixing ln -s directory path

    Fixing ln -s directory path

    If the user is already in phpqa directory due to the previous steps, it makes sense to add the ln -s starting from the current directory. Easier and the user can copy and paste.

    opened by itsdarrylnorris 1
  • Fix validation of 'git' and 'files' options

    Fix validation of 'git' and 'files' options

    I found an issue when running the analyzer the following way:

    $ bin/phpqa analyze
    

    I got a warning Undefined offset: 0, due to the logic around explode for the files option, followed by the expected exception You must set 'files' or 'git' options..

    I moved the validation and normalizing of the files option to its own class with its corresponding tests.

    I also added integration tests for the AnalyzeCommand that verify the git and files validation logic I changed.

    One thing I noticed is that currently it is not possible to write tests for the command without modifying your src or whatever folder you pass to the test. It might be a good idea to create Analyzer objects and inject them to the app in order to make them testable or create a folder for testing with fixture files.

    opened by MontealegreLuis 0
  • Add support for WordPress projects by adding PHP_CodeSniffer rules

    Add support for WordPress projects by adding PHP_CodeSniffer rules

    Add support for WordPress projects by adding PHP_CodeSniffer rules

    Third party dependency list that provides WordPress PHP_CodeSniffer rules:

    • [ ] https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards

    Feel free to suggest any other project.

    opened by jmolivas 0
Releases(0.5.0)
  • 0.5.0(Jan 25, 2017)

  • 0.4.0(Jan 1, 2017)

  • 0.3.0(Jan 1, 2017)

  • 0.2.0(Dec 31, 2016)

  • 0.1.0(Jan 7, 2016)

    c981e06 Merge pull request #20 from MontealegreLuis/master b348a7c Fix doc blocks wording. a8df850 Fix 'git' and 'files' validation. Add tests. ac52ed0 Add test to verify that either files or git options are set. d206afc Merge pull request #19 from jmolivas/validate-init-global-project-options 64435f0 Add options (project & global) validation a674c39 Add options (project & global) notes 87b2967 Merge pull request #17 from jmolivas/update-override-configuration 58eb4f2 Format init command at Override configuration 4ca0265 Merge pull request #16 from jmolivas/update-override-configuration 16440df Add --global option to Override configuration c0e1f4e Merge pull request #15 from jmolivas/update-analyze-command-git-option bf65a1f Update git option reading 2695f3d Update git InputOption definiton fcf65bf Merge pull request #14 from jmolivas/add-global-option 3c4eb0b Update global option on Readme file 7f0f067 Replace dir option with global option 52693d2 Update Copy configuration file title f293612 Update Override section 20396b8 Update Override section 0c0c366 Update TOC Nice to have features 742fb48 Update command options 98027d6 Update readme add commans options and override section 468cb63 Merge pull request #12 from bgaleotti/fix-bin fe81776 Renamed binary aaf1774 Merge pull request #11 from jmolivas/6-add-project-option-init-command 5ef30c7 #6 Add --project option to InitCommand class c48b6ee Improve AnalyzeCommand class 56915d9 #6 Enable phpcbf on drupal config 1f225d5 #6 Remove php & symfony config files 164effb Merge pull request #10 from jmolivas/6-add-dir-option-init-command 60e76e3 #6 Add dir option to init command 377ed9a Merge pull request #9 from jmolivas/update-analyze-command 70ebdf7 Fixes to AnalyzeCommand classes 018d00b Update reference to phpqa.yml 7ff36e9 Rename config.yml -> phpqa.yml e9e1189 Merge pull request #8 from jmolivas/5-project-specific-configuration 49cdb5f #5 Add per-project configuration feature ec3383b Merge pull request #7 from jmolivas/update-phpunit-file-config 1af99dd Update reference to phpunit.xml.dist 2400b6c Update phpunit.file.configuration to phpunit.xml.dist e8c42ee Rename nfig/phpunit.xml -> config/phpunit.xml.dist c3f9708 Merge pull request #3 from jongotlin/undefined-variable-fix a76b107 Removing composer installaiton until properly tested 05310b4 Prevent undefined variable 3b7b3e5 Add analyzer images 8e547fc Add docblocks 2654362 Add defaults on config->get values 75bfd87 Remove psecio/iniscan since is not a project conf check 9fd354f Exxtract and execute analyzer from configuration 5a60bd2 Nice to have features e5e5836 Rename and add to TOC Upcoming features 7ec5835 Update pdepend URL e13b119 Update PhpMetrics URL 98e9fb4 Update Add more analysers 524edd7 Update What features are planned for development? 2e87090 Remove bin/parallel-lint dec0a1a Update .gitignore file 91fad52 PHPCPD - PHP Copy/Paste Detector 5fbeabd Add Drupal project support bd93454 Add configuration files for each project 058fe5f Add analyzers phploc,phpdcd and phpcpd 3d13173 Validate error/exception message display 86b9b4a Update config files 8d6a7aa More fixes to README 6ef74ff Minor fixes to README 9a16588 Add analyzers 219b390 Add overview section and separate init and analyze commands 8145edd Add How to run to README aff8018 Merge remote-tracking branch 'origin/master' 18e2931 Refactor AnalyzeCommand Class f5f9242 Merge pull request #1 from enzolutions/master dfa9edf Update documentation 86137e6 Add how to use to readme 7be48da Update readme 110e0e8 Update composer descritpion abd6e6b Initial commit

    Source code(tar.gz)
    Source code(zip)
Owner
Jesus Manuel Olivas
Co-founder at Octahedroid. Interested in JAMstack, GatsbyJS, NextJS, GraphQL, Cloud Native Architectures, Automation and CMS.
Jesus Manuel Olivas
Analyzer of PHP code to search issues with deprecated functionality in newer interpreter versions.

PhpDeprecationDetector PhpDeprecationDetector - analyzer of PHP code to search usages of deprecated functionality in newer interpreter versions - depr

Sergey 312 Dec 26, 2022
Analyzer of PHP code to search issues with deprecated functionality in newer interpreter versions.

PhpDeprecationDetector PhpDeprecationDetector - analyzer of PHP code to search usages of deprecated functionality in newer interpreter versions - depr

Sergey 312 Dec 26, 2022
Docker-magento2 - 🐳 Docker containers with all required Magento 2 dependencies installed available as FPM through Nginx and CLI

Magento 2 Docker A collection of Docker images for running Magento 2 through nginx and on the command line. Quick Start cp composer.env.sample compose

Meanbee 454 Dec 27, 2022
All in one Video Downloader - Download videos from facebook twitter youtube tiktok and 1000+ other sites .. made by Vijay Kumar

VKRdownloader Video Downloader by @TherealVKR Vijay Kumar .... Download Video From YouTube , Facebook , Twitter , Instagram , TikTok , And 1000+ Other

Vijay Kumar 35 Dec 29, 2022
This is wegare tools but all-in-one installer only, exclude GUI

All In One Installer for Wegare Tools This is wegare tools, but this is all-in-one. Here is the source https://github.com/wegare123?tab=repositories I

Helmi Amirudin 3 Jul 29, 2022
An all-in-one package with the minimum third-party requirements to get started as quickly as possible with Pokemod Atlas

Pokemod Atlas All-In-One An all-in-one package with the minimum third-party requirements to get started as quickly as possible with Pokemod Atlas. ❤️

Pokemod 12 Oct 10, 2022
A small CLI tool to check missing dependency declarations in the composer.json and module.xml

Integrity checker Package allows to run static analysis on Magento 2 Module Packages to provide an integrity check of package. Supported tools: Compos

run_as_root GmbH 13 Dec 19, 2022
:globe_with_meridians: List of all countries with names and ISO 3166-1 codes in all languages and data formats.

symfony upgrade fixer • twig gettext extractor • wisdom • centipede • permissions handler • extraload • gravatar • locurro • country list • transliter

Saša Stamenković 5k Dec 22, 2022
The swiss army knife for Magento developers, sysadmins and devops. The tool provides a huge set of well tested command line commands which save hours of work time. All commands are extendable by a module API.

netz98 magerun CLI tools for Magento 2 The n98 magerun cli tools provides some handy tools to work with Magento from command line. Build Status Latest

netz98 758 Dec 28, 2022
PHP_Depend is an adaptation of the established Java development tool JDepend. This tool shows you the quality of your design in terms of extensibility, reusability and maintainability.

PHP Depend Documentation PHP Depend for enterprise Available as part of the Tidelift Subscription. The maintainers of PHP Depend and thousands of othe

PHP_Depend 837 Dec 14, 2022
⚙️ Web3 PHP CLI is a blazing fast blockchain server for local development.

Web3 PHP CLI is a blazing fast blockchain server for local development. This project is a work-in-progress. Code and documentation are currently under

Web3 PHP 139 Jan 6, 2023
Phalcon cli template

Phalcon cli template This is just sample boostraping application for command line applications using the outstanding Phalcon Framework. Installation J

Guilherme Viebig 9 Oct 7, 2022
Magento-bulk - Bulk Import/Export helper scripts and CLI utilities for Magento Commerce

Magento Bulk Bulk operations for Magento. Configuration Copy config.php.sample to config.php and edit it. Product Attribute Management List All Attrib

Bippo Indonesia 23 Dec 20, 2022
netz98 magerun CLI tools for Magento 1

netz98 magerun CLI tools for Magento 1 The n98 magerun cli tools provides some handy tools to work with Magento from command line. Build Status Latest

netz98 1.4k Dec 31, 2022
Import/Export configuration data in Magento 2 via CLI.

ConfigImportExport This module provides new CLI commands for Magento 2 to import/export data in/from core_config_data. This module is inspired by the

semaio 135 Dec 9, 2022
Warden is a CLI utility for orchestrating Docker based developer environments

Warden Warden is a CLI utility for orchestrating Docker based developer environments, and enables multiple local environments to run simultaneously wi

David Alger 314 Dec 2, 2022
pine - A CLI installer for timber

pine - A CLI installer for timber A CLI tool written in PHP based on symfony console to easily create a WordPress (Timber) project. Installation compo

Azeem Hassni 29 Aug 24, 2022
A PHP library that can be used manually as well as a CLI script that you can just run on your file

Run phpcs on files and only report new warnings/errors compared to the previous version. This is both a PHP library that can be used manually as well

Payton Swick 20 Aug 4, 2022