1+ PHPCS_PHAR = https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
2+ COMPOSER_PHAR = https://getcomposer.org/composer.phar
3+ PHPDOCUMENTOR_PHAR_URL = https://github.com/phpDocumentor/phpDocumentor2/releases/download/v2.9.0/phpDocumentor.phar
4+ CLEAN_FILES = composer.phar composer.lock phpDocumentor.phar phpcs.phar phpcbf.phar
5+ CLEAN_FOLDERS = bin build cover vendor docs/api
6+ CLEAN_PATHS = $(CLEAN_FILES ) $(CLEAN_FOLDERS )
7+ SOURCE_CODE_PATHS = src test examples
8+ API_DOCS_PATH = ./docs/api
9+ COVERAGE_PATH = ./cover
10+
11+ define require_phar
12+ @[ -f ./$(1 ) ] || wget -q $(2 ) -O ./$(1 ) && chmod +x $(1 ) ;
13+ endef
14+
115lint : lint-php lint-psr2 lint-squiz
216
317.PHONY : lint-php
418lint-php :
5- find src -name * .php -exec php -l {} \;
6- find test -name * .php -exec php -l {} \;
7- find spec -name * .php -exec php -l {} \;
8- find examples -name * .php -exec php -l {} \;
19+ find $(SOURCE_CODE_PATHS ) spec -name * .php -exec php -l {} \;
920
1021.PHONY : lint-psr2
1122lint-psr2 :
12- # ./vendor/bin/phpcbf --standard=PSR2 src test examples
13- ./vendor/bin/ phpcs --standard=PSR2 --colors -w -s --warning-severity=0 src test examples
23+ $( call require_phar,phpcs.phar, $( PHPCS_PHAR ) )
24+ ./phpcs.phar --standard=PSR2 --colors -w -s --warning-severity=0 $( SOURCE_CODE_PATHS )
1425
1526.PHONY : lint-squiz
1627lint-squiz :
17- # ./vendor/bin/phpcbf --standard=Squiz,./ruleset.xml src test examples
18- ./vendor/bin/ phpcs --standard=Squiz,./ruleset.xml --colors -w -s --warning-severity=0 src test examples
28+ $( call require_phar,phpcs.phar, $( PHPCS_PHAR ) )
29+ ./phpcs.phar --standard=Squiz,./ruleset.xml --colors -w -s --warning-severity=0 $( SOURCE_CODE_PATHS )
1930
2031
2132test : test-tdd test-bdd
@@ -29,28 +40,25 @@ test-bdd:
2940 ./vendor/bin/phpspec run --format=pretty -v
3041
3142cover :
32- ./vendor/bin/phpunit --coverage-html ./cover test
43+ ./vendor/bin/phpunit --coverage-html $( COVERAGE_PATH ) test
3344
3445deps :
35- wget -q https://getcomposer.org/composer.phar -O ./composer.phar
36- chmod +x composer.phar
37- php composer.phar install
46+ $(call require_phar,composer.phar,$(COMPOSER_PHAR ) )
47+ ./composer.phar install --no-dev
48+
49+ dev-deps :
50+ $(call require_phar,composer.phar,$(COMPOSER_PHAR ) )
51+ ./composer.phar install
3852
3953dist-clean :
40- rm -rf bin
41- rm -rf vendor
42- rm -f composer.phar
43- rm -f composer.lock
44- rm -f phpDocumentor.phar
45- rm -rf docs/api
54+ rm -rf $(CLEAN_PATHS )
4655
4756docker-nats :
4857 docker run --rm -p 8222:8222 -p 4222:4222 -d --name nats-main nats
4958
5059phpdoc :
51- wget -q https://github.com/phpDocumentor/phpDocumentor2/releases/download/v2.9.0/phpDocumentor.phar -O ./phpDocumentor.phar
52- chmod +x phpDocumentor.phar
53- ./phpDocumentor.phar -d ./src/ -t ./docs/api --template=checkstyle --template=responsive-twig
60+ $(call require_phar,phpdoc.phar,$(PHPDOCUMENTOR_PHAR_URL ) )
61+ ./phpdoc.phar -d ./src/ -t $(API_DOCS_PATH ) --template=checkstyle --template=responsive-twig
5462
5563serve-phpdoc :
56- cd docs/api && php -S localhost:8000 && cd ../..
64+ cd $( API_DOCS_PATH ) && php -S localhost:8000 && cd ../..
0 commit comments