Skip to content

Commit eeb234f

Browse files
committed
Use PHPStan and coding standard
1 parent 8b50674 commit eeb234f

26 files changed

+1387
-550
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Author: Dominik Harmim <harmim6@gmail.com>
2-
31
name: Build
42

53
on: [push, pull_request]

.github/workflows/coding-style.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1-
# Author: Dominik Harmim <harmim6@gmail.com>
2-
31
name: Coding Style
42

53
on: [push, pull_request]
64

75
jobs:
8-
nette-cc:
9-
name: Nette Code Checker
6+
code-checker:
7+
name: Code Checker
108
runs-on: ubuntu-latest
119
steps:
1210
- uses: actions/checkout@v3
1311
- run: make code-checker CI=1
12+
13+
coding-standard:
14+
name: Coding Standard
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- run: make coding-standard CI=1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: Static Analysis
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
phpstan:
7+
name: PHPStan
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
- run: make phpstan CI=1

.github/workflows/tests.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Author: Dominik Harmim <harmim6@gmail.com>
2-
31
name: Tests
42

53
on: [push, pull_request]
@@ -23,5 +21,6 @@ jobs:
2321
steps:
2422
- uses: actions/checkout@v3
2523
- run: |
26-
echo "repo_token: ${{ secrets.GITHUB_TOKEN }}" >> tests/.coveralls.github-actions.yml
24+
echo "repo_token: ${{ secrets.GITHUB_TOKEN }}" >> \
25+
tests/.coveralls.github-actions.yml
2726
make tests-coverage CI=1

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Author: Dominik Harmim <harmim6@gmail.com>
2-
31
/.idea
42
/temp/*
53
/vendor/*

Makefile

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# Author: Dominik Harmim <harmim6@gmail.com>
2-
31
FIX := 0
42
CI := 0
53

@@ -14,6 +12,10 @@ CODE_CHECKER := nette/code-checker
1412
CODE_CHECKER_VERSION := ~3.3.0
1513
CODE_CHECKER_DIR := $(TEMP_DIR)/code-checker
1614

15+
CODING_STANDARD := nette/coding-standard
16+
CODING_STANDARD_VERSION := ~3.3.2
17+
CODING_STANDARD_DIR := $(TEMP_DIR)/coding-standard
18+
1719
COVERALLS := php-coveralls/php-coveralls
1820
COVERALLS_VERSION := ^2.5
1921
COVERALLS_DIR := $(TEMP_DIR)/coveralls
@@ -33,55 +35,78 @@ composer: docker-compose-php
3335
$(DOCKER_PHP) composer install --no-interaction --no-progress
3436

3537

36-
.PHONY: code-checker
37-
code-checker: code-checker-install code-checker-run
38-
3938
.PHONY: code-checker-install
4039
code-checker-install: docker-compose-php
4140
ifeq ($(wildcard $(CODE_CHECKER_DIR)/.), )
42-
$(DOCKER_PHP) composer create-project $(CODE_CHECKER) $(CODE_CHECKER_DIR) $(CODE_CHECKER_VERSION) --no-interaction \
41+
$(DOCKER_PHP) composer create-project $(CODE_CHECKER) $(CODE_CHECKER_DIR) \
42+
$(CODE_CHECKER_VERSION) --no-interaction --no-progress --no-dev
43+
endif
44+
45+
.PHONY: code-checker
46+
code-checker: code-checker-install docker-compose-php
47+
ifeq ($(FIX), 0)
48+
$(DOCKER_PHP) ./$(CODE_CHECKER_DIR)/code-checker --no-progress \
49+
--strict-types --eol
50+
else
51+
$(DOCKER_PHP) ./$(CODE_CHECKER_DIR)/code-checker --no-progress \
52+
--strict-types --eol --fix
53+
endif
54+
55+
56+
.PHONY: coding-standard-install
57+
coding-standard-install: docker-compose-php
58+
ifeq ($(wildcard $(CODING_STANDARD_DIR)/.), )
59+
$(DOCKER_PHP) composer create-project $(CODING_STANDARD) \
60+
$(CODING_STANDARD_DIR) $(CODING_STANDARD_VERSION) --no-interaction \
4361
--no-progress --no-dev
4462
endif
4563

46-
.PHONY: code-checker-run
47-
code-checker-run: docker-compose-php
64+
.PHONY: coding-standard
65+
coding-standard: coding-standard-install docker-compose-php
4866
ifeq ($(FIX), 0)
49-
$(DOCKER_PHP) ./$(CODE_CHECKER_DIR)/code-checker --no-progress --strict-types --eol
67+
$(DOCKER_PHP) ./$(CODING_STANDARD_DIR)/ecs check $(SRC_DIR) $(TESTS_DIR)
5068
else
51-
$(DOCKER_PHP) ./$(CODE_CHECKER_DIR)/code-checker --no-progress --strict-types --eol --fix
69+
$(DOCKER_PHP) ./$(CODING_STANDARD_DIR)/ecs check $(SRC_DIR) $(TESTS_DIR) \
70+
--fix
5271
endif
5372

5473

74+
.PHONY: phpstan
75+
phpstan: install docker-compose-php
76+
$(DOCKER_PHP) ./$(VENDOR_BIN_DIR)/phpstan analyse -c phpstan.neon \
77+
--no-progress
78+
79+
5580
.PHONY: tests
5681
tests: install docker-compose-php
5782
$(DOCKER_PHP) ./$(VENDOR_BIN_DIR)/tester $(TESTS_DIR) -s -C
5883

5984

60-
.PHONY: tests-coverage
61-
tests-coverage: tests-coverage-install tests-coverage-run
62-
6385
.PHONY: tests-coverage-install
6486
tests-coverage-install: docker-compose-php
6587
ifeq ($(wildcard $(COVERALLS_DIR)/.), )
66-
$(DOCKER_PHP) composer create-project $(COVERALLS) $(COVERALLS_DIR) $(COVERALLS_VERSION) --no-interaction \
67-
--no-progress --no-dev
88+
$(DOCKER_PHP) composer create-project $(COVERALLS) $(COVERALLS_DIR) \
89+
$(COVERALLS_VERSION) --no-interaction --no-progress --no-dev
6890
endif
6991

70-
.PHONY: tests-coverage-run
71-
tests-coverage-run: install docker-compose-php
72-
$(DOCKER_PHP) ./$(VENDOR_BIN_DIR)/tester -p phpdbg $(TESTS_DIR) -s -C --coverage coverage.xml \
73-
--coverage-src $(SRC_DIR)
92+
.PHONY: tests-coverage
93+
tests-coverage: install tests-coverage-install docker-compose-php
94+
$(DOCKER_PHP) ./$(VENDOR_BIN_DIR)/tester -p phpdbg $(TESTS_DIR) -s -C \
95+
--coverage coverage.xml --coverage-src $(SRC_DIR)
7496
ifeq ($(CI), 1)
7597
$(DOCKER_PHP) git config --global --add safe.directory /app
76-
$(DOCKER_PHP) ./$(COVERALLS_DIR)/bin/php-coveralls --verbose --config $(TESTS_DIR)/.coveralls.github-actions.yml
98+
$(DOCKER_PHP) ./$(COVERALLS_DIR)/bin/php-coveralls --verbose \
99+
--config $(TESTS_DIR)/.coveralls.github-actions.yml
77100
else
78-
$(DOCKER_PHP) ./$(COVERALLS_DIR)/bin/php-coveralls --verbose --config $(TESTS_DIR)/.coveralls.local.yml
101+
$(DOCKER_PHP) ./$(COVERALLS_DIR)/bin/php-coveralls --verbose \
102+
--config $(TESTS_DIR)/.coveralls.local.yml
79103
endif
80104

81105

82106
.PHONY: clean
83107
clean:
84-
git clean -xdff $(TEMP_DIR) $(TESTS_TEMP_DIR) $(shell find $(TESTS_DIR) -type d -name output) $(VENDOR_DIR) \
108+
git clean -xdff $(TEMP_DIR) $(TESTS_TEMP_DIR) \
109+
$(shell find $(TESTS_DIR) -type d -name output) $(VENDOR_DIR) \
85110
$(shell ls -Ap | grep -v '/\|composer.lock')
86111

87112

0 commit comments

Comments
 (0)