Skip to content

Commit c89be66

Browse files
committed
feat(php82): to suuport PHP82
found an isue that the repo https://github.com/squizlabs/PHP_CodeSniffer Doesn't upgrade and support PHP8 + higher phpunit version. so we used to have a unittest that extend from libs which need to be removed.
1 parent bf1a92a commit c89be66

24 files changed

+301
-1008
lines changed

.travis.yml

+6-12
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,24 @@ language: php
22

33
matrix:
44
include:
5-
- php: 7.0
6-
- php: 7.1
7-
- php: nightly
5+
- dist: focal
6+
php: 8.2
7+
env: LIBONIG_INSTALL=1
88

99
fast_finish: true
1010

11-
allow_failures:
12-
- php: nightly
13-
- php: 7.0
14-
15-
before_script:
11+
before_install:
12+
- if [ -n "$LIBONIG_INSTALL" ]; then sudo apt-get install libonig5; fi
1613
- travis_retry composer self-update
1714
- travis_retry composer update --prefer-dist
1815

19-
script:
20-
- vendor/bin/phpunit --testsuite=sniff_tests
21-
2216
deploy:
2317
provider: script
2418
script: scripts/deploy.sh
2519
skip_cleanup: false
2620
on:
2721
tags: true
28-
condition: "$TRAVIS_PHP_VERSION = 7.1"
22+
condition: "$TRAVIS_PHP_VERSION = 8.2"
2923

3024
cache:
3125
directories:

composer.json

+23-21
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
{
2-
"name": "crazyfactory/sniffs",
3-
"description": "Crazy Factory default code styles to be used with Squizlabs' code sniffer.",
4-
"license": "proprietary",
5-
"require": {
6-
"symplify/easy-coding-standard": "^2.2.0"
7-
},
8-
"require-dev": {
9-
"phpunit/phpunit": "~4.0"
10-
},
11-
"autoload": {
12-
"psr-4": {
13-
"CrazyFactory\\Sniffs\\": "src/CrazyFactory/Sniffs/"
14-
}
15-
},
16-
"config": {
17-
"optimize-autoloader": true,
18-
"preferred-install": {
19-
"*": "dist"
20-
}
2+
"name": "crazyfactory/sniffs",
3+
"description": "Crazy Factory default code styles to be used with Squizlabs' code sniffer.",
4+
"license": "proprietary",
5+
"require": {
6+
"PHP": "^8.2",
7+
"symplify/easy-coding-standard": "^11.3"
8+
},
9+
"require-dev": {
10+
"squizlabs/php_codesniffer": "^3.7",
11+
"phpunit/phpunit": "^10.0"
12+
},
13+
"autoload": {
14+
"psr-4": {
15+
"CrazyFactory\\Sniffs\\": "src/CrazyFactory/Sniffs/"
16+
}
17+
},
18+
"config": {
19+
"optimize-autoloader": true,
20+
"preferred-install": {
21+
"*": "dist"
2122
},
22-
"scripts": {
23-
"test": "phpunit -c phpunit.xml"
23+
"platform": {
24+
"php": "8.2.3"
2425
}
26+
}
2527
}

docker-compose.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
version: '3.4'
2+
3+
services:
4+
php-sniff-php-fpm:
5+
container_name: php-sniff-php-fpm
6+
build:
7+
context: ./
8+
dockerfile: ./docker/php/Dockerfile
9+
target: debugging
10+
ports:
11+
- "30112:80"
12+
volumes:
13+
- ./:/var/www/project
14+
environment:
15+
IN_DOCKER: 1
16+
17+
PHP_INI_UPLOAD_MAX_FILESIZE: 100M
18+
PHP_INI_POST_MAX_SIZE: 108M
19+
PHP_INI_MAX_FILE_UPLOADS: 200
20+
INI_EXPOSE_PHP: 0
21+
22+
INI_MAX_EXECUTION_TIME: 0
23+
INI_MEMORY_LIMIT: 2G
24+
25+
INI_ERROR_LOG: .debug/php-errors.log
26+
INI_LOG_ERRORS: 1
27+
INI_DISPLAY_ERRORS: "E_ALL & ~E_DEPRECATED & ~E_NOTICE"
28+
INI_DISPLAY_STARTUP_ERRORS: 1
29+
INI_ERROR_REPORTING: 1
30+
INI_HTML_ERRORS: 0
31+
32+
# https://xdebug.org/docs/all_settings#mode
33+
# INI_XDEBUG_MODE=off,debug,profile,trace - EG - Enables step debugger, profiling and tracing
34+
INI_XDEBUG_MODE: "debug"
35+
INI_XDEBUG_HOST: host.docker.internal
36+
INI_XDEBUG_PORT: 9000
37+
INI_IDEKEY: PHPSTORM
38+
INI_XDEBUG_OUTPUT_DIR: "/var/www/project/.debug"
39+
INI_XDEBUG_DISCOVER_CLIENT_HOST: 1
40+
INI_XDEBUG_CLI_COLOR: 1
41+
INI_XDEBUG_START_WITH_REQUEST: 1
42+
43+
INI_XDEBUG_LOG: "/var/www/project/.debug/remote.log"
44+
INI_XDEBUG_LOG_LEVEL: 7
45+
46+
INI_XDEBUG_TRACE_FORMAT: 0
47+
INI_XDEBUG_TRACE_OUTPUT_NAME: "trace.%t-%s"
48+
49+
INI_XDEBUG_PROFILER_APPEND: 0
50+
INI_XDEBUG_PROFILER_OUTPUT_NAME: "cachegrind.out.%t-%s"
51+
52+
PHP_IDE_CONFIG: "serverName=php-sniff-php-fpm"

docker-project.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"file": "./docker-compose.yml",
3+
"service": "php-sniff-php-fpm",
4+
"command": "composer %args%",
5+
"actions": {
6+
"install": {
7+
"command": "composer %action% %args%",
8+
"user": "www-data"
9+
},
10+
"update": {
11+
"command": "composer %action% %args%",
12+
"user": "www-data"
13+
},
14+
"php": {
15+
"command": "php %args%",
16+
"user": "www-data"
17+
},
18+
"bash": {
19+
"user": "www-data"
20+
},
21+
"bash:root": {
22+
"command": ["bash"],
23+
"user": "root"
24+
},
25+
"start:dev": {
26+
"service": "@host",
27+
"command": [
28+
"docker-compose build",
29+
"docker-compose up -d"
30+
]
31+
}
32+
}
33+
}

docker/docker-compose.dev.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
version: '3.4'
2+
3+
services:
4+
php-sniff-php-fpm:
5+
container_name: php-sniff-php-fpm
6+
build:
7+
context: ./
8+
dockerfile: ./docker/php/Dockerfile
9+
target: image-ci-testing
10+
ports:
11+
- "30112:80"
12+
volumes:
13+
- ./:/var/www/project
14+
environment:
15+
IN_DOCKER: 1
16+
17+
PHP_INI_UPLOAD_MAX_FILESIZE: 100M
18+
PHP_INI_POST_MAX_SIZE: 108M
19+
PHP_INI_MAX_FILE_UPLOADS: 200
20+
INI_EXPOSE_PHP: 0
21+
22+
INI_MAX_EXECUTION_TIME: 0
23+
INI_MEMORY_LIMIT: 2G
24+
25+
INI_ERROR_LOG: .debug/php-errors.log
26+
INI_LOG_ERRORS: 1
27+
INI_DISPLAY_ERRORS: "E_ALL & ~E_DEPRECATED & ~E_NOTICE"
28+
INI_DISPLAY_STARTUP_ERRORS: 1
29+
INI_ERROR_REPORTING: 1
30+
INI_HTML_ERRORS: 0
31+
32+
# https://xdebug.org/docs/all_settings#mode
33+
# INI_XDEBUG_MODE=off,debug,profile,trace - EG - Enables step debugger, profiling and tracing
34+
INI_XDEBUG_MODE: "debug"
35+
INI_XDEBUG_HOST: host.docker.internal
36+
INI_XDEBUG_PORT: 9000
37+
INI_IDEKEY: PHPSTORM
38+
INI_XDEBUG_OUTPUT_DIR: "/var/www/project/.debug"
39+
INI_XDEBUG_DISCOVER_CLIENT_HOST: 1
40+
INI_XDEBUG_CLI_COLOR: 1
41+
INI_XDEBUG_START_WITH_REQUEST: 1
42+
43+
INI_XDEBUG_LOG: "/var/www/project/.debug/remote.log"
44+
INI_XDEBUG_LOG_LEVEL: 7
45+
46+
INI_XDEBUG_TRACE_FORMAT: 0
47+
INI_XDEBUG_TRACE_OUTPUT_NAME: "trace.%t-%s"
48+
49+
INI_XDEBUG_PROFILER_APPEND: 0
50+
INI_XDEBUG_PROFILER_OUTPUT_NAME: "cachegrind.out.%t-%s"
51+
52+
PHP_IDE_CONFIG: "serverName=php-sniff-php-fpm"

docker/php/Dockerfile

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# For why we separate so many docker layers by performing multiple RUN and COPY, please see
2+
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
3+
# https://www.ginkgobioworks.com/2020/05/18/optimizing-your-dockerfile/
4+
5+
FROM base-php-fpm:php82 as base
6+
7+
COPY ./docker/php/www.conf /usr/local/etc/php-fpm.d/www.conf
8+
RUN chmod 644 /usr/local/etc/php-fpm.d/www.conf
9+
10+
FROM base as composer-install
11+
12+
COPY --chown=www-data:www-data ./composer.json /var/www/project/composer.json
13+
COPY --chown=www-data:www-data ./composer.lock /var/www/project/composer.lock
14+
15+
USER www-data
16+
RUN COMPOSER_MEMORY_LIMIT=-1 composer install
17+
USER root
18+
19+
FROM base as copy-volume
20+
21+
COPY --chown=www-data:www-data ./ /var/www/project
22+
23+
24+
FROM base as env-file
25+
26+
RUN mkdir -p shop-env-config
27+
RUN touch shop-env-config/.env
28+
29+
RUN chown www-data:www-data /var/www/project/shop-env-config/.env
30+
31+
32+
# ---------------- Debug ----------------- #
33+
34+
FROM base as debugging
35+
36+
RUN install-php-extensions xdebug
37+
38+
# debug settings
39+
RUN mkdir -m 777 -p .debug
40+
RUN chown www-data:www-data .debug
41+
42+
# Travis should have the same ini setup as live prod
43+
COPY ./docker/php/php-fpm-ini.ini /usr/local/etc/php/conf.d/999-overrides.ini
44+
45+
COPY --from=composer-install /var/www/project .
46+
COPY --from=env-file /var/www/project .
47+
COPY --from=copy-volume /var/www/project .
48+
49+
# Bind mount location
50+
VOLUME ["/var/www/project"]
51+
52+
CMD php-fpm
53+
54+
55+
# ---------------- CI ----------------- #
56+
57+
FROM base as image-ci-testing
58+
59+
# Travis should have the same ini setup as live prod
60+
COPY ./docker/php/php-fpm-ini.ini /usr/local/etc/php/conf.d/999-overrides.ini
61+
62+
COPY --from=composer-install /var/www/project .
63+
COPY --from=env-file /var/www/project .
64+
COPY --from=copy-volume /var/www/project .
65+
66+
# Bind mount location
67+
VOLUME ["/var/www/project"]
68+
69+
CMD php-fpm

docker/php/php-fpm-ini.ini

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
memory_limit = -1
2+
3+
[xdebug]
4+
5+
xdebug.mode=${INI_XDEBUG_MODE}
6+
xdebug.client_host=${INI_XDEBUG_HOST}
7+
xdebug.client_port=${INI_XDEBUG_PORT}
8+
xdebug.idekey=${INI_IDEKEY}
9+
xdebug.output_dir=${INI_XDEBUG_OUTPUT_DIR}
10+
xdebug.discover_client_host = ${INI_XDEBUG_DISCOVER_CLIENT_HOST}
11+
xdebug.cli_color = ${INI_XDEBUG_CLI_COLOR}
12+
xdebug.start_with_request = ${INI_XDEBUG_START_WITH_REQUEST}
13+
14+
xdebug.log = ${INI_XDEBUG_LOG}
15+
xdebug.log_level = ${INI_XDEBUG_LOG_LEVEL}
16+
17+
xdebug.trace_format = ${INI_XDEBUG_TRACE_FORMAT}
18+
xdebug.trace_output_name = ${INI_XDEBUG_TRACE_OUTPUT_NAME}
19+
20+
xdebug.profiler_append = ${INI_XDEBUG_PROFILER_APPEND}
21+
xdebug.profiler_output_name = ${INI_XDEBUG_PROFILER_OUTPUT_NAME}
22+
23+

docker/php/www.conf

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[www]
2+
3+
user = www-data
4+
group = www-data
5+
6+
pm = static
7+
pm.max_children = 75
8+
pm.max_requests = 250
9+
pm.status_path = /status
10+
11+
ping.path = /ping
12+
13+
access.format = "%m %r %d %C %M %s %q"

ecs.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 PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
6+
use Symplify\EasyCodingStandard\Config\ECSConfig;
7+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
8+
9+
return function (ECSConfig $ecsConfig): void {
10+
$ecsConfig->paths([
11+
__DIR__ . '/src',
12+
__DIR__ . '/tests',
13+
]);
14+
15+
// this way you add a single rule
16+
$ecsConfig->rules([
17+
NoUnusedImportsFixer::class,
18+
]);
19+
20+
// this way you can add sets - group of rules
21+
$ecsConfig->sets([
22+
// run and fix, one by one
23+
// SetList::SPACES,
24+
// SetList::ARRAY,
25+
// SetList::DOCBLOCK,
26+
// SetList::NAMESPACES,
27+
// SetList::COMMENTS,
28+
// SetList::PSR_12,
29+
]);
30+
};

phpunit.xml

-8
This file was deleted.

src/CrazyFactory/Tests/Classes/UnusedUseStatementUnitTest.inc

-24
This file was deleted.

0 commit comments

Comments
 (0)