定制 webprofil/coding-standards 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

webprofil/coding-standards

Composer 安装命令:

composer require webprofil/coding-standards

包简介

Zero-configuration QA toolchain for WEBprofil TYPO3 projects – scaffolds Rector, Fractor, PHP-CS-Fixer, PHPStan configs with dynamic version detection and CLI-driven execution.

README 文档

README

Zero-configuration QA toolchain for WEBprofil TYPO3 projects. Provides a unified CLI (webprofil-qa) and Composer plugin that scaffolds Rector, Fractor, PHP-CS-Fixer, and PHPStan configurations under build/qa/, with dynamic PHP and TYPO3 version detection.

Features

  • CLI-driven QA – run all checks and fixers via a single webprofil-qa command with subcommands for each tool
  • Composer plugin – auto-scaffolds config files on install/update (no script injection)
  • Configuration factories – centralized, dynamic configs for Rector, Fractor, PHP-CS-Fixer, and PHPStan
  • Dynamic version detection – reads composer.json (platform PHP) and composer.lock (TYPO3 core major) to apply the correct level sets
  • Cache isolation – all tool caches are stored in build/qa/.cache/ and ignored via .gitignore
  • Graceful cleanup – uninstalling the package removes only scripts/descriptions that still match the injected values
  • Non-destructive scaffolding – existing config files in build/qa/ are never overwritten

Installation

composer require --dev webprofil/coding-standards

Before installing, the host project must allow the Composer plugin either by accepting Composer's interactive prompt or by pre-configuring:

"config": {
    "allow-plugins": {
        "webprofil/coding-standards": true
    }
}

After installation, the plugin will automatically:

  1. Create build/qa/ with configuration files for all four tools (if they don't already exist)
  2. Create the vendor/bin/webprofil-qa binary for CLI usage

Usage

Run the full QA pipeline:

vendor/bin/webprofil-qa check

Auto-fix all fixable issues:

vendor/bin/webprofil-qa fix

Scaffold missing configuration files:

vendor/bin/webprofil-qa install

Verify that all required files and binaries are present:

vendor/bin/webprofil-qa doctor

Show help and command-specific examples:

vendor/bin/webprofil-qa list
vendor/bin/webprofil-qa --help
vendor/bin/webprofil-qa help cs

Command reference

CommandDescription
webprofil-qa / list / --helpShow help and available commands
webprofil-qa checkRun all checks (cs, stan, rector, fractor)
webprofil-qa fixRun all fixers (cs, rector, fractor)
webprofil-qa cs checkCheck PHP coding style (dry-run)
webprofil-qa cs fixFix PHP coding style
webprofil-qa stan checkRun PHPStan static analysis
webprofil-qa rector checkDry run Rector upgrades
webprofil-qa rector fixApply Rector upgrades
webprofil-qa fractor checkDry run Fractor upgrades
webprofil-qa fractor fixApply Fractor upgrades
webprofil-qa installScaffold missing build/qa/ config files
webprofil-qa doctorCheck required files and binaries

Legacy Composer scripts (removed)

Previous versions of this package injected Composer scripts (composer qa, composer cs:check, etc.). As of v2, the package no longer injects Composer scripts. Use the webprofil-qa CLI instead. If old scripts are still present in your composer.json, the plugin removes them on uninstall.

Configuration

Dynamic version detection

The plugin automatically detects:

  • PHP version – from config.platform.php (first), then require.php, then require-dev.php in composer.json
  • TYPO3 major version – from typo3/cms-core version in composer.lock (packages then packages-dev), falling back to the constraint in composer.json

Rector and Fractor use the detected versions to apply the appropriate LevelSetList (e.g. UP_TO_PHP_84, UP_TO_TYPO3_14).

Customizing configs

All scaffolded files include centralized config files from vendor/webprofil/coding-standards/ and contain commented-out customization examples. Since the plugin never overwrites existing files, your changes persist across package updates.

Rector – edit build/qa/rector.php:

$config = RectorConfigFactory::create(__DIR__ . '/../..');
$config->withSkip([
    __DIR__ . '/../../extensions/legacy/Classes',
]);

PHP-CS-Fixer – edit build/qa/.php-cs-fixer.php:

$config = ConfigFactory::create(__DIR__ . '/../..');
$config->addRules([
    'no_unused_imports' => false,
]);

PHPStan – edit build/qa/phpstan.neon:

The scaffolded PHPStan config includes the centralized package config from webprofil/coding-standards and only keeps project-specific paths locally. The package default level is 5.

parameters:
    level: 8
    excludePaths:
        - ../../extensions/legacy/*

Path detection

The PathDetector service scans for existing directories in this order:

  1. extensions/<name>/{Classes,Configuration,Tests,Resources} – for each extension directory
  2. packages/<name>/{Classes,Configuration,Tests,Resources} – for each package directory
  3. Project root directories: src/, tests/, Classes/, Configuration/

Different tools get different path sets:

  • Rector: Classes, Configuration, Tests, and entry point files
  • Fractor: Configuration, Resources (TypoScript/XML focus)
  • PHPStan: Classes, Tests
  • PHP-CS-Fixer: Full extension directories + src, tests

Uninstall

composer remove webprofil/coding-standards

Upon uninstallation, the plugin removes only the Composer scripts and descriptions it originally injected, provided they still match the original values. If you customized a script, it is left in place to avoid breaking your project.

Scaffolded files under build/qa/ are not removed — they remain available for manual use.

Requirements

  • PHP >= 8.2
  • Composer 2.x
  • TYPO3 v12+ (v13 default fallback, v12 when detected from lock/constraint)

License

GPL-2.0-or-later

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-06-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固