Skip to content

Commit

Permalink
strict types used
Browse files Browse the repository at this point in the history
  • Loading branch information
Vítězslav Dvořák committed Sep 26, 2024
1 parent c81e3b8 commit 970a17d
Show file tree
Hide file tree
Showing 13 changed files with 762 additions and 564 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
/debian/multiflexi-discomp2abraflexi/
/debian/multiflexi-discomp2abraflexi.debhelper.log
/debian/multiflexi-discomp2abraflexi.substvars
/.build/
105 changes: 105 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?php

declare(strict_types=1);

/**
* This file is part of the discomp2abraflexi package
*
* https://github.com/Spoje-NET/discomp2abraflexi
*
* (c) SpojeNet s.r.o. <http://spojenet.cz/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Ergebnis\PhpCsFixer\Config\Factory;
use Ergebnis\PhpCsFixer\Config\Rules;
use Ergebnis\PhpCsFixer\Config\RuleSet\Php74;

$header = <<<'HEADER'
This file is part of the discomp2abraflexi package
https://github.com/Spoje-NET/discomp2abraflexi
(c) SpojeNet s.r.o. <http://spojenet.cz/>
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
HEADER;

$ruleSet = Php74::create()->withHeader($header)->withRules(Rules::fromArray([
'blank_line_before_statement' => [
'statements' => [
'break',
'continue',
'declare',
'default',
'do',
'exit',
'for',
'foreach',
'goto',
'if',
'include',
'include_once',
'require',
'require_once',
'return',
'switch',
'throw',
'try',
'while',
],
],
'concat_space' => [
'spacing' => 'none',
],
'date_time_immutable' => false,
'error_suppression' => false,
'final_class' => false,
'mb_str_functions' => false,
'native_function_invocation' => [
'exclude' => [
'sprintf',
],
'include' => [
'@compiler_optimized',
],
'scope' => 'all',
'strict' => false,
],
'php_unit_internal_class' => false,
'php_unit_test_annotation' => [
'style' => 'prefix',
],
'php_unit_test_class_requires_covers' => false,
'return_to_yield_from' => false,
'phpdoc_array_type' => false,
'phpdoc_list_type' => false,
'attribute_empty_parentheses' => false,
'final_public_method_for_abstract_class' => false,
'class_attributes_separation' => [
'elements' => [
'const' => 'only_if_meta',
'property' => 'only_if_meta',
'trait_import' => 'none',
'case' => 'none',
],
],
'yoda_style' => false,
'php_unit_test_case_static_method_calls' => false,
]));

$config = Factory::fromRuleSet($ruleSet);

$config->getFinder()
->append([
__DIR__.'/.php-cs-fixer.dist.php',
])
->in('src')
->in('tests');

$config->setCacheFile(__DIR__.'/.build/php-cs-fixer/.php-cs-fixer.cache');

return $config;
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
# vim: set tabstop=8 softtabstop=8 noexpandtab:
.PHONY: help
help: ## Displays this list of targets with descriptions
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}'

.PHONY: static-code-analysis
static-code-analysis: vendor ## Runs a static code analysis with phpstan/phpstan
vendor/bin/phpstan analyse --configuration=phpstan-default.neon.dist --memory-limit=-1

.PHONY: static-code-analysis-baseline
static-code-analysis-baseline: check-symfony vendor ## Generates a baseline for static code analysis with phpstan/phpstan
vendor/bin/phpstan analyze --configuration=phpstan-default.neon.dist --generate-baseline=phpstan-default-baseline.neon --memory-limit=-1

.PHONY: tests
tests: vendor
vendor/bin/phpunit tests

.PHONY: vendor
vendor: composer.json composer.lock ## Installs composer dependencies
composer install

.PHONY: cs
cs: ## Update Coding Standards
vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --diff --verbose



buildimage:
docker build -t vitexsoftware/discomp2abraflexi:latest .

Expand Down
13 changes: 11 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
"spojenet/flexibee": "dev-main"
},
"require-dev": {
"phpunit/phpunit": "11.0.x-dev"
"phpunit/phpunit": "*",
"phpstan/phpstan": "*",
"friendsofphp/php-cs-fixer": "^3.61",
"ergebnis/composer-normalize": "^2.43",
"ergebnis/php-cs-fixer-config": "^6.34"
},
"license": "MIT",
"autoload": {
Expand All @@ -20,5 +24,10 @@
"email": "[email protected]"
}
],
"minimum-stability": "dev"
"minimum-stability": "dev",
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
}
}
}
165 changes: 86 additions & 79 deletions discomp2abraflexi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions phpstan-default-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
parameters:
ignoreErrors:
9 changes: 9 additions & 0 deletions phpstan-default.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
includes:
- phpstan-default-baseline.neon

parameters:
inferPrivatePropertyTypeFromConstructor: true
level: 6
paths:
- src
- tests
Binary file added social-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 970a17d

Please sign in to comment.