Skip to content

Commit

Permalink
feat: switch to php-cs-fixer (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
sitepark-veltrup authored Jul 2, 2024
1 parent 35e7622 commit c4af36b
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 46 deletions.
1 change: 1 addition & 0 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<phar name="composer-normalize" version="^2.32.0" location="./tools/composer-normalize" copy="false" installed="2.32.0"/>
<phar name="phpunit" version="^10.4.0" location="./tools/phpunit.phar" copy="true" installed="10.4.1"/>
<phar name="overtrue/phplint" version="^9.0.4" location="./tools/phplint" copy="false" installed="9.0.4"/>
<phar name="php-cs-fixer" version="^3.58.1" installed="3.58.1" copy="false" location="./tools/php-cs-fixer"/>
</phive>
12 changes: 12 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

$finder = (new \PhpCsFixer\Finder())
->in(__DIR__ . '/src')
->in(__DIR__ . '/test');

return (new \PhpCsFixer\Config())
->setCacheFile('var/cache/php-cs-fixer')
->setFinder($finder)
->setRules(['@PER-CS' => true]);
8 changes: 3 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,24 @@
}
},
"scripts": {
"post-install-cmd": "phive --no-progress install --force-accept-unsigned --trust-gpg-keys C00543248C87FB13,4AA394086372C20A,CF1A108D0E7AE720,51C67305FFC2E5C0",
"post-install-cmd": "phive --no-progress install --force-accept-unsigned --trust-gpg-keys C00543248C87FB13,4AA394086372C20A,CF1A108D0E7AE720,51C67305FFC2E5C0,E82B2FB314E9906E",
"analyse": [
"@analyse:phplint",
"@analyse:phpstan",
"@analyse:phpcs",
"@analyse:phpcsfixer",
"@analyse:compatibilitycheck"
],
"analyse:compatibilitycheck": "./vendor/bin/phpcs --standard=./phpcs.compatibilitycheck.xml",
"analyse:phpcs": "./vendor/bin/phpcs",
"analyse:phpcsfixer": "./tools/php-cs-fixer check --diff --show-progress=dots",
"analyse:phplint": "./tools/phplint",
"analyse:phpstan": "./tools/phpstan analyse",
"cs-fix": [
"@cs-fix:phpcbf"
],
"cs-fix:phpcbf": "./vendor/bin/phpcbf",
"report": [
"@report:phpcs",
"@report:phpstan"
],
"report:phpcs": "./vendor/bin/phpcs || exit 0",
"report:phpstan": "./tools/phpstan analyse --no-progress --no-ansi --no-interaction --error-format=checkstyle > ./var/log/phpstan-report.xml || exit 0",
"test": [
"@test:phpunit"
Expand Down
25 changes: 0 additions & 25 deletions phpcs.xml.dist

This file was deleted.

4 changes: 2 additions & 2 deletions src/AtooloCityCallBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function build(ContainerBuilder $container): void
new LoaderResolver(
[
new YamlFileLoader($container, new FileLocator($configDir)),
]
)
],
),
);

$loader->load('services.yaml');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@
*/
class NewsDocumentEnricher implements DocumentEnricher
{
public function cleanup(): void
{
}
public function cleanup(): void {}

/**
* @throws DocumentEnrichingException
*/
public function enrichDocument(
Resource $resource,
IndexDocument $doc,
string $processId
string $processId,
): IndexSchema2xDocument {

if ($resource->objectType !== 'citycall-news') {
Expand All @@ -42,11 +40,11 @@ public function enrichDocument(
*/
private function enrichDocumentForNews(
Resource $resource,
IndexDocument $doc
IndexDocument $doc,
): IndexDocument {

$isAdHocActive = $resource->data->getBool(
'metadata.isAdHocActive'
'metadata.isAdHocActive',
);
if ($isAdHocActive) {
$doc->setMetaBool('citycall_isadhoc', true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ public function testIsAdHocActive(): void
$doc = $this->enrichDocument([
'objectType' => 'citycall-news',
'metadata' => [
'isAdHocActive' => true
]
'isAdHocActive' => true,
],
]);

/** @var array{sp_meta_string_leikanumber: bool} $fields */
$fields = $doc->getFields();

$this->assertTrue(
$fields['sp_meta_bool_citycall_isadhoc'],
'unexpected isadhoc'
'unexpected isadhoc',
);
}

Expand All @@ -38,16 +38,16 @@ public function testWithNonNewsObjectType(): void
$doc = $this->enrichDocument([
'objectType' => 'otherType',
'metadata' => [
'isAdHocActive' => true
]
'isAdHocActive' => true,
],
]);

/** @var array{sp_meta_string_leikanumber: bool} $fields */
$fields = $doc->getFields();

$this->assertEmpty(
$fields,
'document should be empty'
'document should be empty',
);
}

Expand All @@ -59,7 +59,7 @@ public function testCleanup(): void
}

private function enrichDocument(
array $data
array $data,
): IndexSchema2xDocument {
$enricher = new NewsDocumentEnricher();
$doc = new IndexSchema2xDocument();
Expand Down
2 changes: 1 addition & 1 deletion test/TestResourceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static function create(array $data): Resource
$data['name'] ?? '',
$data['objectType'] ?? '',
ResourceLanguage::of($data['locale'] ?? ''),
new DataBag($data)
new DataBag($data),
);
}
}

0 comments on commit c4af36b

Please sign in to comment.