Skip to content

Commit d8a782e

Browse files
committed
PHP 8
1 parent 4ae1605 commit d8a782e

43 files changed

Lines changed: 494 additions & 828 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.docker/php/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM php:8.0-fpm-alpine
2+
3+
ENV USER_ID=1000
4+
5+
RUN apk update --quiet && \
6+
apk add --quiet --no-cache bash git shadow openssh openssl-dev p7zip && \
7+
apk add --quiet --no-cache pcre-dev ${PHPIZE_DEPS}
8+
9+
RUN mkdir -p /var/www/.ssh/ && \
10+
touch /var/www/.ssh/known_hosts && \
11+
ssh-keyscan github.com >> /var/www/.ssh/known_hosts
12+
13+
WORKDIR /var/www/html
14+
15+
COPY --chown=www-data:www-data --from=composer:2 /usr/bin/composer /usr/local/bin/composer
16+
17+
RUN usermod -u $USER_ID www-data && chown -R www-data:www-data /var/www/ .
18+
USER www-data
19+
20+
CMD ["php-fpm"]

.docker/php/php.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
memory_limit = 128M

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
vendor
33
/.phpunit.result.cache
44
composer.lock
5+
.vscode

.phpcstd.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
include = 'vendor/spaceemotion/php-coding-standard/.phpcstd.dist.ini'
2+
3+
source[] = composer.json
4+
source[] = src
5+
6+
[phpstan]
7+
enabled = true
8+
9+
[composer-normalize]
10+
enabled = true
11+
12+
[parallel-lint]
13+
enabled = true
14+
15+
[ecs]
16+
enabled = true

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Randy Schütt
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
DOCKER_SEARCH_SERVICE = time
2+
3+
env:
4+
cp .env.dist .env
5+
6+
new: kill
7+
docker-compose up -d --build --remove-orphans
8+
make install
9+
up:
10+
docker-compose up -d
11+
make autoload
12+
stop:
13+
docker-compose stop
14+
kill:
15+
docker-compose kill
16+
17+
test:
18+
docker-compose exec $(DOCKER_SEARCH_SERVICE) composer test
19+
20+
lint:
21+
docker-compose exec $(DOCKER_SEARCH_SERVICE) composer lint
22+
lint-static:
23+
docker-compose exec $(DOCKER_SEARCH_SERVICE) composer lint:static
24+
lint-fix:
25+
docker-compose exec $(DOCKER_SEARCH_SERVICE) composer lint:fix
26+
lint-style:
27+
docker-compose exec $(DOCKER_SEARCH_SERVICE) composer lint:style
28+
lint-fix-style:
29+
docker-compose exec $(DOCKER_SEARCH_SERVICE) composer lint:fix-style
30+
31+
autoload:
32+
docker-compose exec $(DOCKER_SEARCH_SERVICE) composer dump-autoload
33+
install:
34+
docker-compose exec $(DOCKER_SEARCH_SERVICE) composer install --no-interaction --prefer-dist
35+
normalize:
36+
docker-compose exec $(DOCKER_SEARCH_SERVICE) composer normalize
37+
update-lock:
38+
docker-compose exec $(DOCKER_SEARCH_SERVICE) composer update --lock
39+
update:
40+
docker-compose exec $(DOCKER_SEARCH_SERVICE) composer update
41+
validate:
42+
docker-compose exec $(DOCKER_SEARCH_SERVICE) composer validate
43+
44+
bash:
45+
docker-compose exec $(DOCKER_SEARCH_SERVICE) bash

composer.json

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,74 @@
11
{
22
"name": "dgame/php-time",
3-
"description": "php time conversion",
4-
"license": "MIT",
53
"type": "library",
6-
"homepage": "https://github.com/php-time",
4+
"description": "php time conversion",
75
"keywords": [
86
"Date",
97
"Time",
108
"Timer",
119
"Clock",
1210
"Time conversion"
1311
],
12+
"homepage": "https://github.com/php-time",
13+
"license": "MIT",
1414
"authors": [
1515
{
1616
"name": "Randy Schütt",
17-
"email": "rswhite4@gmail.com"
17+
"email": "rswhite4@gmail.com",
18+
"role": "lead"
1819
}
1920
],
2021
"require": {
21-
"php": ">=7.1"
22+
"php": "8.0",
23+
"thecodingmachine/safe": "^1.3"
2224
},
2325
"require-dev": {
24-
"phpunit/phpunit": ">=8",
25-
"phpstan/phpstan": "^0.12"
26+
"ergebnis/composer-normalize": "^2.4",
27+
"ergebnis/phpstan-rules": "^0.15",
28+
"php-parallel-lint/php-parallel-lint": "^1.2",
29+
"phpstan/phpstan": "^0.12",
30+
"phpstan/phpstan-deprecation-rules": "^0.12",
31+
"phpstan/phpstan-strict-rules": "^0.12",
32+
"phpunit/phpunit": "^9.4",
33+
"roave/security-advisories": "dev-latest",
34+
"slevomat/coding-standard": "dev-master",
35+
"spaceemotion/php-coding-standard": "dev-master",
36+
"spaze/phpstan-disallowed-calls": "^1.5",
37+
"symplify/easy-coding-standard": "^9.3",
38+
"thecodingmachine/phpstan-safe-rule": "^1.0",
39+
"thecodingmachine/phpstan-strict-rules": "^0.12"
40+
},
41+
"config": {
42+
"optimize-autoloader": true,
43+
"platform": {
44+
"php": "8.0"
45+
},
46+
"preferred-install": "dist",
47+
"process-timeout": 0,
48+
"sort-packages": true
2649
},
2750
"autoload": {
28-
"classmap": [
29-
"src/"
30-
],
51+
"psr-4": {
52+
"Dgame\\Time\\": "src/"
53+
},
3154
"files": [
3255
"src/functions.php"
33-
],
56+
]
57+
},
58+
"autoload-dev": {
3459
"psr-4": {
35-
"Dgame\\Time\\": "src/"
60+
"Dgame\\Time\\Tests\\": "tests/"
3661
}
3762
},
63+
"minimum-stability": "dev",
64+
"prefer-stable": true,
3865
"scripts": {
39-
"test": [
40-
"phpunit",
41-
"phpstan analyse src --level=8"
42-
],
43-
"coverage": [
44-
"phpunit --coverage-clover=coverage"
45-
]
66+
"coverage": "phpunit --coverage-clover=coverage",
67+
"lint": "phpcstd --continue",
68+
"lint:fix": "phpcstd --fix --continue",
69+
"lint:fix-style": "ecs --fix",
70+
"lint:static": "phpstan",
71+
"lint:style": "ecs",
72+
"test": "phpunit --exclude-group timer"
4673
}
4774
}

docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: "3.7"
2+
services:
3+
time:
4+
container_name: time
5+
build:
6+
dockerfile: ./.docker/php/Dockerfile
7+
context: .
8+
volumes:
9+
- ./:/var/www/html/
10+
- ./.docker/php/php.ini:/usr/local/etc/php/php.ini

ecs.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Fixer\ControlStructure\NoUselessElseFixer;
6+
use PhpCsFixer\Fixer\FunctionNotation\FunctionDeclarationFixer;
7+
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
8+
use PhpCsFixer\Fixer\Operator\BinaryOperatorSpacesFixer;
9+
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
10+
use PhpCsFixer\Fixer\Strict\StrictParamFixer;
11+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
12+
use Symplify\EasyCodingStandard\ValueObject\Option;
13+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
14+
15+
return static function (ContainerConfigurator $containerConfigurator): void {
16+
$parameters = $containerConfigurator->parameters();
17+
$parameters->set(Option::PATHS, [
18+
__DIR__ . '/src',
19+
__DIR__ . '/tests'
20+
]);
21+
$containerConfigurator->import(SetList::PSR_12);
22+
$parameters->set(Option::SKIP, [
23+
BinaryOperatorSpacesFixer::class, // So that union types like `int|bool` won't be replaced with `int | bool`
24+
FunctionDeclarationFixer::class // So that `fn(int $a)` won't be replaced with `fn (int $a)`
25+
]);
26+
$containerConfigurator->import(SetList::CLEAN_CODE);
27+
28+
$services = $containerConfigurator->services();
29+
$services->set(StrictParamFixer::class);
30+
$services->set(DeclareStrictTypesFixer::class);
31+
$services->set(NoUselessElseFixer::class);
32+
$services->set(NoUnusedImportsFixer::class);
33+
};

phpstan.neon

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
includes:
2+
- vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
3+
- vendor/thecodingmachine/phpstan-strict-rules/phpstan-strict-rules.neon
4+
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
5+
- vendor/phpstan/phpstan-strict-rules/rules.neon
6+
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
7+
- vendor/spaze/phpstan-disallowed-calls/extension.neon
8+
- vendor/spaze/phpstan-disallowed-calls/disallowed-dangerous-calls.neon
9+
- vendor/spaze/phpstan-disallowed-calls/disallowed-execution-calls.neon
10+
11+
parameters:
12+
treatPhpDocTypesAsCertain: false
13+
checkInternalClassCaseSensitivity: true
14+
checkTooWideReturnTypesInProtectedAndPublicMethods: true
15+
checkUninitializedProperties: true
16+
checkMissingCallableSignature: true
17+
level: max
18+
paths:
19+
- src
20+
21+
rules:
22+
- Ergebnis\PHPStan\Rules\Expressions\NoCompactRule
23+
- Ergebnis\PHPStan\Rules\Expressions\NoEmptyRule
24+
- Ergebnis\PHPStan\Rules\Expressions\NoErrorSuppressionRule
25+
- Ergebnis\PHPStan\Rules\Expressions\NoEvalRule
26+
- Ergebnis\PHPStan\Rules\Expressions\NoIssetRule
27+
- Ergebnis\PHPStan\Rules\Files\DeclareStrictTypesRule
28+
- Ergebnis\PHPStan\Rules\Methods\PrivateInFinalClassRule

0 commit comments

Comments
 (0)