2017 © Pedro Peláez
 

library phpstorm-inspect

Package for running PhpStorm's inspections from CLI and displaying results

image

shopsys/phpstorm-inspect

Package for running PhpStorm's inspections from CLI and displaying results

  • Thursday, April 5, 2018
  • by sustmi
  • Repository
  • 13 Watchers
  • 34 Stars
  • 2,616 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 9 Forks
  • 4 Open issues
  • 12 Versions
  • 24 % Grown

The README.md

phpstorm-inspect

This package enables you to comfortably use PhpStorm as a CLI tool for static analysis., (*1)

Basically, it is a wrapper for PhpStorm's inspect.sh script that does some extra work: * waits for PhpStorm to finish already running inspections (because PhpStorm cannot run more instances of inspect.sh in simultaneously; see IDEA-150272) * clears PhpStorm's cache before every run in order to prevent stale cache issues (otherwise PhpStorm sometimes fails to see new files when switching GIT branches) * parses XML output generated by PhpStorm and presents it in a readable form (similar to tools like PHP CodeSniffer, PHPMD or PHP CS Fixer), (*2)

Usage

php bin/phpstorm-inspect <inspectShExecutableFilepath> <phpstormSystemPath> <projectPath> <inspectionProfileFilepath> <inspectedDirectory> [<format>]

Arguments description

  • inspectShExecutableFilepath - path to inspect.sh script
  • phpstormSystemPath - path to .WebIde*/system directory
  • projectPath - path to project directory (that contains .idea directory)
  • inspectionProfileFilepath - path to inspection profile XML file
  • inspectedDirectory - path in which are the inspected sources
  • format (optional) - format of output result, accepted values: "text" (default value) / "checkstyle"

Example (text format)

php bin/phpstorm-inspect \
  /opt/PhpStorm-139.1348/bin/inspect.sh ~/.WebIde80/system \
  . .idea/inspectionProfiles/Project_Default.xml ./src

Output

File: /home/user/project/src/MyBundle/Controller/UserController.php
--------------------------------------------------------------------------------
Found 1 problems
--------------------------------------------------------------------------------
Line 17: Undefined field: Field 'usre' not found in class
--------------------------------------------------------------------------------

File: /home/user/project/src/MyBundle/Controller/ArticleController.php
--------------------------------------------------------------------------------
Found 2 problems
--------------------------------------------------------------------------------
Line 26: Unused local variable: Unused local variable $articleId
Line 32: Unreachable statement: Unreachable statement
--------------------------------------------------------------------------------

Example (checkstyle format)

php bin/phpstorm-inspect \
  /opt/PhpStorm-139.1348/bin/inspect.sh ~/.WebIde80/system \
  . .idea/inspectionProfiles/Project_Default.xml ./src checkstyle > report.xml

Content of report.xml

<?xml version="1.0"?>
<checkstyle version="1.0.0">
    <file name="/home/user/project/src/MyBundle/Controller/UserController.php">
        <error line="17" column="0" severity="warning" message="Undefined field: Field 'usre' not found in class" />
    </file>
    <file name="/home/user/project/src/MyBundle/Controller/ArticleController.php">
        <error line="26" column="0" severity="warning" message="Unused local variable: Unused local variable $articleId" />
        <error line="32" column="0" severity="warning" message="Unreachable statement: Unreachable statement" />
    </file>
</checkstyle>

FAQ / Issues

Why should I use this package when I can simply run the inspections from IDE?

This package comes handy in environments where you do not have graphical interface., (*3)

For example, you can run static code analysis on your Continuous Integration server (eg. Jenkins)., (*4)

Does CLI inspections work when PhpStorm IDE is running?

Unfortunately not. PhpStorm currently does not support running inspect.sh script when IDE is running. You need to close the IDE when you want to run inspections from CLI., (*5)

What PhpStorm versions are supported?

The package was tested with PhpStorm 8.0 (139.732) but the newer versions will probably work too., (*6)

The Versions

05/04 2018

dev-ss-documentation-github

dev-ss-documentation-github

Package for running PhpStorm's inspections from CLI and displaying results

  Sources   Download

MIT

The Requires

 

The Development Requires

phpstorm code quality inspection

28/02 2018

dev-master

9999999-dev

Package for running PhpStorm's inspections from CLI and displaying results

  Sources   Download

MIT

The Requires

 

The Development Requires

phpstorm code quality inspection

28/02 2018

dev-ss-licence-agreement

dev-ss-licence-agreement

Package for running PhpStorm's inspections from CLI and displaying results

  Sources   Download

MIT

The Requires

 

The Development Requires

phpstorm code quality inspection

11/09 2017

v1.1.1

1.1.1.0

Package for running PhpStorm's inspections from CLI and displaying results

  Sources   Download

MIT

The Requires

 

The Development Requires

phpstorm code quality inspection

25/05 2017

v1.1.0

1.1.0.0

Package for running PhpStorm's inspections from CLI and displaying results

  Sources   Download

MIT

The Requires

 

The Development Requires

phpstorm code quality inspection

15/03 2017

v1.0.6

1.0.6.0

Package for running PhpStorm's inspections from CLI and displaying results

  Sources   Download

MIT

The Requires

 

The Development Requires

phpstorm code quality inspection

14/02 2017

v1.0.5

1.0.5.0

Run PhpStorm's inspections from CLI and show results

  Sources   Download

MIT

The Requires

 

The Development Requires

by Miroslav Sustek

20/03 2015

v1.0.4

1.0.4.0

Run PhpStorm's inspections from CLI and show results

  Sources   Download

MIT

The Requires

 

by Miroslav Sustek

17/03 2015

1.0.3

1.0.3.0

Run PhpStorm's inspections from CLI and show results

  Sources   Download

MIT

The Requires

 

by Miroslav Sustek

17/03 2015

1.0.2

1.0.2.0

Run PhpStorm's inspections from CLI and show results

  Sources   Download

MIT

The Requires

 

by Miroslav Sustek

17/03 2015

1.0.1

1.0.1.0

Run PhpStorm's inspections from CLI and show results

  Sources   Download

MIT

The Requires

 

by Miroslav Sustek

16/03 2015

1.0.0

1.0.0.0

Run PhpStorm's inspections from CLI and show results

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Miroslav Sustek