Skip to content

Commit bfbad39

Browse files
#1 Add Makefile & .docker for local standalone usage. Add rector, phpstan & php-cs-fixer configurations
1 parent 791692c commit bfbad39

File tree

10 files changed

+246
-2
lines changed

10 files changed

+246
-2
lines changed

.docker/compose.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
x-build-args: &build-args
2+
UID: "${UID:-1000}"
3+
GID: "${GID:-1000}"
4+
5+
name: cleverage-rest-process-bundle
6+
7+
services:
8+
php:
9+
build:
10+
context: php
11+
args:
12+
<<: *build-args
13+
volumes:
14+
- ../:/var/www

.docker/php/Dockerfile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM php:8.2-fpm-alpine
2+
3+
ARG UID
4+
ARG GID
5+
6+
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
7+
COPY /conf.d/ "$PHP_INI_DIR/conf.d/"
8+
9+
RUN apk update && apk add \
10+
tzdata \
11+
shadow \
12+
nano \
13+
bash \
14+
icu-dev \
15+
&& docker-php-ext-configure intl \
16+
&& docker-php-ext-install intl opcache \
17+
&& docker-php-ext-enable opcache
18+
19+
RUN ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime \
20+
&& sed -i "s/^;date.timezone =.*/date.timezone = Europe\/Paris/" $PHP_INI_DIR/php.ini
21+
22+
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
23+
24+
RUN usermod -u $UID www-data \
25+
&& groupmod -g $GID www-data
26+
27+
USER www-data:www-data
28+
29+
WORKDIR /var/www

.docker/php/conf.d/dev.ini

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
display_errors = 1
2+
error_reporting = E_ALL
3+
4+
opcache.validate_timestamps = 1
5+
opcache.revalidate_freq = 0

.php-cs-fixer.dist.php

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the CleverAge/RestProcessBundle package.
5+
*
6+
* Copyright (c) Clever-Age
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
if (!file_exists(__DIR__.'/src')) {
13+
exit(0);
14+
}
15+
16+
$fileHeaderComment = <<<'EOF'
17+
This file is part of the CleverAge/RestProcessBundle package.
18+
19+
Copyright (c) Clever-Age
20+
21+
For the full copyright and license information, please view the LICENSE
22+
file that was distributed with this source code.
23+
EOF;
24+
25+
return (new PhpCsFixer\Config())
26+
->setRules([
27+
'@PHP71Migration' => true,
28+
'@PHP82Migration' => true,
29+
'@PHPUnit75Migration:risky' => true,
30+
'@Symfony' => true,
31+
'@Symfony:risky' => true,
32+
'protected_to_private' => false,
33+
'native_constant_invocation' => ['strict' => false],
34+
'header_comment' => ['header' => $fileHeaderComment],
35+
'modernize_strpos' => true,
36+
'get_class_to_class_keyword' => true,
37+
])
38+
->setRiskyAllowed(true)
39+
->setFinder(
40+
(new PhpCsFixer\Finder())
41+
->in(__DIR__.'/src')
42+
->in(__DIR__.'/tests')
43+
->append([__FILE__])
44+
)
45+
->setCacheFile('.php-cs-fixer.cache')
46+
;

Makefile

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
.ONESHELL:
2+
SHELL := /bin/bash
3+
4+
DOCKER_RUN_PHP = docker compose -f .docker/compose.yaml run --rm php "bash" "-c"
5+
DOCKER_COMPOSE = docker compose -f .docker/compose.yaml
6+
7+
start: upd #[Global] Start application
8+
9+
src/vendor: #[Composer] install dependencies
10+
$(DOCKER_RUN_PHP) "composer install --no-interaction"
11+
12+
upd: #[Docker] Start containers detached
13+
touch .docker/.env
14+
make src/vendor
15+
$(DOCKER_COMPOSE) up --remove-orphans --detach
16+
17+
up: #[Docker] Start containers
18+
touch .docker/.env
19+
make src/vendor
20+
$(DOCKER_COMPOSE) up --remove-orphans
21+
22+
stop: #[Docker] Down containers
23+
$(DOCKER_COMPOSE) stop
24+
25+
down: #[Docker] Down containers
26+
$(DOCKER_COMPOSE) down
27+
28+
build: #[Docker] Build containers
29+
$(DOCKER_COMPOSE) build
30+
31+
ps: # [Docker] Show running containers
32+
$(DOCKER_COMPOSE) ps
33+
34+
bash: #[Docker] Connect to php container with current host user
35+
$(DOCKER_COMPOSE) exec php bash
36+
37+
logs: #[Docker] Show logs
38+
$(DOCKER_COMPOSE) logs -f
39+
40+
quality: phpstan php-cs-fixer rector #[Quality] Run all quality checks
41+
42+
phpstan: #[Quality] Run PHPStan
43+
$(DOCKER_RUN_PHP) "vendor/bin/phpstan --no-progress --memory-limit=1G analyse"
44+
45+
php-cs-fixer: #[Quality] Run PHP-CS-Fixer
46+
$(DOCKER_RUN_PHP) "vendor/bin/php-cs-fixer fix --diff --verbose"
47+
48+
rector: #[Quality] Run Rector
49+
$(DOCKER_RUN_PHP) "vendor/bin/rector"
50+
51+
tests: phpunit #[Tests] Run all tests
52+
53+
phpunit: #[Tests] Run PHPUnit
54+
$(DOCKER_RUN_PHP) "vendor/bin/phpunit"

composer.json

+23-2
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,33 @@
3737
"CleverAge\\RestProcessBundle\\": ""
3838
}
3939
},
40+
"autoload-dev": {
41+
"psr-4": {
42+
"CleverAge\\FlysystemProcessBundle\\Tests\\": "tests/"
43+
}
44+
},
4045
"require": {
41-
"cleverage/process-bundle": "3.*|dev-v3.0-dev",
46+
"php": ">=8.1",
47+
"cleverage/process-bundle": "dev-prepare-release",
4248
"nategood/httpful": ">0.2.0, <1.0.0",
4349
"sidus/base-bundle": "~1.0"
4450
},
4551
"require-dev": {
46-
"phpunit/phpunit": "~6.4"
52+
"friendsofphp/php-cs-fixer": "*",
53+
"phpstan/extension-installer": "*",
54+
"phpstan/phpstan": "*",
55+
"phpstan/phpstan-symfony": "*",
56+
"phpunit/phpunit": "*",
57+
"rector/rector": "*",
58+
"roave/security-advisories": "dev-latest",
59+
"symfony/test-pack": "^1.1"
60+
},
61+
"config": {
62+
"allow-plugins": {
63+
"phpstan/extension-installer": true,
64+
"symfony/flex": true,
65+
"symfony/runtime": true
66+
},
67+
"sort-packages": true
4768
}
4869
}

phpstan.neon

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
parameters:
2+
level: 6
3+
paths:
4+
- src
5+
- tests
6+
ignoreErrors:
7+
- '#type has no value type specified in iterable type#'
8+
- '#has parameter .* with no value type specified in iterable type#'
9+
- '#has no value type specified in iterable type array#'
10+
- '#configureOptions\(\) has no return type specified.#'
11+
- '#configure\(\) has no return type specified#'
12+
- '#process\(\) has no return type specified#'
13+
- '#should return Iterator but returns Traversable#'
14+
- '#Negated boolean expression is always false#'
15+
checkGenericClassInNonGenericObjectType: false
16+
reportUnmatchedIgnoredErrors: false
17+
inferPrivatePropertyTypeFromConstructor: true
18+
treatPhpDocTypesAsCertain: false

phpunit.xml.dist

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheResultFile=".phpunit.cache/test-results"
6+
executionOrder="depends,defects"
7+
forceCoversAnnotation="true"
8+
beStrictAboutCoversAnnotation="true"
9+
beStrictAboutOutputDuringTests="true"
10+
beStrictAboutTodoAnnotatedTests="true"
11+
convertDeprecationsToExceptions="true"
12+
failOnRisky="true"
13+
failOnWarning="true"
14+
verbose="true">
15+
<testsuites>
16+
<testsuite name="default">
17+
<directory>tests</directory>
18+
</testsuite>
19+
</testsuites>
20+
21+
<coverage cacheDirectory=".phpunit.cache/code-coverage"
22+
processUncoveredFiles="true">
23+
<include>
24+
<directory suffix=".php">src</directory>
25+
</include>
26+
</coverage>
27+
</phpunit>

rector.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Set\ValueObject\LevelSetList;
7+
use Rector\Symfony\Set\SymfonySetList;
8+
use Rector\ValueObject\PhpVersion;
9+
10+
return RectorConfig::configure()
11+
->withPhpVersion(PhpVersion::PHP_82)
12+
->withPaths([
13+
__DIR__.'/src',
14+
__DIR__.'/tests',
15+
])
16+
->withPhpSets(php82: true)
17+
// here we can define, what prepared sets of rules will be applied
18+
->withPreparedSets(
19+
deadCode: true,
20+
codeQuality: true
21+
)
22+
->withSets([
23+
LevelSetList::UP_TO_PHP_82,
24+
SymfonySetList::SYMFONY_64,
25+
SymfonySetList::SYMFONY_71,
26+
SymfonySetList::SYMFONY_CODE_QUALITY,
27+
SymfonySetList::SYMFONY_CONSTRUCTOR_INJECTION,
28+
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES,
29+
])
30+
;

tests/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)