Skip to content

About

Ultra-fast PHP function signature extractor written in Go

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-func-parser-go

Ultra-fast PHP function signature extractor written in Go.

Build

go mod tidy
go test ./...
go build -o bin/phpfuncparser ./cmd/phpfuncparser

Usage

Scan a directory recursively and write report to a file:

./bin/phpfuncparser -path ./src -recursive -report functions.txt

Scan a single file and print to stdout:

./bin/phpfuncparser -path ./index.php

Compare two existing reports and output what was added/changed:

./bin/phpfuncparser -diff-old functions_prev.txt -diff-new functions_new.txt -report functions_delta.txt

CLI Options

-diff-old / -diff-new (diff mode)

Enables diff mode: compares two reports in the text format produced by this tool.

The output contains only the function signatures that exist in the new report but are missing from the old report.

This catches:

  • brand new functions
  • changed signatures (params modified/added/removed)

Rules:

  • -diff-old and -diff-new must be provided together
  • -path must not be used together with diff mode

Example:

./bin/phpfuncparser -diff-old functions_prev.txt -diff-new functions_new.txt -report functions_delta.txt

-path (required)

Path to a PHP file or a directory to scan.

Examples:

./bin/phpfuncparser -path ./index.php
./bin/phpfuncparser -path ./src

-recursive (optional)

If -path points to a directory, enables recursive traversal of subdirectories.

Default: false

Example:

./bin/phpfuncparser -path ./src -recursive

-report (optional)

Output report destination.

  • If set: writes to the specified file (created or truncated).
  • If not set: prints to stdout.

Example:

./bin/phpfuncparser -path ./src -recursive -report functions.txt

-workers (optional)

Number of concurrent workers used for scanning files.

  • 0 means auto (runtime-based default).
  • For SSD/NVMe, higher values may improve throughput; for HDD/network FS, too high may degrade performance.

Default: 0

Examples:

./bin/phpfuncparser -path ./src -recursive -workers 0
./bin/phpfuncparser -path ./src -recursive -workers 16

-log (optional)

Log verbosity level.

Supported values:

  • debug
  • info
  • warn
  • error

Default: info

Examples:

./bin/phpfuncparser -path ./src -recursive -log debug
./bin/phpfuncparser -path ./src -recursive -log error

Output format

/path/to/file1.php
function foo($a, $b = 1)
function bar()

/path/to/file2.php
function baz(int $x)

Notes

  • Only named function <name>(...) declarations are reported (anonymous functions are skipped).
  • The parser is a purpose-built single-pass scanner that ignores strings and comments.
  • Logging goes to stderr; the report goes to -report or stdout.

About

Ultra-fast PHP function signature extractor written in Go

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages