Skip to content

Commit cbf1853

Browse files
committed
Implement entry management with CRUD operations and form handling
1 parent d73afba commit cbf1853

38 files changed

+1757
-3508
lines changed

.ci-tools/deptrac.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
deptrac:
2+
paths:
3+
- ./../src
4+
layers:
5+
- name: 'application'
6+
collectors:
7+
- type: 'directory'
8+
value: 'src/.*'
9+
- name: 'vendors'
10+
collectors:
11+
- { type: classLike, value: '^League\\' }
12+
- { type: classLike, value: '^Doctrine\\' }
13+
- { type: classLike, value: '^Symfony\\' }
14+
- { type: classLike, value: '^Twig\\' }
15+
ruleset:
16+
application:
17+
- 'vendors'

.ci-tools/ecs.php

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer;
6+
use PhpCsFixer\Fixer\ClassNotation\ProtectedToPrivateFixer;
7+
use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
8+
use PhpCsFixer\Fixer\ConstantNotation\NativeConstantInvocationFixer;
9+
use PhpCsFixer\Fixer\ControlStructure\NoSuperfluousElseifFixer;
10+
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
11+
use PhpCsFixer\Fixer\Import\GlobalNamespaceImportFixer;
12+
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
13+
use PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveIssetsFixer;
14+
use PhpCsFixer\Fixer\LanguageConstruct\CombineConsecutiveUnsetsFixer;
15+
use PhpCsFixer\Fixer\Phpdoc\AlignMultilineCommentFixer;
16+
use PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer;
17+
use PhpCsFixer\Fixer\Phpdoc\PhpdocOrderFixer;
18+
use PhpCsFixer\Fixer\Phpdoc\PhpdocTrimConsecutiveBlankLineSeparationFixer;
19+
use PhpCsFixer\Fixer\PhpTag\LinebreakAfterOpeningTagFixer;
20+
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
21+
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestCaseStaticMethodCallsFixer;
22+
use PhpCsFixer\Fixer\PhpUnit\PhpUnitTestClassRequiresCoversFixer;
23+
use PhpCsFixer\Fixer\ReturnNotation\SimplifiedNullReturnFixer;
24+
use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer;
25+
use PhpCsFixer\Fixer\Strict\StrictComparisonFixer;
26+
use PhpCsFixer\Fixer\Strict\StrictParamFixer;
27+
use PhpCsFixer\Fixer\Whitespace\ArrayIndentationFixer;
28+
use PhpCsFixer\Fixer\Whitespace\MethodChainingIndentationFixer;
29+
use Symplify\CodingStandard\Fixer\Spacing\MethodChainingNewlineFixer;
30+
use Symplify\EasyCodingStandard\Config\ECSConfig;
31+
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
32+
33+
return static function (ECSConfig $config): void {
34+
$header = '';
35+
$config->import(SetList::PSR_12);
36+
$config->import(SetList::CLEAN_CODE);
37+
$config->import(SetList::DOCTRINE_ANNOTATIONS);
38+
$config->import(SetList::SPACES);
39+
$config->import(SetList::PHPUNIT);
40+
$config->import(SetList::SYMPLIFY);
41+
$config->import(SetList::ARRAY);
42+
$config->import(SetList::COMMON);
43+
$config->import(SetList::COMMENTS);
44+
$config->import(SetList::CONTROL_STRUCTURES);
45+
$config->import(SetList::DOCBLOCK);
46+
$config->import(SetList::NAMESPACES);
47+
$config->import(SetList::STRICT);
48+
49+
$config->rule(StrictParamFixer::class);
50+
$config->rule(StrictComparisonFixer::class);
51+
$config->rule(ArrayIndentationFixer::class);
52+
$config->rule(OrderedImportsFixer::class);
53+
$config->rule(ProtectedToPrivateFixer::class);
54+
$config->rule(DeclareStrictTypesFixer::class);
55+
$config->rule(NativeConstantInvocationFixer::class);
56+
$config->rule(LinebreakAfterOpeningTagFixer::class);
57+
$config->rule(CombineConsecutiveIssetsFixer::class);
58+
$config->rule(CombineConsecutiveUnsetsFixer::class);
59+
$config->rule(NoSuperfluousElseifFixer::class);
60+
$config->rule(NoSuperfluousPhpdocTagsFixer::class);
61+
$config->rule(PhpdocTrimConsecutiveBlankLineSeparationFixer::class);
62+
$config->rule(PhpdocOrderFixer::class);
63+
$config->rule(SimplifiedNullReturnFixer::class);
64+
$config->rule(PhpUnitTestCaseStaticMethodCallsFixer::class);
65+
$config->ruleWithConfiguration(ArraySyntaxFixer::class, [
66+
'syntax' => 'short',
67+
]);
68+
$config->ruleWithConfiguration(NativeFunctionInvocationFixer::class, [
69+
'include' => ['@compiler_optimized'],
70+
'scope' => 'namespaced',
71+
'strict' => true,
72+
]);
73+
$config->ruleWithConfiguration(HeaderCommentFixer::class, [
74+
'header' => $header,
75+
]);
76+
$config->ruleWithConfiguration(AlignMultilineCommentFixer::class, [
77+
'comment_type' => 'all_multiline',
78+
]);
79+
$config->ruleWithConfiguration(PhpUnitTestAnnotationFixer::class, [
80+
'style' => 'annotation',
81+
]);
82+
$config->ruleWithConfiguration(GlobalNamespaceImportFixer::class, [
83+
'import_classes' => true,
84+
'import_constants' => true,
85+
'import_functions' => true,
86+
]);
87+
88+
$config->skip([
89+
PhpUnitTestClassRequiresCoversFixer::class,
90+
MethodChainingIndentationFixer::class => [__DIR__ . '/src/Resources/config'],
91+
MethodChainingNewlineFixer::class => [__DIR__ . '/src/Resources/config'],
92+
]);
93+
94+
$config->parallel();
95+
$config->paths([
96+
__DIR__ . '/../src',
97+
__DIR__ . '/../tests',
98+
__DIR__ . '/../castor.php',
99+
__DIR__ . '/ecs.php',
100+
__DIR__ . '/rector.php',
101+
]);
102+
};

.ci-tools/infection.json.dist

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"source": {
3+
"directories": ["src"],
4+
"excludes": [
5+
"src/Kernel.php",
6+
"src/DependencyInjection",
7+
"src/Event",
8+
"src/Twig"
9+
]
10+
},
11+
"logs": {
12+
"text": "infection.log"
13+
},
14+
"mutators": {
15+
"@default": true,
16+
17+
"MBString": {
18+
"settings": {
19+
"mb_substr": false,
20+
"mb_strlen": false
21+
}
22+
},
23+
24+
"PublicVisibility": false,
25+
"For_": false
26+
},
27+
"timeout": 10
28+
}

.ci-tools/phpstan-baseline.neon

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Class "App\\Controller\\EntryController" is not allowed to extend "Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController"\.$#'
5+
identifier: ergebnis.noExtends
6+
count: 1
7+
path: ../src/Controller/EntryController.php
8+
9+
-
10+
message: '#^Class "App\\Controller\\HomepageController" is not allowed to extend "Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController"\.$#'
11+
identifier: ergebnis.noExtends
12+
count: 1
13+
path: ../src/Controller/HomepageController.php
14+
15+
-
16+
message: '#^Method App\\Entity\\Entry\:\:__construct\(\) has parameter \$filePath with a nullable type declaration\.$#'
17+
identifier: ergebnis.noParameterWithNullableTypeDeclaration
18+
count: 1
19+
path: ../src/Entity/Entry.php
20+
21+
-
22+
message: '#^Method App\\Entity\\Entry\:\:__construct\(\) has parameter \$mimeType with a nullable type declaration\.$#'
23+
identifier: ergebnis.noParameterWithNullableTypeDeclaration
24+
count: 1
25+
path: ../src/Entity/Entry.php
26+
27+
-
28+
message: '#^Method App\\Entity\\Entry\:\:__construct\(\) has parameter \$textContent with a nullable type declaration\.$#'
29+
identifier: ergebnis.noParameterWithNullableTypeDeclaration
30+
count: 1
31+
path: ../src/Entity/Entry.php
32+
33+
-
34+
message: '#^Method App\\Entity\\Entry\:\:__construct\(\) has parameter \$url with a nullable type declaration\.$#'
35+
identifier: ergebnis.noParameterWithNullableTypeDeclaration
36+
count: 1
37+
path: ../src/Entity/Entry.php
38+
39+
-
40+
message: '#^Method App\\Entity\\Entry\:\:createFile\(\) has parameter \$mimeType with a nullable type declaration\.$#'
41+
identifier: ergebnis.noParameterWithNullableTypeDeclaration
42+
count: 1
43+
path: ../src/Entity/Entry.php
44+
45+
-
46+
message: '#^Cannot call method getMimeType\(\) on Symfony\\Component\\HttpFoundation\\File\\File\|null\.$#'
47+
identifier: method.nonObject
48+
count: 1
49+
path: ../src/Form/EntryFormHandler.php
50+
51+
-
52+
message: '#^Cannot call method getPathname\(\) on Symfony\\Component\\HttpFoundation\\File\\File\|null\.$#'
53+
identifier: method.nonObject
54+
count: 1
55+
path: ../src/Form/EntryFormHandler.php
56+
57+
-
58+
message: '#^Cannot call method guessExtension\(\) on Symfony\\Component\\HttpFoundation\\File\\File\|null\.$#'
59+
identifier: method.nonObject
60+
count: 1
61+
path: ../src/Form/EntryFormHandler.php
62+
63+
-
64+
message: '#^Method App\\Form\\EntryFormHandler\:\:create\(\) should return Symfony\\Component\\Form\\FormInterface\<App\\Form\\EntryType\> but returns Symfony\\Component\\Form\\FormInterface\<App\\Form\\EntryData\|null\>\.$#'
65+
identifier: return.type
66+
count: 1
67+
path: ../src/Form/EntryFormHandler.php
68+
69+
-
70+
message: '#^Method App\\Form\\EntryFormHandler\:\:handle\(\) has a nullable return type declaration\.$#'
71+
identifier: ergebnis.noNullableReturnTypeDeclaration
72+
count: 1
73+
path: ../src/Form/EntryFormHandler.php
74+
75+
-
76+
message: '#^PHPDoc tag @var with type App\\Form\\EntryData is not subtype of type App\\Form\\EntryType\.$#'
77+
identifier: varTag.type
78+
count: 1
79+
path: ../src/Form/EntryFormHandler.php
80+
81+
-
82+
message: '#^Parameter \#2 \$contents of method League\\Flysystem\\FilesystemWriter\:\:write\(\) expects string, string\|false given\.$#'
83+
identifier: argument.type
84+
count: 1
85+
path: ../src/Form/EntryFormHandler.php
86+
87+
-
88+
message: '#^Parameter \#4 \$textContent of static method App\\Entity\\Entry\:\:createText\(\) expects string, string\|null given\.$#'
89+
identifier: argument.type
90+
count: 1
91+
path: ../src/Form/EntryFormHandler.php
92+
93+
-
94+
message: '#^Parameter \#4 \$url of static method App\\Entity\\Entry\:\:createUrl\(\) expects string, string\|null given\.$#'
95+
identifier: argument.type
96+
count: 1
97+
path: ../src/Form/EntryFormHandler.php
98+
99+
-
100+
message: '#^Cannot access property \$value on mixed\.$#'
101+
identifier: property.nonObject
102+
count: 1
103+
path: ../src/Form/EntryType.php
104+
105+
-
106+
message: '#^Class "App\\Form\\EntryType" is not allowed to extend "Symfony\\Component\\Form\\AbstractType"\.$#'
107+
identifier: ergebnis.noExtends
108+
count: 1
109+
path: ../src/Form/EntryType.php
110+
111+
-
112+
message: '#^Parameter \#2 \.\.\.\$values of function sprintf expects bool\|float\|int\|string\|null, mixed given\.$#'
113+
identifier: argument.type
114+
count: 1
115+
path: ../src/Form/EntryType.php
116+
117+
-
118+
message: '#^Class "App\\Kernel" is not allowed to extend "Symfony\\Component\\HttpKernel\\Kernel"\.$#'
119+
identifier: ergebnis.noExtends
120+
count: 1
121+
path: ../src/Kernel.php
122+
123+
-
124+
message: '#^Class "App\\Repository\\EntryRepository" is not allowed to extend "Doctrine\\Bundle\\DoctrineBundle\\Repository\\ServiceEntityRepository"\.$#'
125+
identifier: ergebnis.noExtends
126+
count: 1
127+
path: ../src/Repository/EntryRepository.php
128+
129+
-
130+
message: '#^Method App\\Repository\\EntryRepository\:\:getPaginatedEntries\(\) should return Doctrine\\ORM\\Tools\\Pagination\\Paginator\<App\\Entity\\Entry\> but returns Doctrine\\ORM\\Tools\\Pagination\\Paginator\<mixed\>\.$#'
131+
identifier: return.type
132+
count: 1
133+
path: ../src/Repository/EntryRepository.php

.ci-tools/phpstan.neon

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
parameters:
2+
level: max
3+
scanDirectories:
4+
- %rootDir%/../../../../phpunit/vendor
5+
- %currentWorkingDirectory%/vendor
6+
paths:
7+
- %currentWorkingDirectory%/src
8+
banned_code:
9+
non_ignorable: false
10+
checkUninitializedProperties: true
11+
treatPhpDocTypesAsCertain: false
12+
13+
includes:
14+
- %currentWorkingDirectory%/.ci-tools/phpstan-baseline.neon
15+
- %rootDir%/conf/bleedingEdge.neon
16+
- %rootDir%/../../ekino/phpstan-banned-code/extension.neon
17+
- %rootDir%/../phpstan-beberlei-assert/extension.neon
18+
- %rootDir%/../phpstan-deprecation-rules/rules.neon
19+
- %rootDir%/../phpstan-doctrine/extension.neon
20+
- %rootDir%/../../ergebnis/phpstan-rules/rules.neon
21+
- %rootDir%/../phpstan-phpunit/extension.neon
22+
- %rootDir%/../phpstan-strict-rules/rules.neon
23+
- %rootDir%/../phpstan-symfony/extension.neon

.ci-tools/phpunit.xml.dist

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
bootstrap="../tests/bootstrap.php"
5+
colors="true"
6+
xsi:noNamespaceSchemaLocation="phpunit.xsd"
7+
cacheDirectory=".phpunit.cache"
8+
>
9+
<coverage/>
10+
<testsuites>
11+
<testsuite name="Test Suite">
12+
<directory>./../tests</directory>
13+
</testsuite>
14+
</testsuites>
15+
<php>
16+
<ini name="display_errors" value="1" />
17+
<ini name="error_reporting" value="-1" />
18+
<server name="APP_ENV" value="test" force="true" />
19+
<server name="SHELL_VERBOSITY" value="-1" />
20+
</php>
21+
<source>
22+
<include>
23+
<directory>./../src</directory>
24+
</include>
25+
<exclude>
26+
<directory>./../vendor</directory>
27+
<directory>./../tests</directory>
28+
</exclude>
29+
</source>
30+
<extensions>
31+
<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension"/>
32+
</extensions>
33+
</phpunit>

0 commit comments

Comments
 (0)