create-phpstan-config

为 PHP 项目生成 PHPStan 配置文件。创建包含级别设置、扩展、代码路径、基线支持以及面向 DDD 的规则的 phpstan.neon 配置。

仓库最近推送
GitHub Stars
109
Forks
26
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-phpstan-config":https://skillpi.com/zh/skills/deepskill-bc7934899047484829752bb1e3a6dd0b5175bdb0f60b952e274f608814359cd2。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

为 PHP 项目生成 PHPStan 配置文件。创建包含级别设置、扩展、代码路径、基线支持以及面向 DDD 的规则的 phpstan.neon 配置。

0 下载

介绍来源: third_party · dykyi-roman · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: create-phpstan-config
description: Generates PHPStan configurations for PHP projects. Creates phpstan.neon with appropriate level, extensions, paths, baseline support, and DDD-specific rules.

PHPStan Configuration Generator

Generates optimized PHPStan configurations for PHP 8.4+ projects.

All examples target PHPStan 2.x: level accepts 0-10 (10 = max), and parameters removed in 2.0 (checkMissingIterableValueType, checkGenericClassInNonGenericObjectType, checkExplicitMixed, checkImplicitMixed) must never be generated — they abort the run.

Generated Files

phpstan.neon              # Main configuration
phpstan-baseline.neon     # Error baseline (if needed)

Configuration by Project Type

New Project (Level 8-9)

# phpstan.neon
includes:
    - vendor/phpstan/phpstan-strict-rules/rules.neon
    - vendor/phpstan/phpstan-deprecation-rules/rules.neon
    - vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
    level: 8
    phpVersion: 80400

    paths:
        - src
        - tests

    excludePaths:
        - tests/Fixtures/*
        - src/Infrastructure/Legacy/*

    # Strict type checking (raise `level` for stricter checks: 9 = explicit mixed, 10 = implicit mixed)
    checkUninitializedProperties: true
    treatPhpDocTypesAsCertain: true
    reportUnmatchedIgnoredErrors: true

    # Parallel processing
    parallel:
        maximumNumberOfProcesses: 4

Existing Project with Baseline

# phpstan.neon
includes:
    - phpstan-baseline.neon
    - vendor/phpstan/phpstan-strict-rules/rules.neon
    - vendor/phpstan/phpstan-deprecation-rules/rules.neon

parameters:
    level: 6

    paths:
        - src
        - tests

    excludePaths:
        - src/Legacy/*
        - tests/Fixtures/*

    # Gradually increase strictness: bump `level` one step at a time (0-10)
    treatPhpDocTypesAsCertain: false
    reportUnmatchedIgnoredErrors: false

    # Type aliases for legacy code
    typeAliases:
        UserId: 'int|string'
        Timestamp: 'int|DateTimeInterface'

DDD Project Configuration

# phpstan.neon
includes:
    - vendor/phpstan/phpstan-strict-rules/rules.neon
    - vendor/phpstan/phpstan-deprecation-rules/rules.neon
    - vendor/phpstan/phpstan-phpunit/extension.neon
    - vendor/phpstan/phpstan-doctrine/extension.neon

parameters:
    level: 9
    phpVersion: 80400

    paths:
        - src

    excludePaths:
        - src/Infrastructure/Migrations/*

    # Strict for Domain layer (level 9 already forbids explicit mixed; use level 10 for implicit mixed)
    checkUninitializedProperties: true
    treatPhpDocTypesAsCertain: true

    # Report all issues
    reportUnmatchedIgnoredErrors: true
    reportStaticMethodSignatures: true

    # Parallel for speed
    parallel:
        maximumNumberOfProcesses: 8
        processTimeout: 300.0

    # Custom parameters
    doctrine:
        repositoryClass: App\Infrastructure\Persistence\DoctrineRepository
        objectManagerLoader: tests/object-manager.php

    # Ignore patterns (entry is either a delimited regex string, or a map with `message`/`identifier`)
    ignoreErrors:
        # Doctrine entities
        -
            message: '#Property .+ has no type specified#'
            path: src/Infrastructure/Doctrine/Entity/*

        # Value Objects immutability
        -
            message: '#Readonly property .+ is assigned outside of its declaring class#'
            path: src/Domain/*/ValueObject/*

    # Custom rules
    rules:
        - App\PHPStan\DomainLayerRule
        - App\PHPStan\ValueObjectImmutabilityRule

Extension Configuration

PHPUnit Extension

includes:
    - vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
    # PHPUnit-specific settings
    phpunit:
        configPath: phpunit.xml

Doctrine Extension

includes:
    - vendor/phpstan/phpstan-doctrine/extension.neon

parameters:
    doctrine:
        repositoryClass: Doctrine\ORM\EntityRepository
        objectManagerLoader: tests/object-manager.php

Symfony Extension

includes:
    - vendor/phpstan/phpstan-symfony/extension.neon
    - vendor/phpstan/phpstan-symfony/rules.neon

parameters:
    symfony:
        containerXmlPath: var/cache/dev/App_KernelDevDebugContainer.xml
        consoleApplicationLoader: tests/console-application.php

Custom Error Patterns

Common Ignore Patterns

parameters:
    ignoreErrors:
        # Constructor property promotion
        - '#Constructor of class .+ has an unused parameter#'

        # Doctrine entities
        -
            message: '#Property .+ does not accept null#'
            path: src/Infrastructure/Doctrine/Entity/*

        # Test doubles
        -
            message: '#Call to an undefined method .+Mock::#'
            path: tests/*

        # Dynamic properties in tests
        -
            message: '#Access to an undefined property .+Test::\$#'
            path: tests/*

        # Factory methods
        - '#Method .+Factory::create\(\) should return .+ but returns#'

        # Event handlers
        - '#Parameter .+ of method .+Handler::__invoke\(\) has no type specified#'

Error Baseline Generation

# Generate baseline for existing errors
vendor/bin/phpstan analyse --generate-baseline

# Generate baseline with specific name
vendor/bin/phpstan analyse --generate-baseline=phpstan-baseline.neon

# Analyze and exclude baseline errors
vendor/bin/phpstan analyse

Level Migration Guide

From Level 0 to Level 8

# Step 1: Start with baseline at current level
parameters:
    level: 0

# Step 2: Generate baseline
# vendor/bin/phpstan analyse --generate-baseline

# Step 3: Increase level
parameters:
    level: 1

# Step 4: Fix new errors or add to baseline
# Repeat until level 8

Recommended Progression

Level Focus Timeline
0-2 Basic errors, undefined variables Week 1
3-4 Return types, dead code Week 2-3
5-6 Argument types, type hints Week 4-6
7-8 Union types, no mixed Week 7-10
9-10 Maximum strictness (10 is the highest level in PHPStan 2.x) Ongoing

CI Configuration

GitHub Actions

phpstan:
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v4
    - uses: shivammathur/setup-php@v2
      with:
        php-version: '8.4'
    - run: composer install
    - run: vendor/bin/phpstan analyse --memory-limit=1G --error-format=github

GitLab CI

phpstan:
  script:
    - vendor/bin/phpstan analyse --memory-limit=1G --error-format=gitlab > phpstan.json
  artifacts:
    reports:
      codequality: phpstan.json

Performance Optimization

parameters:
    # Parallel processing
    parallel:
        maximumNumberOfProcesses: 8
        processTimeout: 300.0

    # Cache results
    tmpDir: var/cache/phpstan

    # Memory limit
    memoryLimitFile: 1G

Generation Instructions

  1. Analyze project:

    • Check composer.json for PHPStan version
    • Check existing phpstan.neon
    • Identify framework (Symfony, Laravel, etc.)
    • Count existing errors
  2. Determine level:

    • New project: Level 8-9
    • Existing with few errors: Current + 1
    • Legacy: Level 0 + baseline
  3. Add extensions:

    • PHPUnit if tests exist
    • Doctrine if ORM used
    • Symfony/Laravel if framework
  4. Generate baseline if needed:

    • For existing projects with errors
    • Include command to regenerate

Usage

Provide:

  • Project type (new/existing/legacy)
  • Framework (Symfony, Laravel, none)
  • Current error count (if existing)
  • Target level (optional)

The generator will:

  1. Create appropriate configuration
  2. Add relevant extensions
  3. Include ignore patterns
  4. Generate baseline commands if needed

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值92/100

亮点

  • 为PHP项目生成PHPStan配置是开发者日常开发中的高频需求
  • 提供了详细的配置模板和最佳实践指导
  • 支持多种项目类型和框架配置
触发精准88/100

亮点

  • 触发词精准完整,覆盖多种变体
  • description明确描述了生成PHPStan配置的功能
  • 边界清晰,不会与其他Skill混淆
结构规范95/100

待提升项

  • 缺少When to Use章节 原报告严重程度:轻微

    文档结构完整但缺少明确的When to Use使用场景说明章节

    改进建议:建议添加When to Use章节,明确说明何时使用此Skill

亮点

  • Phase/步骤清晰,有出口条件
  • 包含端到端示例,frontmatter完整
  • 文档结构良好,易于理解执行流程
执行可靠90/100

亮点

  • 工具来源明确,参数正确
  • 覆盖主要异常情况,提供了详细的配置选项
  • 提供了CI/CD集成方案和性能优化建议
证据可验 (前四项均值)91/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。