svenpetersen/typo3-coding-standards

TYPO3项目和扩展的编码规范集合

安装: 1

依赖: 0

建议者: 0

安全: 0

星标: 1

关注者: 1

分支: 0

开放问题: 0

类型:编码规范

1.0.0 2022-03-22 22:33 UTC

This package is auto-updated.

Last update: 2024-09-29 05:57:11 UTC


README

安装

由于这是一个composer包,请在您的composer项目中执行composer req --dev svenpetersen/typo3-coding-standards

设置TYPO3规则集作为样板

我们的编码规范文件可以为您设置这些。运行

composer exec svenpet-typo3-coding-standards project

composer exec svenpet-typo3-coding-standards extension

如果您想更新规则,请在末尾添加force选项。

查看您根目录中新创建的文件

  • .editorconfig
  • .php-cs-fixer.php
  • phpcpd.phar
  • phpstan.neon
  • typoscript-lint.yml
  • debutoutputCheck.sh
  • .gitlab-ci.yml

composer.scripts

将此代码复制到composer.json的scripts部分。然后,您可以通过composer ci:test轻松执行所有代码检查。

项目

"ci:test": [
    "@ci:test:php",
    "@ci:lint:typoscript",
    "@ci:test:debugoutput",
    "@ci:test:phpunit"
],
"ci:test:php": [
    "@ci:php:cs-fixer",
    "@ci:php:stan",
    "@ci:php:phpmd",
    "@ci:php:copypastedetector"
],
"ci:test:phpunit": [
    "@ci:test:functional",
    "@ci:test:unit"
],
"ci:php:cs-fixer": [
    "php-cs-fixer fix packages -v --dry-run --using-cache no --diff",
],
"ci:php:stan": [
    "phpstan analyse --no-progress"
],
"ci:php:phpmd": [
    "phpmd ./packages html codesize --ignore-violations-on-exit --reportfile ./phpmd-codesize.html",
    "phpmd ./packages html cleancode --ignore-violations-on-exit --reportfile ./phpmd-codesize.html",
    "phpmd ./packages html naming --ignore-violations-on-exit --reportfile ./phpmd-naming.html",
    "phpmd ./packages html design --ignore-violations-on-exit --reportfile ./phpmd-design.html",
    "phpmd ./packages html unusedcode --ignore-violations-on-exit --reportfile ./phpmd-unusedcode.html",
    "phpmd ./packages html controversial --ignore-violations-on-exit --reportfile ./phpmd-controversial.html"
],
"ci:php:copypastedetector": [
    "php phpcpd.phar --fuzzy ./packages/*"
],
"ci:test:debugoutput": [
    "chmod +x ./debugoutputCheck.sh && sh ./debugoutputCheck.sh"
],
"ci:test:functional": [
    "phpunit -c Tests/Functional/phpunit.xml"
],
"ci:test:unit": [
    "phpunit -c Tests/Unit/phpunit.xml"
],
"ci:lint:typoscript": [
    "typoscript-lint --ansi -n --fail-on-warnings -vvv"
],
"fix:php:cs-fixer": [
    "php-cs-fixer fix -v --using-cache no"
]

扩展

"ci:test": [
    "@ci:test:php",
    "@ci:lint:typoscript",
    "@ci:test:debugoutput",
    "@ci:test:phpunit"
],
"ci:test:php": [
    "@ci:php:cs-fixer",
    "@ci:php:stan",
    "@ci:php:phpmd",
    "@ci:php:copypastedetector"
],
"ci:test:phpunit": [
    "@ci:test:functional",
    "@ci:test:unit"
],
"ci:php:cs-fixer": [
    "php-cs-fixer fix Classes -v --dry-run --using-cache no --diff",
    "php-cs-fixer fix Tests -v --dry-run --using-cache no --diff"
],
"ci:php:stan": [
    "phpstan analyse --no-progress"
],
"ci:php:phpmd": [
    "phpmd ./Classes html codesize --ignore-violations-on-exit --reportfile ./phpmd-codesize.html",
    "phpmd ./Classes html cleancode --ignore-violations-on-exit --reportfile ./phpmd-codesize.html",
    "phpmd ./Classes html naming --ignore-violations-on-exit --reportfile ./phpmd-naming.html",
    "phpmd ./Classes html design --ignore-violations-on-exit --reportfile ./phpmd-design.html",
    "phpmd ./Classes html unusedcode --ignore-violations-on-exit --reportfile ./phpmd-unusedcode.html",
    "phpmd ./Classes html controversial --ignore-violations-on-exit --reportfile ./phpmd-controversial.html"
],
"ci:php:copypastedetector": [
    "php phpcpd.phar --fuzzy ./Classes/*"
],
"ci:test:debugoutput": [
    "chmod +x ./debugoutputCheck.sh && sh ./debugoutputCheck.sh"
],
"ci:test:functional": [
    "phpunit -c Tests/Functional/phpunit.xml"
],
"ci:test:unit": [
    "phpunit -c Tests/Unit/phpunit.xml"
],
"ci:lint:typoscript": [
    "typoscript-lint --ansi -n --fail-on-warnings -vvv"
],
"fix:php:cs-fixer": [
    "php-cs-fixer fix -v --using-cache no"
]

PHP-CS-Fixer规则

确保您的PHP文件遵循相同的规则。

.editorconfig

typo3/coding-standards包的官方.editorconfig。由TYPO3核心使用。

phpstan配置

"PHPStan"静态分析器的配置

php复制粘贴检测器

复制粘贴检测器的可执行PHAR文件

typoscript-lint配置

Martin Helmich的typoscript-linter "typoscript-lint"的配置文件

debugoutputCheck.sh

检查源代码中调试输出(如die(), var_dump(), DebuggerUtility::var_dump(), console.log()等)的使用情况。调试函数的调用不应提交或部署。