Download the PHP package infocyph/phpprobe without Composer

On this page you can find all versions of the php package infocyph/phpprobe. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpprobe

PHPProbe

Security & Standards Packagist Downloads License: MIT Packagist Version Packagist PHP Version GitHub Code Size

Standalone PHP checker for syntax validation, duplicate-code detection, public API snapshot checks and comment policy checks.

PHPProbe is the checker runtime. It can be used directly as phpprobe, required by tool-combiner packages such as PHPForge, or called from PHP code through the public gateway classes.

Requirements

Install it as a Composer tool dependency:

The package ships a Composer binary:

Commands

Unknown commands print the top-level usage and exit 0. There is no separate --version command. For checker subcommands (syntax, duplicates, api, comments, check), unknown options fail with exit 2.

Onboarding (5 Minutes)

Use this flow for a fresh project:

  1. Initialize config:

  2. Run all 4 tools together:

  3. Add CI reports (optional):

  4. If your project is a library, start API baseline flow:

Tool Map

Tool Purpose Typical command
syntax PHP parse/lint errors php vendor/bin/phpprobe syntax src
duplicates clone and copy-paste detection php vendor/bin/phpprobe duplicates src
api public API drift / BC checks php vendor/bin/phpprobe api --baseline=.phpprobe-api-baseline.json src
comments TODO/FIXME markers and commented-out-code policy php vendor/bin/phpprobe comments src
check run all four together php vendor/bin/phpprobe check src tests

Quick Start

Common examples:

Detailed options and output contracts for each tool are documented in the sections below.

Public API

The package-facing checker gateways live directly under src/:

All expose:

$args is the same argument list that follows the CLI subcommand. For example:

Everything else is internal implementation detail, grouped by role:

Namespace Purpose
Api Public API snapshot extraction from parser ASTs.
Console CLI dispatch for bin/phpprobe.
Config Config lookup, preset lookup, JSON parsing, config merging and shared CLI option handling.
Detection Duplicate-code token indexing, AST block indexing, scoring, grouping and pruning.
Filesystem Git-aware PHP file discovery and path exclusion.
Process Small proc_open runner wrappers.
Util Narrow shared helpers.

Config Lookup

The default config filename is phpprobe.json.

When a checker needs a config file and --config was not passed, PHPProbe resolves it in this order:

  1. phpprobe.json in the current project root, meaning the current working directory.
  2. vendor/infocyph/phpprobe/resources/phpprobe.json under the current project root.
  3. resources/phpprobe.json only when the current project itself is infocyph/phpprobe.

If no config can be found, PHPProbe throws a runtime config error.

Preset files are bundled resources. They are resolved from:

  1. vendor/infocyph/phpprobe/resources/presets/<name>.json.
  2. resources/presets/<name>.json only while developing infocyph/phpprobe itself.

Project-root preset files are not looked up automatically.

When --config=FILE is passed explicitly and that file is missing, unreadable, empty, or invalid JSON, PHPProbe treats it as an empty config and continues with internal defaults plus any CLI options.

Config Format

The bundled resources/phpprobe.json is intentionally small:

A full project config may override any part of the selected preset:

Config keys accept snake case, kebab case and camel case. For example, min_tokens, min-tokens and minTokens are equivalent. Excludes can be configured as either exclude or exclude_paths. duplicates.ignore_fingerprints suppresses known clone fingerprints without a baseline file. comments.rules lets you toggle rule enabled and override per-rule severity.

Internal duplicate defaults, before any preset is applied, are mode=gate, normalize=true, fuzzy=false, near_miss=false, min_lines=5, min_tokens=70, min_statements=4, min_similarity=0.85, no baseline, no JSON output and no configured paths or excludes.

Internal API defaults are include_protected=true, no baseline, no JSON output and no configured paths or excludes.

Config merge order is:

  1. Internal checker defaults.
  2. Config-file preset, when present.
  3. Explicit values in the config file.
  4. CLI --preset=NAME, when present.
  5. Explicit CLI flags and CLI paths.

Local config values override the config-file preset. CLI --preset is a run-level override and can override config-file values. Explicit CLI flags still win after that.

Presets

Preset templates live in resources/presets/ and are loaded by Infocyph\PHPProbe\Config\PresetRepository.

Available presets:

Preset Duplicate policy API policy Comment policy
default Raw engine defaults. gate mode, normalized tokens, no fuzzy identifiers, no near-miss matching, min_lines=5, min_tokens=70, min_statements=4, min_similarity=0.85. Includes protected members. policy=standard, baseline thresholds (min_reason_length=12, max_allowed_block_lines=10, require_issue_for_blocks_longer_than=3).
standard Recommended balanced preset. audit mode, normalized tokens, fuzzy identifiers, near-miss matching, min_lines=5, min_tokens=90, min_statements=4, min_similarity=0.85. Includes protected members. policy=standard, baseline thresholds (12, 10, 3).
ci Quieter CI gate. gate mode, normalized tokens, fuzzy identifiers, no near-miss matching, min_lines=6, min_tokens=100, min_statements=5, min_similarity=0.9. Includes protected members. policy=standard, baseline thresholds (12, 10, 3).
strict Sensitive audit. audit mode, normalized tokens, fuzzy identifiers, near-miss matching, min_lines=4, min_tokens=70, min_statements=3, min_similarity=0.8. Includes protected members. policy=strict, strict thresholds (16, 6, 2).

The standard, ci, and strict presets include the same default syntax, duplicate, API and comment excludes:

Their duplicate sections also exclude storage/framework/views.

Preset commands:

presets prints one preset name per line. preset <name> prints the bundled JSON template. Unknown preset names print an error and exit 2. Legacy alias phpstorm is still accepted and resolves to standard.

Combined Check Command

check runs syntax, duplicates, api, and comments in sequence and returns a combined exit code.

Options:

Option Form Meaning
--config --config=FILE Read checker settings from a specific config file.
--preset --preset=NAME Apply default, standard, ci, or strict.
--format --format=text|json|markdown|sarif|github Combined output format.
--summary-json --summary-json=FILE Write combined run summary JSON.
--report-dir --report-dir=DIR Write per-checker text/json/markdown/sarif reports plus summary.json.
--changed-only flag Scan only changed PHP files from Git diff.
--changed-base --changed-base=REF Base ref used with --changed-only.
--fail-on --fail-on=error|warning|info Passed to duplicates, api, and comments.
--fail-confidence --fail-confidence=low|medium|high Passed through to comments.
--doc-mode --doc-mode=heuristic|parser|hybrid Passed through to comments.
--explain flag Passed through to comments.
--help flag Print command help.

Exit behavior:

Config Validate Command

Options:

Returns 0 for valid config, 1 for schema/key/type validation errors, and 2 for missing/unreadable/invalid JSON files.

Init Command

Options:

Doctor Command

Options:

Checks include PHP version, required extensions, config validity, and CaptainHook presence.

Syntax Checker

The syntax checker discovers PHP files, then runs PHP's native lint command against each file:

Command:

Options:

Option Form Meaning
--config --config=FILE or --config FILE Read checker settings from a specific config file.
--preset --preset=NAME or --preset NAME Apply default, standard, ci, or strict as a run-level preset.
--exclude --exclude=PATH or --exclude PATH Exclude a path. Repeatable.
--format --format=text|json|markdown|sarif|github Output format. Default is text.
--json flag Alias for --format=json.
--summary-json --summary-json=FILE Write a machine-readable run summary JSON.
--changed-only flag Scan only changed PHP files from Git diff.
--changed-base --changed-base=REF Base ref used with --changed-only.
--parallel --parallel=N Parallel lint worker count. Default is 1.
--help, -h flag Print syntax checker help and exit 0.

Path behavior:

Output and exits:

Condition Stream Exit
No PHP files found stdout: No PHP files found. plus summary 0
All files pass stdout: Syntax OK: N PHP files checked. plus summary 0
One or more files fail stderr: failing file list plus lint output 1
Unknown option or runtime config error stderr: error 2

JSON note: comment findings include confidence, subtype, explanation, suggestion, and autofix (suggestion metadata) when available. | Unknown preset | stderr: preset error | 2 |

Comment Policy Checker

The comment checker scans PHP comments using token_get_all() and reports marker tags and commented-out code policy findings.

Command:

Options:

Option Form Meaning
--config --config=FILE or --config FILE Read checker settings from a specific config file.
--preset --preset=NAME or --preset NAME Apply default, standard, ci, or strict as a run-level preset.
--exclude --exclude=PATH or --exclude PATH Exclude a path. Repeatable.
--format --format=text|json|markdown|sarif|github Output format. Default is text.
--json flag Alias for --format=json.
--strict flag Escalate commented-out-code policy severities.
--policy --policy=relaxed|standard|strict Comment policy profile.
--doc-mode --doc-mode=heuristic|parser|hybrid Doc-comment analysis mode. hybrid is default and recommended.
--baseline --baseline=FILE Suppress comment findings already present in a baseline.
--write-baseline --write-baseline or --write-baseline=FILE Write current comment findings to a baseline and exit 0.
--fail-on --fail-on=error|warning|info Control failure threshold (default: error).
--fail-confidence --fail-confidence=low|medium|high Minimum confidence level that can fail the run (default: low).
--explain flag Include why/suggestion details per finding in text/markdown output.
--summary-json --summary-json=FILE Write a machine-readable run summary JSON.
--changed-only flag Scan only changed PHP files from Git diff.
--changed-base --changed-base=REF Base ref used with --changed-only.
--tags --tags=TODO,FIXME,... Override marker tags for marker detection.
--help, -h flag Print comments checker help and exit 0.

Config-only options:

Comment policy and PHPDoc checks

  1. Marker detection: tags like TODO, FIXME, BUG, HACK, SECURITY, REVIEW, DEPRECATED.
  2. Commented-out code requires directly attached tagged reason.
  3. Long commented-out blocks require an issue reference.
  4. Oversized commented-out blocks are always reported.
  5. Dead suppressions are surfaced for cleanup.
  6. PHPDoc signatures/tag values are validated against native declarations.

Default thresholds:

Policy-to-finding mapping:

Policy Finding types
Marker detection comment_marker
Tagged reason required for commented-out code commented_out_code_without_reason, commented_out_code_without_valid_tag, commented_out_code_without_valid_reason, commented_out_code_with_weak_reason
Issue reference required for long blocks commented_out_code_requires_issue_reference
Oversized block disallowed commented_out_code_block_too_large
PHPDoc code without clear example label commented_out_code_in_phpdoc_without_example_label
Invalid suppression directive invalid_suppression_rule
Expired suppression directive expired_suppression_rule
Unused suppression directive dead_suppression_rule
PHPDoc tag/type parse issue phpdoc_invalid_tag_value
PHPDoc parameter missing from native signature phpdoc_unknown_param
Native parameter missing in PHPDoc phpdoc_missing_param
PHPDoc/native type mismatch phpdoc_signature_mismatch
Explicitly valid tagged reason (informational) commented_out_code_with_valid_reason

Inline suppression format:

Comment baseline usage:

Output and exits:

Condition Stream Exit
No failing findings at threshold stdout: summary (or JSON/markdown/SARIF) 0
Findings at or above threshold stderr: text report (or JSON on stdout) 1
Unknown option or runtime config error stderr: error 2

Public API Snapshot Checker

The API checker parses PHP files with nikic/php-parser, extracts the package-visible surface and can compare it with a saved snapshot. It is intended for library BC drift checks, not type analysis.

Command:

Options:

Option Form Meaning
--config --config=FILE or --config FILE Read checker settings from a specific config file.
--preset --preset=NAME or --preset NAME Apply default, standard, ci, or strict as a run-level preset.
--exclude --exclude=PATH or --exclude PATH Exclude a path. Repeatable.
--public-only flag Ignore protected class members.
--include-protected flag Include protected members. This is the default.
--baseline --baseline=FILE Compare the current API against a snapshot file.
--write-baseline --write-baseline, --write-baseline=FILE Write the current API snapshot and exit 0. Bare flag writes .phpprobe-api-baseline.json.
--format --format=text|json|markdown|sarif|github Output format. Default is text.
--json flag Alias for --format=json.
--fail-on --fail-on=error|warning|info Failure threshold for API drift. Default is warning.
--summary-json --summary-json=FILE Write a machine-readable run summary JSON.
--changed-only flag Scan only changed PHP files from Git diff.
--changed-base --changed-base=REF Base ref used with --changed-only.
--help, -h flag Print API checker help and exit 0.

Path behavior:

Snapshot contents:

Output and exits:

Condition Stream Exit
No baseline passed stdout: Public API snapshot OK: N symbol(s) scanned. 0
Baseline matches stdout: Public API unchanged: N symbol(s) scanned. 0
Baseline differs stderr: added/removed/changed symbol list 1 by default, 0 when --fail-on=error
--format=json|markdown|sarif|github stdout: selected format payload 0 or 1, depending on drift and fail-on
--write-baseline stdout: baseline message or JSON result 0
Unknown option or runtime config/baseline error stderr: error 2
Unknown preset stderr: preset error 2

Duplicate Checker

The duplicate checker combines token fingerprints, AST block structure, statement windows, near-miss similarity, grouping, pruning, ranking and optional baseline suppression.

Command:

Options:

Option Form Meaning
--config --config=FILE or --config FILE Read checker settings from a specific config file.
--preset --preset=NAME or --preset NAME Apply default, standard, ci, or strict as a run-level preset.
--exclude --exclude=PATH or --exclude PATH Exclude a path. Repeatable.
--mode --mode=gate or --mode=audit gate runs token matching; audit also enables statement matching and near-miss matching.
--min-lines --min-lines=N Minimum duplicated line span. Values below 1 become 1.
--min-tokens --min-tokens=N Token fingerprint window size. Values below 1 become 1.
--min-statements --min-statements=N Statement window size for audit matching. Values below 1 become 1.
--min-similarity --min-similarity=N Near-miss threshold. Accepts 0.0..1.0 or 0..100; values above 1 are treated as percentages.
--near-miss flag Enable bounded statement/shape similarity matching.
--exact flag Disable variable/literal normalization and disable fuzzy matching.
--fuzzy flag Normalize identifiers/calls as ID for renamed-code scans.
--no-fuzzy flag Disable fuzzy identifier/call normalization.
--baseline --baseline=FILE Suppress clone groups whose fingerprints are already in a baseline file.
--write-baseline --write-baseline, --write-baseline=FILE Write current clone fingerprints to a baseline and exit 0. Bare flag writes .phpprobe-duplicates-baseline.json.
--format --format=text|json|markdown|sarif|github Output format. Default is text.
--json flag Alias for --format=json.
--fail-on --fail-on=error|warning|info Failure threshold. Default is warning.
--error-duplicate-percentage --error-duplicate-percentage=N Error threshold used when --fail-on=error. Default 20.
--summary-json --summary-json=FILE Write a machine-readable run summary JSON.
--changed-only flag Scan only changed PHP files from Git diff.
--changed-base --changed-base=REF Base ref used with --changed-only.
--no-cache flag Disable duplicate result cache.
--cache-file --cache-file=FILE Duplicate result cache path.
--help, -h flag Print duplicate checker help and exit 0.

Config-only options:

Exact accepted forms matter: numeric options, --mode, --baseline and valued --write-baseline=FILE are parsed in equals form. --config, --preset and --exclude also accept split form. --write-baseline may also be passed as a bare flag.

Path behavior:

Mode behavior:

Output and exits:

Condition Stream Exit
No clone groups after baseline suppression stdout: No new duplicated code found (...) plus summary 0
Clone groups found stderr: text report plus summary 1 by default
--format=json|markdown|sarif|github stdout: selected format payload depends on clone findings and fail-on
--write-baseline stdout: baseline message or JSON result 0
Unknown option or runtime config/baseline error stderr: error 2
Unknown preset stderr: preset error 2

Duplicate Detection Details

File discovery:

Token normalization:

Token clones:

AST and statement matching:

Near-miss matching:

Grouping, pruning and scoring:

Duplicate JSON Result Shape

phpprobe duplicates --json emits:

Clone source is one of:

known_clones is populated when a duplicate baseline is read. new_clones is the number of clone groups remaining after baseline suppression.

API JSON Result Shape

phpprobe api --json emits:

Baselines

Write a baseline:

Use a baseline:

This repository does not use a duplicate baseline in CI; duplicate findings are expected to be resolved directly.

Duplicate baseline files contain:

API baseline files use the same top-level version, generated_at and symbols shape emitted under the snapshot JSON key. Missing, unreadable, or invalid baseline files now fail with exit code 2. Duplicate baseline files follow the same strict behavior: missing, unreadable, or invalid baselines fail with exit code 2.

Colored Output

Checker text output is colorized on interactive terminals:

You can override these globally for all checker text output with root-level output.colors:

Color output is automatically disabled for non-TTY streams and when NO_COLOR is set (or TERM=dumb), so CI logs and JSON output stay clean.

CI / Cloud

Workflow: .github/workflows/ci.yml

CI runs:

  1. PHPProbe matrix on PHP 8.2, 8.3, 8.4, 8.5:
    • composer validate --strict
    • composer test
    • composer lint
    • composer duplicates
    • composer api
    • composer comments
  2. PHPForge integration:
    • checks out infocyph/phpforge
    • injects local phpprobe via Composer path repository
    • runs PHPForge tests

workflow_dispatch supports phpforge_ref to test a specific PHPForge branch/tag/SHA.

Development

Composer scripts:

Script Command
composer test vendor/bin/pest -c pest.xml
composer check php bin/phpprobe check --preset=standard --config=resources/phpprobe.json src tests
composer lint php bin/phpprobe syntax src tests
composer duplicates php bin/phpprobe duplicates --preset=standard --config=resources/phpprobe.json src tests
composer api php bin/phpprobe api --config=resources/phpprobe.json src tests
composer comments php bin/phpprobe comments --config=resources/phpprobe.json src tests
composer doctor php bin/phpprobe doctor --config=resources/phpprobe.json
composer bench:comments php tools/bench-comments.php

Useful local checks:


All versions of phpprobe with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
nikic/php-parser Version ^5.7
phpstan/phpdoc-parser Version ^2.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package infocyph/phpprobe contains the following files

Loading the files please wait ...