svenpetersen / typo3-coding-standards
A set of coding guidelines for TYPO3 projects and extensions
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:coding-standards
Requires
- php: ^7.4 || ^8.0
- friendsoftypo3/phpstan-typo3: 0.9.0
- helmich/typo3-typoscript-lint: ^2.5
- phpmd/phpmd: ^2.11
- phpmetrics/phpmetrics: ^2.7
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.4
- phpstan/phpstan-deprecation-rules: 1.0
- saschaegerer/phpstan-typo3: ^1.1
- slam/phpstan-extensions: ^v6.0.0
- squizlabs/php_codesniffer: ^3.5
- symplify/easy-coding-standard: ^10.1.0
- thecodingmachine/phpstan-strict-rules: v1.0.0
- typo3/coding-standards: ^0.5.0
README
Installation
As this is a composer package, execute composer req --dev svenpetersen/typo3-coding-standards
in your composer project.
Setting up the TYPO3 rulesets as boilerplate
Our coding standards files can set this up for you. Run
composer exec svenpet-typo3-coding-standards project
or
composer exec svenpet-typo3-coding-standards extension
or if you want to update the rules, add force
option to the end.
Have a look at the newly created files in your root folder:
- .editorconfig
- .php-cs-fixer.php
- phpcpd.phar
- phpstan.neon
- typoscript-lint.yml
- debutoutputCheck.sh
- .gitlab-ci.yml
composer.scripts
Kopiere diesen Code in die scripts Sektion der composer.json.
Danach kannst du alle codechecks ganz einfach mit composer ci:test
ausführen.
PROJECT
"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" ]
EXTENSION
"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 rules
Making sure your PHP files apply to the same rules.
.editorconfig
The offical .editorconfig of the typo3/coding-standards package. Used by the TYPO3 core.
phpstan config
Config for the PHP Static Analyser "PHPStan"
php copy-paste-detector
The executable PHAR file of the Copy & Paste Detector
typoscript-lint config
Config file for the TypoScipt linter "typoscript-lint" by Martin Helmich.
debugoutputCheck.sh
Checks the source code for usages of debugging output like die(), var_dump(), DebuggerUtility::var_dump(), console.log() etc. Calls to debugging functions should not be commited or deployed.