Skip to content

Commit 74dd893

Browse files
#1 Add Makefile & .docker for local standalone usage. Add rector, phpstan & php-cs-fixer configurations. Remove phpcs configuration.
1 parent da70ea1 commit 74dd893

10 files changed

+240
-69
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-ui-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

.gitignore

+25-19
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,41 @@
1+
/composer.lock
2+
/vendor
3+
.env
4+
.idea
5+
/phpunit.xml
6+
.phpunit.result.cache
7+
.phpunit.cache
8+
.php-cs-fixer.cache
9+
coverage-report
10+
11+
###> phpunit/phpunit ###
12+
/phpunit.xml
13+
.phpunit.result.cache
14+
###< phpunit/phpunit ###
15+
16+
###> symfony/phpunit-bridge ###
17+
.phpunit.result.cache
18+
/phpunit.xml
19+
###< symfony/phpunit-bridge ###
20+
121
###> symfony/framework-bundle ###
2-
/.env
322
/.env.local
423
/.env.local.php
5-
/.env.test
624
/.env.*.local
725
/config/secrets/prod/prod.decrypt.private.php
826
/public/bundles/
927
/var/
1028
/vendor/
1129
###< symfony/framework-bundle ###
12-
###> custom ###
13-
/docker-compose.override.yml
14-
/.idea
15-
/.pdepend
16-
/.composer/cache
17-
###< custom ###
30+
31+
###> friendsofphp/php-cs-fixer ###
32+
/.php-cs-fixer.php
33+
/.php-cs-fixer.cache
34+
###< friendsofphp/php-cs-fixer ###
1835

1936
###> symfony/webpack-encore-bundle ###
2037
/node_modules/
2138
/public/build/
2239
npm-debug.log
2340
yarn-error.log
2441
###< symfony/webpack-encore-bundle ###
25-
26-
###> squizlabs/php_codesniffer ###
27-
/.phpcs-cache
28-
/phpcs.xml
29-
/.php-cs-fixer.cache
30-
###< squizlabs/php_codesniffer ###
31-
32-
###> friendsofphp/php-cs-fixer ###
33-
/.php-cs-fixer.php
34-
/.php-cs-fixer.cache
35-
###< friendsofphp/php-cs-fixer ###

.php-cs-fixer.dist.php

+37-22
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,46 @@
11
<?php
22

3-
$finder = PhpCsFixer\Finder::create()
4-
->in(__DIR__.'/src')
5-
->ignoreDotFiles(true)
6-
->ignoreVCS(true)
7-
->exclude(['build', 'vendor'])
8-
->files()
9-
->name('*.php')
10-
;
3+
/*
4+
* This file is part of the CleverAge/UiProcessBundle 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+
*/
1111

12-
$config = new PhpCsFixer\Config();
12+
if (!file_exists(__DIR__.'/src')) {
13+
exit(0);
14+
}
1315

14-
return $config
15-
->setUsingCache(true)
16-
->setRiskyAllowed(true)
17-
->setFinder($finder)
16+
$fileHeaderComment = <<<'EOF'
17+
This file is part of the CleverAge/UiProcessBundle 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())
1826
->setRules([
19-
'@PHP80Migration' => true,
20-
'@PHP80Migration:risky' => true,
27+
'@PHP71Migration' => true,
28+
'@PHP82Migration' => true,
29+
'@PHPUnit75Migration:risky' => true,
2130
'@Symfony' => true,
2231
'@Symfony:risky' => true,
23-
'array_syntax' => ['syntax' => 'short'],
24-
'fopen_flags' => false,
25-
'ordered_imports' => true,
2632
'protected_to_private' => false,
27-
'single_line_throw' => false,
28-
// this must be disabled because the output of some tests include NBSP characters
29-
'non_printable_character' => false,
33+
'native_constant_invocation' => ['strict' => false],
34+
'header_comment' => ['header' => $fileHeaderComment],
35+
'modernize_strpos' => true,
36+
'get_class_to_class_keyword' => true,
3037
])
31-
;
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"

phpcs.xml.dist

-19
This file was deleted.

phpstan.neon

+19-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
parameters:
2-
level: 8
3-
paths:
4-
- src
5-
excludePaths:
6-
- src/DependencyInjection/Configuration.php
7-
ignoreErrors:
8-
- '#is never written, only read#'
9-
- '#has no value type specified in iterable type#'
10-
- '#has parameter .* with no value type specified in iterable type#'
2+
level: 8
3+
paths:
4+
- src
5+
- tests
6+
excludePaths:
7+
- src/DependencyInjection/Configuration.php
8+
ignoreErrors:
9+
- '#type has no value type specified in iterable type#'
10+
- '#has parameter .* with no value type specified in iterable type#'
11+
- '#has no value type specified in iterable type array#'
12+
- '#configureOptions\(\) has no return type specified.#'
13+
- '#configure\(\) has no return type specified#'
14+
- '#process\(\) has no return type specified#'
15+
- '#should return Iterator but returns Traversable#'
16+
- '#Negated boolean expression is always false#'
17+
checkGenericClassInNonGenericObjectType: false
18+
reportUnmatchedIgnoredErrors: false
19+
inferPrivatePropertyTypeFromConstructor: true
20+
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+
;

0 commit comments

Comments
 (0)