Skip to content

Commit

Permalink
Maintenance: git, editorconfig, phpstan, makefile, codesniffer
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Dec 12, 2023
1 parent a49c560 commit 40f6ad9
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ indent_style = tab
indent_size = tab
tab_width = 4

[{*.json, *.yaml, *.yml, *.md}]
[*.{json,yaml,yml,md}]
indent_style = space
indent_size = 2
7 changes: 3 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Not archived
.docs export-ignore
tests export-ignore
.github export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
Makefile export-ignore
phpstan.neon export-ignore
README.md export-ignore
phpstan.neon export-ignore
ruleset.xml export-ignore
tests export-ignore
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
/composer.lock

# Tests
/coverage.xml
/tests/tmp
/coverage.*
/tests/**/*.log
/tests/**/*.html
/tests/**/*.expected
/tests/**/*.actual
34 changes: 22 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
.PHONY: install qa cs csf phpstan tests coverage-clover coverage-html

.PHONY: install
install:
composer update

.PHONY: qa
qa: phpstan cs

.PHONY: cs
cs:
vendor/bin/codesniffer src tests
ifdef GITHUB_ACTION
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp -q --report=checkstyle src tests | cs2pr
else
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp src tests
endif

.PHONY: csf
csf:
vendor/bin/codefixer src tests
vendor/bin/phpcbf --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp src tests

.PHONY: phpstan
phpstan:
vendor/bin/phpstan analyse -l 8 -c phpstan.neon src
vendor/bin/phpstan analyse -c phpstan.neon

.PHONY: tests
tests:
vendor/bin/tester -s -p php --colors 1 -C tests/cases

coverage-clover:
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage ./coverage.xml --coverage-src ./src tests/cases

coverage-html:
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage ./coverage.html --coverage-src ./src tests/cases
vendor/bin/tester -s -p php --colors 1 -C tests/Cases

.PHONY: coverage
coverage:
ifdef GITHUB_ACTION
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.xml --coverage-src src tests/Cases
else
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage coverage.html --coverage-src src tests/Cases
endif
22 changes: 14 additions & 8 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
includes:
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/phpstan/phpstan-nette/extension.neon
- vendor/phpstan/phpstan-nette/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/contributte/phpstan/phpstan.neon

parameters:
level: 9
phpVersion: 80100

scanDirectories:
- src

fileExtensions:
- php

paths:
- src
- .docs

ignoreErrors:
- path: %currentWorkingDirectory%/src/Filters/EmailFilter.php
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
- path: %currentWorkingDirectory%/src/Filters/EmailFilter.php
message: '#.+int\|false given.+#'
14 changes: 7 additions & 7 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0"?>
<ruleset>
<!-- Contributte Coding Standard -->
<rule ref="./vendor/ninjify/coding-standard/contributte.xml"/>
<?xml version="1.0" encoding="UTF-8"?>
<ruleset name="Contributte" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd">
<!-- Rulesets -->
<rule ref="./vendor/contributte/qa/ruleset-8.0.xml"/>

<!-- Specific rules -->
<!-- Rules -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array">
<element key="src" value="Contributte\Latte"/>
<element key="tests/fixtures" value="Tests\Fixtures"/>
<element key="tests" value="Tests"/>
</property>
</properties>
</rule>

<!-- Exclude folders -->
<!-- Excludes -->
<exclude-pattern>/tests/tmp</exclude-pattern>
</ruleset>

0 comments on commit 40f6ad9

Please sign in to comment.