Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to PHPStan 2 #57

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/.gitignore export-ignore
/.php-cs-fixer.php export-ignore
/Makefile export-ignore
/Dockerfile export-ignore
/docker-compose.yml export-ignore
/composer-require-checker.json export-ignore
/phpstan-baseline.neon export-ignore
/phpstan.neon export-ignore
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/.phpunit.cache/
/vendor/
/coverage/
/.env
/.php-cs-fixer.cache
/.phpunit.result.cache
/composer.lock
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM php:8.3

ADD --chmod=0755 https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN install-php-extensions @composer pcov

ARG USER_ID
ARG GROUP_ID

RUN groupadd --gid ${GROUP_ID} code \
&& useradd --create-home --shell /bin/bash --uid ${USER_ID} --gid code code

USER code
26 changes: 16 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
CSFIX_PHP_BIN=PHP_CS_FIXER_IGNORE_ENV=1 php8.2
PHP_BIN=php8.2 -d zend.assertions=1 -d error_reporting=-1
COMPOSER_BIN=$(shell command -v composer)
ifdef CI
DOCKER_PHP_EXEC :=
else
DOCKER_PHP_EXEC := docker compose run --rm php
endif

all: csfix static-analysis test
@echo "Done."

vendor: composer.json
$(PHP_BIN) $(COMPOSER_BIN) update
$(PHP_BIN) $(COMPOSER_BIN) bump
touch vendor
.env: /etc/passwd /etc/group Makefile
printf "USER_ID=%s\nGROUP_ID=%s\n" `id --user "${USER}"` `id --group "${USER}"` > .env

vendor: .env docker-compose.yml Dockerfile composer.json
docker compose build --pull
$(DOCKER_PHP_EXEC) composer update
$(DOCKER_PHP_EXEC) composer bump
touch --no-create $@

.PHONY: csfix
csfix: vendor
$(CSFIX_PHP_BIN) vendor/bin/php-cs-fixer fix -v
$(DOCKER_PHP_EXEC) vendor/bin/php-cs-fixer fix -v $(arg)

.PHONY: static-analysis
static-analysis: vendor
$(PHP_BIN) vendor/bin/phpstan analyse $(PHPSTAN_ARGS)
$(DOCKER_PHP_EXEC) php -d zend.assertions=1 vendor/bin/phpstan analyse $(PHPSTAN_ARGS)

.PHONY: test
test: vendor
$(PHP_BIN) vendor/bin/phpunit $(PHPUNIT_ARGS)
$(DOCKER_PHP_EXEC) php -d zend.assertions=1 vendor/bin/phpunit $(PHPUNIT_ARGS)
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"ext-libxml": "*"
},
"require-dev": {
"phpstan/phpstan": "^1.12.9",
"phpstan/phpstan-phpunit": "^1.4.0",
"phpstan/phpstan-strict-rules": "^1.6.1",
"phpstan/phpstan": "^2",
"phpstan/phpstan-phpunit": "^2",
"phpstan/phpstan-strict-rules": "^2",
"phpunit/phpunit": "^11.4.3",
"slam/php-cs-fixer-extensions": "^3.12.0"
},
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
php:
build:
context: .
args:
USER_ID: ${USER_ID}
GROUP_ID: ${GROUP_ID}
volumes:
- .:${PWD}
working_dir: ${PWD}