ci-tools-knowledge
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "ci-tools-knowledge":https://skillpi.com/zh/skills/deepskill-58622f5457a63f0fd1ec3a4808ecf6b24723dbf557623f17194d77a147d657af。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
PHP CI 工具知识库:汇总 PHPStan 级别与配置、Psalm 集成、PHP-CS-Fixer 规则、DEPTRAC 分层分析、Rector 自动重构及代码覆盖率工具方面的信息。
介绍来源: third_party · dykyi-roman · 0.0.1 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: ci-tools-knowledge
description: PHP CI tools knowledge base. Provides PHPStan levels and configuration, Psalm integration, PHP-CS-Fixer rules, DEPTRAC layer analysis, Rector automated refactoring, and code coverage tools.PHP CI Tools Knowledge Base
Quick reference for PHP static analysis, code quality, and testing tools.
PHPStan
Levels Overview
| Level | Description | Use Case |
|---|---|---|
| 0 | Basic checks (undefined variables, classes) | Legacy projects, quick start |
| 1 | + Undefined methods, properties | Minimal safety |
| 2 | + Unknown methods on $this |
Medium safety |
| 3 | + Return types | Recommended minimum |
| 4 | + Dead code, unreachable | Recommended for new projects |
| 5 | + Argument types | Standard compliance |
| 6 | + Missing typehints | Strict typing |
| 7 | + Union types strict | High strictness |
| 8 | + No mixed, nullsafe | Production recommended |
| 9 | + Maximum strictness | Clean Architecture |
| max | Bleeding edge | Experimental only |
Configuration Template
# phpstan.neon — targets PHPStan 2.x (level 0-10, 10 = max)
includes:
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- phpstan-baseline.neon
parameters:
level: 8
paths:
- src
- tests
excludePaths:
- src/Infrastructure/Legacy/*
- tests/Fixtures/*
# PHP version
phpVersion: 80400
# Strict rules (iterable/generics checks come from `level` in 2.x, not from parameters)
checkUninitializedProperties: true
treatPhpDocTypesAsCertain: true
reportUnmatchedIgnoredErrors: true
# Custom rules
ignoreErrors:
- '#Call to an undefined method [a-zA-Z0-9\\_]+::getId\(\)#'
# Type aliases
typeAliases:
UserId: 'string'
# Parallel processing
parallel:
maximumNumberOfProcesses: 4
Common Extensions
| Extension | Purpose |
|---|---|
phpstan-strict-rules |
Additional strict checks |
phpstan-deprecation-rules |
Deprecated usage detection |
phpstan-phpunit |
PHPUnit support |
phpstan-doctrine |
Doctrine ORM support |
phpstan-symfony |
Symfony container support |
Baseline Management
# Generate baseline (for existing projects)
vendor/bin/phpstan analyse --generate-baseline
# Analyze with baseline
vendor/bin/phpstan analyse
# CI command
vendor/bin/phpstan analyse --no-progress --error-format=checkstyle > phpstan-report.xml
Psalm
Error Levels
| Level | Description |
|---|---|
| 1 | Maximum strictness (recommended for new) |
| 2 | Very strict |
| 3 | Strict (recommended for existing) |
| 4 | Relaxed |
| 5-8 | Increasingly permissive |
Configuration Template
<!-- psalm.xml -->
<?xml version="1.0"?>
<psalm
errorLevel="2"
resolveFromConfigFile="true"
findUnusedBaselineEntry="true"
findUnusedCode="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
<directory name="src/Infrastructure/Legacy"/>
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MixedAssignment errorLevel="suppress"/>
<PropertyNotSetInConstructor>
<errorLevel type="suppress">
<directory name="src/Infrastructure/Doctrine"/>
</errorLevel>
</PropertyNotSetInConstructor>
</issueHandlers>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
</plugins>
</psalm>
Useful Commands
# Full analysis
vendor/bin/psalm
# Generate baseline
vendor/bin/psalm --set-baseline=psalm-baseline.xml
# Security analysis
vendor/bin/psalm --taint-analysis
# CI output
vendor/bin/psalm --output-format=checkstyle > psalm-report.xml
PHP-CS-Fixer
Configuration Template
<?php
// .php-cs-fixer.dist.php
declare(strict_types=1);
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$finder = Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->exclude([
'var',
'vendor',
]);
return (new Config())
->setRiskyAllowed(true)
->setRules([
'@PER-CS2.0' => true,
'@PER-CS2.0:risky' => true,
'@PHP84Migration' => true,
'@PHP80Migration:risky' => true,
'@PHPUnit100Migration:risky' => true,
// Strict rules
'declare_strict_types' => true,
'strict_param' => true,
'strict_comparison' => true,
// Modern PHP
'array_syntax' => ['syntax' => 'short'],
'modernize_strpos' => true,
'no_alias_functions' => true,
'void_return' => true,
// Clean code
'no_unused_imports' => true,
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']],
'single_line_throw' => false,
'trailing_comma_in_multiline' => true,
// DocBlocks
'no_superfluous_phpdoc_tags' => true,
'phpdoc_align' => false,
'phpdoc_separation' => true,
])
->setFinder($finder)
->setCacheFile('.php-cs-fixer.cache');
Commands
# Check (dry run)
vendor/bin/php-cs-fixer fix --dry-run --diff
# Fix
vendor/bin/php-cs-fixer fix
# CI check
vendor/bin/php-cs-fixer fix --dry-run --format=checkstyle > cs-report.xml
DEPTRAC
Configuration Template
# deptrac.yaml
deptrac:
paths:
- ./src
layers:
- name: Domain
collectors:
- type: directory
value: src/Domain/.*
- name: Application
collectors:
- type: directory
value: src/Application/.*
- name: Infrastructure
collectors:
- type: directory
value: src/Infrastructure/.*
- name: Presentation
collectors:
- type: directory
value: src/(Api|Web|Console)/.*
ruleset:
Domain: [] # Domain depends on nothing
Application:
- Domain
Infrastructure:
- Domain
- Application
Presentation:
- Application
- Domain
skip_violations:
# Temporary violations during migration
App\Infrastructure\Legacy\*:
- App\Domain\*
Commands
# Analyze
vendor/bin/deptrac analyse
# With baseline
vendor/bin/deptrac analyse --baseline=deptrac-baseline.yaml
# CI output
vendor/bin/deptrac analyse --formatter=junit --output=deptrac-report.xml
Rector
Configuration Template
<?php
// rector.php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withSkip([
__DIR__ . '/src/Infrastructure/Legacy',
])
->withPhpSets(php84: true)
->withSets([
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
SetList::TYPE_DECLARATION,
PHPUnitSetList::PHPUNIT_100,
])
->withPreparedSets(
deadCode: true,
codeQuality: true,
typeDeclarations: true,
privatization: true,
earlyReturn: true,
);
Commands
# Preview changes (dry run)
vendor/bin/rector process --dry-run
# Apply changes
vendor/bin/rector process
# Single file
vendor/bin/rector process src/Domain/Order.php
Code Coverage Tools
PHPUnit Coverage
<!-- phpunit.xml -->
<phpunit>
<coverage>
<report>
<clover outputFile="coverage.xml"/>
<html outputDirectory="coverage-html"/>
<text outputFile="coverage.txt"/>
</report>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<directory>src/Infrastructure/Legacy</directory>
</exclude>
</coverage>
</phpunit>
Coverage Drivers
| Driver | Speed | Accuracy | Use Case |
|---|---|---|---|
| Xdebug | Slow | High | Local dev, accurate metrics |
| PCOV | Fast | High | CI, fast feedback |
| PHPDBG | Medium | Medium | Alternative |
CI Integration
# GitHub Actions with PCOV
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: pcov
- run: vendor/bin/phpunit --coverage-clover coverage.xml
- uses: codecov/codecov-action@v4
with:
files: coverage.xml
Infection (Mutation Testing)
Configuration
{
"$schema": "vendor/infection/infection/resources/schema.json",
"source": {
"directories": ["src"]
},
"logs": {
"text": "infection.log",
"html": "infection.html"
},
"mutators": {
"@default": true
},
"minMsi": 80,
"minCoveredMsi": 90
}
Commands
# Run with coverage
vendor/bin/infection --threads=4
# CI mode
vendor/bin/infection --min-msi=80 --min-covered-msi=90 --threads=max
Tool Comparison Matrix
| Aspect | PHPStan | Psalm | DEPTRAC | Rector |
|---|---|---|---|---|
| Type analysis | ✅ Deep | ✅ Deep | ❌ | ⚠️ Basic |
| Architecture | ❌ | ❌ | ✅ | ❌ |
| Security | ⚠️ | ✅ Taint | ❌ | ❌ |
| Auto-fix | ❌ | ❌ | ❌ | ✅ |
| Speed | Fast | Medium | Fast | Slow |
| Config | NEON | XML | YAML | PHP |
Recommended CI Setup
lint:
parallel:
matrix:
- TOOL: [phpstan, psalm, cs-fixer, deptrac]
script:
- case $TOOL in
phpstan) vendor/bin/phpstan analyse ;;
psalm) vendor/bin/psalm ;;
cs-fixer) vendor/bin/php-cs-fixer fix --dry-run ;;
deptrac) vendor/bin/deptrac analyse ;;
esac
References
For detailed information, load these reference files:
references/phpstan-rules.md— Custom PHPStan rulesreferences/psalm-plugins.md— Psalm plugins and annotationsreferences/rector-rules.md— Rector upgrade sets
当前收录版本
0.0.1
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供PHP主流CI工具(PHPStan、Psalm、PHP-CS-Fixer、DEPTRAC、Rector、代码覆盖率、Infection)的完整知识库
- 涵盖配置模板、命令、最佳实践、CI集成,显著提升PHP项目代码质量和开发效率
- 结构清晰,实用性强,受众广泛,属于高频刚需工具参考
亮点
- 触发词精准完整,明确涵盖PHP CI工具、PHPStan、Psalm、PHP-CS-Fixer、DEPTRAC、Rector、代码覆盖率等核心关键词
- 边界清晰,覆盖多种变体,用户可通过多种相关术语准确触发
亮点
- 结构清晰,分工具模块组织,每部分含概述、配置模板、命令、最佳实践
- 提供完整示例和CI集成建议,frontmatter完整,文档长度适中
亮点
- 工具来源明确,参数正确,覆盖主要异常处理如baseline生成、CI输出格式
- 不可逆操作如Rector有dry-run预览机制,整体执行可靠性高
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- getpsalm.org
- www.w3.org
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。