Anchor provides a suite of tools to ensure your code remains clean, consistent, and error-free.
- Development: Run
php dock formatperiodically to keep your code style consistent. - Review: Run
php dock inspectbefore committing to catch static analysis issues. - Deployment: Run
php dock sailas a final gatekeeper before merging or deploying.
The inspect command performs static analysis and coding style checks to identify issues without modifying files.
php dock inspectThis command runs:
- Pint (in test mode) to check coding standards.
- PHPStan to perform static analysis on
AppandSystemdirectories.
If any issues are found, the command will exit with a failure status and report the errors.
The format command automatically fixes coding style issues and removes unnecessary comments.
php dock format| Option | Description |
|---|---|
--dry-run |
Preview changes without modifying files |
--path |
Specify target directory (default: App, System) |
--backup |
Create .bak files before modifying |
--max-size |
Max file size in MB to process (default: 5) |
--skip-pint |
Skip running Pint after comment cleanup |
--exclude |
Directories to exclude (comma-separated) |
--show-skipped |
Show all skipped files with reasons |
The format command uses an opinionated Code Cleanup Engine that goes beyond standard indentation fixes. It aims to reduce "visual noise" by removing redundant or obvious code artifacts.
If a method has full PHP 8 type-hinting (parameters and return types), the formatter will remove docblocks that simply repeat that information.
- Redundant:
/** * @param string $name * @return void */ public function setName(string $name): void
- Preserved: Docblocks containing
@throws, complex generics (e.g.,array<string, User>), or specific architectural explanations are always kept.
The formatter identifies and removes comments that merely describe the next line of code without adding context.
- Action:
// Save userfollowed by$user->save(). - Calculation:
// Calculate totalfollowed by$total = $price * $qty.
The cleanup engine is "narrative-aware." It understands the difference between a redundant comment and a helpful explanation.
- Kept: Comments containing keywords like
because,since,workaround,hack,important,warning, ornoteare preserved as they provide valuable developer context. - Removed: Simple "Step 1", "Step 2" markers or trivial "Create instance" comments.
You can configure the formatter in .formatter.json in the project root:
{
"paths": ["App", "System"],
"backup": false,
"maxFileSize": 5,
"skipPint": false,
"exclude": ["vendor", "node_modules", "storage"]
}The sail command is the ultimate assertion of readiness for production. It runs a comprehensive suite of checks in parallel.
php dock sailThe command performs a "Pre-Flight Check" consisting of:
- Inspection Check: Runs
pint --test(Style) andformat --check(Comment Cleanup) in parallel. - Functionality Check: Runs unit tests via
pest(Correctness).
The command will only succeed if ALL checks pass. Use this command before pushing code or deploying to ensure your application is seaworthy.
Production Readiness Checks
===========================
1. Integrity & Style Inspection
Running Coding Style (Pint) and Comment Cleanup Check...
Coding Style (Pint) Passed.
Comment Cleanup Check Passed.
2. Operational Readiness & Testing
running Unit Tests...
Unit Tests Passed.
All checks passed! The application is ready for the Port (deployment). 🚀
VOYAGE CLEAR! All Inspections, Repairs, and Unit Tests passed. Vessel is cleared to set sail for the Port.