{"id":26530059,"url":"https://github.com/uzulla/phpstorm-inspect-code-cli-runner","last_synced_at":"2025-10-28T15:14:51.287Z","repository":{"id":283135311,"uuid":"950801417","full_name":"uzulla/phpstorm-inspect-code-cli-runner","owner":"uzulla","description":"CLI tool that runs PhpStorm's code inspections and outputs structured results for easier refactoring and find bugs.","archived":false,"fork":false,"pushed_at":"2025-03-18T18:24:34.000Z","size":758,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T18:50:53.606Z","etag":null,"topics":["codequality","php","phpstorm","refactoring-tools"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uzulla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-18T17:50:37.000Z","updated_at":"2025-03-18T18:24:00.000Z","dependencies_parsed_at":"2025-03-18T18:50:58.560Z","dependency_job_id":"b0b53beb-86cd-44b3-8340-321efda46fdf","html_url":"https://github.com/uzulla/phpstorm-inspect-code-cli-runner","commit_stats":null,"previous_names":["uzulla/phpstorm-inspect-code-cli-runner"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uzulla%2Fphpstorm-inspect-code-cli-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uzulla%2Fphpstorm-inspect-code-cli-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uzulla%2Fphpstorm-inspect-code-cli-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uzulla%2Fphpstorm-inspect-code-cli-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uzulla","download_url":"https://codeload.github.com/uzulla/phpstorm-inspect-code-cli-runner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244837621,"owners_count":20518664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codequality","php","phpstorm","refactoring-tools"],"created_at":"2025-03-21T17:29:20.653Z","updated_at":"2025-10-28T15:14:46.263Z","avatar_url":"https://github.com/uzulla.png","language":"PHP","readme":"# phpstorm-inspect-code-cli-runner\n\nThis package enables you to comfortably use PhpStorm as a CLI tool for static analysis.\n\n## Features\n\n* Wrapper for PhpStorm's `inspect.sh` script with additional functionality\n* Waits for PhpStorm to finish already running inspections\n* Clears PhpStorm's cache before every run to prevent stale cache issues\n* Parses XML output generated by PhpStorm and presents it in a readable form\n* Supports both text and checkstyle output formats\n* Modern PHP 8.3 implementation with Symfony Console integration\n* Tested with PHPStorm 2024.3\n\n## Installation\n\n```bash\ncomposer require shopsys/phpstorm-inspect\n```\n\n## Usage\n\n```bash\nvendor/bin/phpstorm-inspect inspect \\\n  --inspect-sh=/path/to/PhpStorm/bin/inspect.sh \\\n  --system-path=/path/to/.WebIde*/system \\\n  --project-path=/path/to/project \\\n  --profile=/path/to/project/.idea/inspectionProfiles/Project_Default.xml \\\n  --directory=/path/to/inspect \\\n  --format=text\n```\n\n### Arguments\n\n* `--inspect-sh`: Path to `inspect.sh` script\n* `--system-path`: Path to `.WebIde*/system` directory\n* `--project-path`: Path to project directory (that contains `.idea` directory)\n* `--profile`: Path to inspection profile XML file\n* `--directory`: Path in which are the inspected sources\n* `--format`: Format of output result, accepted values: \"text\" (default) / \"checkstyle\"\n\n### Environment Configuration\n\nYou can configure PhpStorm binary paths using a `.env` file:\n\n1. Copy the `.env.example` file to `.env` in the project root:\n   ```bash\n   cp .env.example .env\n   ```\n\n2. Edit the `.env` file with your specific paths:\n   ```\n   PHPSTORM_INSPECT_SH=/path/to/PhpStorm/bin/inspect.sh\n   PHPSTORM_SYSTEM_PATH=/path/to/.WebIde*/system\n   ```\n\nWhen environment variables are set, you can omit the corresponding command-line options:\n\n```bash\nvendor/bin/phpstorm-inspect inspect \\\n  --project-path=/path/to/project \\\n  --profile=/path/to/project/.idea/inspectionProfiles/Project_Default.xml \\\n  --directory=/path/to/inspect \\\n  --format=text\n```\n\n## Example Usage\n\n### Creating a Simple Inspection Profile\n\nIf you don't have an existing inspection profile, you can create a simple one:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cinspections version=\"1.0\"\u003e\n  \u003coption name=\"myName\" value=\"Project Default\" /\u003e\n  \u003cinspection_tool class=\"PhpDocMissingReturnTagInspection\" enabled=\"true\" level=\"WEAK WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpDocSignatureInspection\" enabled=\"true\" level=\"WEAK WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpMissingDocCommentInspection\" enabled=\"true\" level=\"WEAK WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpMissingParentCallCommonInspection\" enabled=\"true\" level=\"WEAK WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpMissingParentCallMagicInspection\" enabled=\"true\" level=\"WEAK WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpMultipleClassesDeclarationsInOneFile\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpRedundantCatchClauseInspection\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpSingleClassInspection\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpStanGlobal\" enabled=\"true\" level=\"WEAK WARNING\" enabled_by_default=\"true\" /\u003e\n\u003c/inspections\u003e\n```\n\nSave this to a file named `inspection-profile.xml` in your project directory.\n\n### Running the Inspection\n\nYou can run the inspection on your project's source code:\n\n```bash\nphp bin/phpstorm-inspect --project-path=$(pwd) --profile=$(pwd)/inspection-profile.xml --directory=$(pwd)/src\n```\n\n### Self-Inspection Example\n\nA good way to test the tool is to use it to inspect its own code:\n\n```bash\n# Create a simple inspection profile\ncat \u003e inspection-profile.xml \u003c\u003c 'EOF'\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cinspections version=\"1.0\"\u003e\n  \u003coption name=\"myName\" value=\"Project Default\" /\u003e\n  \u003cinspection_tool class=\"PhpDocMissingReturnTagInspection\" enabled=\"true\" level=\"WEAK WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpDocSignatureInspection\" enabled=\"true\" level=\"WEAK WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpMissingDocCommentInspection\" enabled=\"true\" level=\"WEAK WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpMissingParentCallCommonInspection\" enabled=\"true\" level=\"WEAK WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpMissingParentCallMagicInspection\" enabled=\"true\" level=\"WEAK WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpMultipleClassesDeclarationsInOneFile\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpRedundantCatchClauseInspection\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpSingleClassInspection\" enabled=\"true\" level=\"WARNING\" enabled_by_default=\"true\" /\u003e\n  \u003cinspection_tool class=\"PhpStanGlobal\" enabled=\"true\" level=\"WEAK WARNING\" enabled_by_default=\"true\" /\u003e\n\u003c/inspections\u003e\nEOF\n\n# Run the inspection on the tool's own code\nphp bin/phpstorm-inspect --project-path=$(pwd) --profile=$(pwd)/inspection-profile.xml --directory=$(pwd)/src\n```\n\n### Sample Output (Text Format)\n\nWhen running the self-inspection example above, you'll get output similar to this:\n\n```\nFile: /path/to/project/src/PhpStormInspect/Command/InspectCommand.php\n--------------------------------------------------------------------------------\nFound 15 problems\n--------------------------------------------------------------------------------\nLine 25: Missing PHPDoc comment: Missing PHPDoc comment for class\nLine 27: Class constant type is missing: Class constant type is missing\nLine 28: Class constant type is missing: Class constant type is missing\nLine 30: Missing parent call for method: Missing parent method call\nLine 30: unused declaration: Method is never used.\nLine 72: Missing parent call for method: Missing parent method call\nLine 72: unused declaration: Method is never used.\nLine 83: Fully qualified name usage: Qualifier can be replaced with an import\nLine 89: Fully qualified name usage: Qualifier can be replaced with an import\nLine 110: Fully qualified name usage: Qualifier can be replaced with an import\nLine 120: Fully qualified name usage: Qualifier can be replaced with an import\nLine 125: Fully qualified name usage: Qualifier can be replaced with an import\nLine 142: Fully qualified name usage: Qualifier can be replaced with an import\nLine 152: Fully qualified name usage: Qualifier can be replaced with an import\nLine 165: Fully qualified name usage: Qualifier can be replaced with an import\n--------------------------------------------------------------------------------\n\nFile: /path/to/project/src/PhpStormInspect/Inspection/InspectionRunner.php\n--------------------------------------------------------------------------------\nFound 5 problems\n--------------------------------------------------------------------------------\nLine 10: Missing PHPDoc comment: Missing PHPDoc comment for class\nLine 12: Class constant type is missing: Class constant type is missing\nLine 13: Class constant type is missing: Class constant type is missing\nLine 69: Fully qualified name usage: Qualifier can be replaced with an import\nLine 73: Fully qualified name usage: Qualifier can be replaced with an import\n--------------------------------------------------------------------------------\n\n... (more files and issues) ...\n```\n\nThis output shows various code quality issues that PhpStorm's inspection has found, such as:\n- Missing PHPDoc comments\n- Missing class constant types\n- Missing parent method calls\n- Fully qualified name usage that could be replaced with imports\n- Unused declarations\n- And more\n\n### Sample Output (Checkstyle Format)\n\nYou can also get the output in checkstyle format, which is useful for integration with CI tools:\n\n```bash\nphp bin/phpstorm-inspect --project-path=$(pwd) --profile=$(pwd)/inspection-profile.xml --directory=$(pwd)/src --format=checkstyle\n```\n\nOutput:\n\n```xml\n\u003c?xml version=\"1.0\"?\u003e\n\u003ccheckstyle version=\"1.0.0\"\u003e\n  \u003cfile name=\"/path/to/project/src/PhpStormInspect/Command/InspectCommand.php\"\u003e\n    \u003cerror line=\"25\" column=\"0\" severity=\"weak warning\" message=\"Missing PHPDoc comment for class\"/\u003e\n    \u003cerror line=\"27\" column=\"0\" severity=\"weak warning\" message=\"Class constant type is missing\"/\u003e\n    \u003cerror line=\"28\" column=\"0\" severity=\"weak warning\" message=\"Class constant type is missing\"/\u003e\n    \u003cerror line=\"30\" column=\"0\" severity=\"weak warning\" message=\"Missing parent method call\"/\u003e\n    \u003cerror line=\"30\" column=\"0\" severity=\"weak warning\" message=\"Method is never used.\"/\u003e\n    \u003c!-- More errors... --\u003e\n  \u003c/file\u003e\n  \u003cfile name=\"/path/to/project/src/PhpStormInspect/Inspection/InspectionRunner.php\"\u003e\n    \u003cerror line=\"10\" column=\"0\" severity=\"weak warning\" message=\"Missing PHPDoc comment for class\"/\u003e\n    \u003cerror line=\"12\" column=\"0\" severity=\"weak warning\" message=\"Class constant type is missing\"/\u003e\n    \u003cerror line=\"13\" column=\"0\" severity=\"weak warning\" message=\"Class constant type is missing\"/\u003e\n    \u003cerror line=\"69\" column=\"0\" severity=\"weak warning\" message=\"Qualifier can be replaced with an import\"/\u003e\n    \u003cerror line=\"73\" column=\"0\" severity=\"weak warning\" message=\"Qualifier can be replaced with an import\"/\u003e\n  \u003c/file\u003e\n  \u003c!-- More files... --\u003e\n\u003c/checkstyle\u003e\n```\n\nThe checkstyle format is particularly useful for integrating with CI/CD pipelines and other tools that can process this standard format.\n\n## Tips for Effective Usage\n\n### Customizing Inspection Profiles\n\nFor more comprehensive code quality checks, you can create a custom inspection profile in PhpStorm:\n\n1. Open your project in PhpStorm\n2. Go to Settings/Preferences → Editor → Inspections\n3. Configure the inspections you want to enable/disable\n4. Click the gear icon and select \"Export\" to save your profile as an XML file\n5. Use this exported file with the `--profile` option\n\n### Integrating with CI/CD\n\nTo integrate with CI/CD pipelines:\n\n1. Use the checkstyle output format (`--format=checkstyle`)\n2. Save the output to a file: `php bin/phpstorm-inspect ... --format=checkstyle \u003e phpstorm-inspection.xml`\n3. Use a tool like [checkstyle-formatter](https://www.npmjs.com/package/checkstyle-formatter) to convert the output to HTML or other formats\n4. Configure your CI system to fail the build if certain types or numbers of issues are found\n\n### Performance Considerations\n\n- The first run may take longer as PhpStorm builds its indexes\n- For large projects, consider inspecting specific directories rather than the entire project\n- Clearing the cache (which this tool does automatically) helps prevent stale cache issues but may increase inspection time\n\n## License\n\nMIT License (see LICENSE file)\n\n\u003e This is a modernized version of [shopsys/phpstorm-inspect](https://github.com/shopsys/phpstorm-inspect) updated for PHP 8.3.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuzulla%2Fphpstorm-inspect-code-cli-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuzulla%2Fphpstorm-inspect-code-cli-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuzulla%2Fphpstorm-inspect-code-cli-runner/lists"}