Skip to content

Commit 8cf3c9a

Browse files
author
Bernhard Schmitt
committed
Properly run linter and static analyzer in CI
1 parent b28563f commit 8cf3c9a

11 files changed

Lines changed: 27 additions & 16 deletions

File tree

.github/workflows/qa.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ jobs:
1818

1919
- name: Run PHP Code Sniffer
2020
run: |
21-
phpcs \
22-
--standard=PSR12 \
23-
--extensions=php \
24-
--exclude=Generic.Files.LineLength \
25-
Classes/ Tests/
21+
composer lint
2622
2723
static-analysis:
2824
runs-on: ubuntu-20.04
@@ -53,7 +49,7 @@ jobs:
5349
5450
- name: Run phpstan
5551
run: |
56-
composer lint
52+
composer analyze
5753
5854
unit-tests:
5955
runs-on: ubuntu-20.04

Classes/Aspect/CompilingEvaluatorPreprocessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
final class CompilingEvaluatorPreprocessor
1919
{
2020
#[Flow\Before('method(Neos\Eel\CompilingEvaluator->evaluate())')]
21-
public function preprocessEvaluate(JoinPointInterface $joinPoint)
21+
public function preprocessEvaluate(JoinPointInterface $joinPoint): void
2222
{
2323
$context = $joinPoint->getMethodArgument('context');
2424
$joinPoint->setMethodArgument(

Classes/Domain/Component/PropType/UnionPropType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public function __construct(
2222
private readonly bool $nullable,
2323
PropTypeInterface ...$propTypes
2424
) {
25+
/** @var array<int,PropTypeInterface> $propTypes */
2526
$this->propTypes = $propTypes;
2627
}
2728

Classes/Domain/Enum/Enum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ private function getConstantName(string $value): string
7474

7575
private function camelCaseToUpperSnakeCase(string $value): string
7676
{
77-
return strtoupper(preg_replace('/(?<!^)[A-Z]/', '_$0', $value));
77+
return strtoupper(preg_replace('/(?<!^)[A-Z]/', '_$0', $value) ?: '');
7878
}
7979

8080
/**

Classes/Domain/Enum/EnumGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
final class EnumGenerator
2020
{
2121
public function __construct(
22-
private FileWriterInterface $fileWriter
22+
private readonly FileWriterInterface $fileWriter
2323
) {
2424
}
2525

Classes/Domain/Enum/EnumName.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,21 @@ public function getPhpNamespace(): string
4242
*/
4343
public function getPhpClassName(): string
4444
{
45-
return $this->componentName->getPhpNamespace() . '\\' . $this->name;
45+
/** @var class-string<mixed> $name */
46+
$name = $this->componentName->getPhpNamespace() . '\\' . $this->name;
47+
48+
return $name;
4649
}
4750

51+
/**
52+
* @return class-string<mixed>
53+
*/
4854
public function getProviderName(): string
4955
{
50-
return $this->name . 'Provider';
56+
/** @var class-string<mixed> $name */
57+
$name = $this->name . 'Provider';
58+
59+
return $name;
5160
}
5261

5362
public function getPhpFilePath(string $packagePath, bool $colocate): string

Classes/Infrastructure/UriService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function getPersistentResourceUri(PersistentResource $resource): ?Uri
8989
{
9090
$uri = $this->resourceManager->getPublicPersistentResourceUri($resource);
9191

92-
return $uri
92+
return is_string($uri)
9393
? new Uri($uri)
9494
: null;
9595
}

Classes/Presentation/Slot/Collection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ final class Collection implements SlotInterface
2222

2323
private function __construct(SlotInterface ...$items)
2424
{
25+
/** @var array<int,SlotInterface> $items */
2526
$this->items = $items;
2627
}
2728

28-
public static function fromSlots(SlotInterface ...$items)
29+
public static function fromSlots(SlotInterface ...$items): self
2930
{
3031
return new self(...$items);
3132
}

Tests/Unit/Domain/DummyFactoryRendererTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public function setUp(): void
6464

6565
public function testGetFactoryContent(): void
6666
{
67+
/** @var Component $object */
68+
$object = $this->component;
69+
6770
Assert::assertSame(
6871
'<?php
6972
@@ -81,7 +84,7 @@ final class MyNewComponentFactory extends AbstractComponentPresentationObjectFac
8184
{
8285
}
8386
',
84-
(new DummyFactoryRenderer())->renderFactoryContent($this->component)
87+
(new DummyFactoryRenderer())->renderFactoryContent($object)
8588
);
8689
}
8790
}

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
"sitegeist/monocle-presentationobjects": "For Monocle integration"
3030
},
3131
"scripts": {
32-
"lint": "bin/phpunit -c phpunit.xml --enforce-time-limit --coverage-html Build/Reports/coverage Tests",
32+
"lint": "bin/phpcs --standard=PSR12 --extensions=php --exclude=Generic.Files.LineLength Classes/ Tests/",
33+
"analyse": "bin/phpstan analyse --level 8 Tests/Unit Classes",
3334
"test": "bin/phpunit -c phpunit.xml --enforce-time-limit --coverage-html Build/Reports/coverage Tests"
3435
},
3536
"config": {

0 commit comments

Comments
 (0)