Skip to content

Commit e3383db

Browse files
committed
[TASK] Introduce phpstan, rector and fractor, adapt php-cs-fixer configs, update composer.json and ext_emconf.php for TYPO3 13
1 parent 7cf0065 commit e3383db

6 files changed

+106
-24
lines changed

composer.json

+15-8
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,22 @@
2727
}
2828
],
2929
"require": {
30-
"php": ">=8.1",
31-
"typo3/cms-backend": "^12.4",
32-
"typo3/cms-core": "^12.4",
33-
"typo3/cms-extbase": "^12.4",
34-
"typo3/cms-frontend": "^12.4",
30+
"php": ">=8.3",
31+
"typo3/cms-backend": "^12.4 || ^13.4",
32+
"typo3/cms-core": "^12.4 || ^13.4",
33+
"typo3/cms-extbase": "^12.4 || ^13.4",
34+
"typo3/cms-frontend": "^12.4 || ^13.4",
3535
"symfony/console": "^6.3",
3636
"doctrine/dbal": "^3.6"
3737
},
3838
"require-dev": {
3939
"phpunit/phpunit": "^10.0",
4040
"typo3/testing-framework": "^8.0",
41-
"friendsofphp/php-cs-fixer": "^3.0"
41+
"friendsofphp/php-cs-fixer": "^3.0",
42+
"saschaegerer/phpstan-typo3": "^1.10",
43+
"phpstan/phpstan": "^1.11",
44+
"ssch/typo3-rector": "^2.5",
45+
"a9f/typo3-fractor": "^0.4"
4246
},
4347
"suggest": {
4448
"jaybizzle/crawler-detect": "If you do not want to redirect bots.",
@@ -65,7 +69,8 @@
6569
"bin-dir": ".Build/bin",
6670
"allow-plugins": {
6771
"typo3/class-alias-loader": true,
68-
"typo3/cms-composer-installers": true
72+
"typo3/cms-composer-installers": true,
73+
"a9f/fractor-extension-installer": true
6974
}
7075
},
7176
"scripts": {
@@ -74,7 +79,9 @@
7479
"mkdir -p .Build/public/typo3conf/ext/",
7580
"[ -L .Build/public/typo3conf/ext/locate ] || ln -snvf ../../../../. .Build/public/typo3conf/ext/locate"
7681
],
77-
"cs-fix": ".Build/bin/php-cs-fixer fix --config php-cs-fixer.php --using-cache no --show-progress dots -v"
82+
"check:cs": "./.Build/bin/php-cs-fixer fix --dry-run --config ./php-cs-fixer.php --using-cache no --show-progress dots -v --diff --format=txt",
83+
"fix:cs": "./.Build/bin/php-cs-fixer fix --config ./php-cs-fixer.php --using-cache no --show-progress dots -v --diff --format=txt",
84+
"check:phpstan": "./.Build/bin/phpstan analyse -c ./phpstan.neon"
7885
},
7986
"extra": {
8087
"typo3/cms": {

ext_emconf.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
$EM_CONF['locate'] = [
44
'title' => 'Locate',
55
'description' => 'The users country, preferred language and other facts will be detected. Depending on configurable rules the user can be redirected to other languages or pages. Locate also provides geo blocking for configurable pages in configurable countries.',
6-
'version' => '12.0.3',
6+
'version' => '13.0.0',
77
'category' => 'fe',
88
'constraints' => [
99
'depends' => [
10-
'typo3' => '12.4.0-12.4.99',
10+
'typo3' => '12.4.0-13.4.99',
1111
],
1212
'conflicts' => [],
1313
'suggests' => [

fractor.php

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
use a9f\Fractor\Configuration\FractorConfiguration;
4+
use a9f\FractorTypoScript\Configuration\TypoScriptProcessorOption;
5+
use a9f\Typo3Fractor\Set\Typo3LevelSetList;
6+
use Helmich\TypoScriptParser\Parser\Printer\PrettyPrinterConfiguration;
7+
8+
return FractorConfiguration::configure()
9+
->withPaths([
10+
__DIR__ . '/*',
11+
])
12+
->withSkip([
13+
__DIR__ . '/.Build',
14+
])
15+
->withSets([
16+
Typo3LevelSetList::UP_TO_TYPO3_13
17+
])
18+
->withOptions([
19+
TypoScriptProcessorOption::INDENT_SIZE => 4,
20+
TypoScriptProcessorOption::INDENT_CHARACTER => PrettyPrinterConfiguration::INDENTATION_STYLE_SPACES,
21+
TypoScriptProcessorOption::ADD_CLOSING_GLOBAL => false,
22+
TypoScriptProcessorOption::INCLUDE_EMPTY_LINE_BREAKS => true,
23+
TypoScriptProcessorOption::INDENT_CONDITIONS => true,
24+
]);

php-cs-fixer.php

+26-14
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,47 @@
3030
->setRiskyAllowed(true)
3131
->setRules([
3232
'@DoctrineAnnotation' => true,
33-
'@PER' => true,
34-
'@PSR2' => true,
33+
// @todo: Switch to @PER-CS2.0 once php-cs-fixer's todo list is done: https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/7247
34+
'@PER-CS1.0' => true,
35+
'array_indentation' => true,
3536
'array_syntax' => ['syntax' => 'short'],
36-
'blank_line_after_opening_tag' => true,
37-
'braces' => ['allow_single_line_closure' => true],
37+
'braces_position' => true,
3838
'cast_spaces' => ['space' => 'none'],
39-
'compact_nullable_typehint' => true,
39+
// @todo: Can be dropped once we enable @PER-CS2.0
40+
'compact_nullable_type_declaration' => true,
4041
'concat_space' => ['spacing' => 'one'],
42+
'control_structure_braces' => true,
43+
'control_structure_continuation_position' => true,
4144
'declare_equal_normalize' => ['space' => 'none'],
45+
'declare_parentheses' => true,
4246
'dir_constant' => true,
47+
// @todo: Can be dropped once we enable @PER-CS2.0
48+
'function_declaration' => [
49+
'closure_fn_spacing' => 'none',
50+
],
4351
'function_to_constant' => ['functions' => ['get_called_class', 'get_class', 'get_class_this', 'php_sapi_name', 'phpversion', 'pi']],
44-
'function_typehint_space' => true,
52+
'type_declaration_spaces' => true,
53+
'global_namespace_import' => ['import_classes' => false, 'import_constants' => false, 'import_functions' => false],
4554
'header_comment' => [
4655
'header' => $headerComment,
4756
'comment_type' => 'comment',
57+
'location' => 'after_declare_strict',
4858
'separate' => 'both',
49-
'location' => 'after_declare_strict'
5059
],
51-
'lowercase_cast' => true,
52-
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
60+
'list_syntax' => ['syntax' => 'short'],
61+
// @todo: Can be dropped once we enable @PER-CS2.0
62+
'method_argument_space' => true,
5363
'modernize_strpos' => true,
5464
'modernize_types_casting' => true,
5565
'native_function_casing' => true,
56-
'new_with_braces' => true,
66+
'new_with_parentheses' => true,
5767
'no_alias_functions' => true,
5868
'no_blank_lines_after_phpdoc' => true,
5969
'no_empty_phpdoc' => true,
6070
'no_empty_statement' => true,
6171
'no_extra_blank_lines' => true,
62-
'no_leading_import_slash' => true,
6372
'no_leading_namespace_whitespace' => true,
73+
'no_multiple_statements_per_line' => true,
6474
'no_null_property_initialization' => true,
6575
'no_short_bool_cast' => true,
6676
'no_singleline_whitespace_before_semicolons' => true,
@@ -70,8 +80,7 @@
7080
'no_unused_imports' => true,
7181
'no_useless_else' => true,
7282
'no_useless_nullsafe_operator' => true,
73-
'no_whitespace_in_blank_line' => true,
74-
'ordered_imports' => true,
83+
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
7584
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
7685
'php_unit_mock_short_will_return' => true,
7786
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
@@ -84,8 +93,11 @@
8493
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
8594
'return_type_declaration' => ['space_before' => 'none'],
8695
'single_quote' => true,
96+
'single_space_around_construct' => true,
8797
'single_line_comment_style' => ['comment_types' => ['hash']],
88-
'single_trait_insert_per_statement' => true,
98+
// @todo: Can be dropped once we enable @PER-CS2.0
99+
'single_line_empty_body' => true,
100+
'statement_indentation' => true,
89101
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
90102
'whitespace_after_comma_in_array' => ['ensure_single_space' => true],
91103
'yoda_style' => ['equal' => false, 'identical' => false, 'less_and_greater' => false],

phpstan.neon

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
includes:
2+
- .Build/vendor/saschaegerer/phpstan-typo3/extension.neon
3+
4+
parameters:
5+
level: 9
6+
7+
paths:
8+
- %currentWorkingDirectory%/Classes

rector.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
7+
use Ssch\TYPO3Rector\Set\Typo3LevelSetList;
8+
use Ssch\TYPO3Rector\Set\Typo3SetList;
9+
10+
return RectorConfig::configure()
11+
->withPaths([
12+
__DIR__ . '/*',
13+
])
14+
->withSkipPath(
15+
__DIR__ . '/.Build',
16+
)
17+
->withPhpSets(php83: true)
18+
->withRules([
19+
TypedPropertyFromStrictConstructorRector::class
20+
])
21+
->withSets([
22+
Typo3SetList::CODE_QUALITY,
23+
Typo3SetList::GENERAL,
24+
Typo3LevelSetList::UP_TO_TYPO3_13,
25+
])
26+
// here we can define, what prepared sets of rules will be applied
27+
->withPreparedSets(
28+
deadCode: true,
29+
codeQuality: true
30+
)
31+
->withTypeCoverageLevel(8);

0 commit comments

Comments
 (0)