Skip to content

Commit

Permalink
Maintenance: phpstan, codesniffer, makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Feb 4, 2024
1 parent 2f3cf33 commit d191e88
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
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
@@ -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
8 changes: 6 additions & 2 deletions .gitignore
Expand Up @@ -6,5 +6,9 @@
/composer.lock

# Tests
/temp
/coverage.xml
/tests/tmp
/coverage.*
/tests/**/*.log
/tests/**/*.html
/tests/**/*.expected
/tests/**/*.actual
15 changes: 10 additions & 5 deletions Makefile
@@ -1,26 +1,31 @@
.PHONY: install qa cs csf phpstan tests coverage

.PHONY: install
install:
composer update

.PHONY: qa
qa: phpstan cs

.PHONY: cs
cs:
ifdef GITHUB_ACTION
vendor/bin/codesniffer -q --report=checkstyle src tests | cs2pr
vendor/bin/phpcs --standard=ruleset.xml --encoding=utf-8 --extensions="php,phpt" --colors -nsp -q --report=checkstyle src tests | cs2pr
else
vendor/bin/codesniffer src tests
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 -c phpstan.neon

.PHONY: tests
tests:
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
Expand Down
31 changes: 9 additions & 22 deletions phpstan.neon
@@ -1,31 +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: 70200
phpVersion: 80100

paths:
scanDirectories:
- src

ignoreErrors:
# phpstan don't like array callbacks
- '#^Parameter \#1 \$function of function call_user_func expects callable\(\)\: mixed, array\{.+\} given\.$#'

-
message: "#^Method Contributte\\\\EventDispatcher\\\\LazyEventDispatcher\\:\\:getListeners\\(\\) should return array\\<Symfony\\\\Component\\\\EventDispatcher\\\\EventSubscriberInterface\\> but returns array\\<array\\<callable\\>\\|\\(callable\\)\\>\\.$#"
count: 1
path: src/LazyEventDispatcher.php
fileExtensions:
- php

-
message: "#^Return type \\(array\\<Symfony\\\\Component\\\\EventDispatcher\\\\EventSubscriberInterface\\>\\) of method Contributte\\\\EventDispatcher\\\\LazyEventDispatcher\\:\\:getListeners\\(\\) should be covariant with return type \\(array\\<array\\<callable\\(\\)\\: mixed\\>\\|\\(callable\\(\\)\\: mixed\\)\\>\\) of method Symfony\\\\Component\\\\EventDispatcher\\\\EventDispatcher\\:\\:getListeners\\(\\)$#"
count: 1
path: src/LazyEventDispatcher.php
paths:
- src
- .docs

-
message: "#^Return type \\(array\\<Symfony\\\\Component\\\\EventDispatcher\\\\EventSubscriberInterface\\>\\) of method Contributte\\\\EventDispatcher\\\\LazyEventDispatcher\\:\\:getListeners\\(\\) should be covariant with return type \\(array\\<array\\<callable\\(\\)\\: mixed\\>\\|\\(callable\\(\\)\\: mixed\\)\\>\\) of method Symfony\\\\Component\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:getListeners\\(\\)$#"
count: 1
path: src/LazyEventDispatcher.php
ignoreErrors:
16 changes: 10 additions & 6 deletions ruleset.xml
@@ -1,18 +1,22 @@
<?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\EventDispatcher"/>
<element key="tests" value="Tests"/>
</property>
<property name="extensions" type="array">
<element key="php" value="php"/>
<element key="phpt" value="phpt"/>
</property>
</properties>
</rule>

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

0 comments on commit d191e88

Please sign in to comment.