Skip to content

Commit

Permalink
Properly run linter and static analyzer in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard Schmitt committed Nov 16, 2022
1 parent b28563f commit 8cf3c9a
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 16 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ jobs:

- name: Run PHP Code Sniffer
run: |
phpcs \
--standard=PSR12 \
--extensions=php \
--exclude=Generic.Files.LineLength \
Classes/ Tests/
composer lint
static-analysis:
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -53,7 +49,7 @@ jobs:
- name: Run phpstan
run: |
composer lint
composer analyze
unit-tests:
runs-on: ubuntu-20.04
Expand Down
2 changes: 1 addition & 1 deletion Classes/Aspect/CompilingEvaluatorPreprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
final class CompilingEvaluatorPreprocessor
{
#[Flow\Before('method(Neos\Eel\CompilingEvaluator->evaluate())')]
public function preprocessEvaluate(JoinPointInterface $joinPoint)
public function preprocessEvaluate(JoinPointInterface $joinPoint): void
{
$context = $joinPoint->getMethodArgument('context');
$joinPoint->setMethodArgument(
Expand Down
1 change: 1 addition & 0 deletions Classes/Domain/Component/PropType/UnionPropType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct(
private readonly bool $nullable,
PropTypeInterface ...$propTypes
) {
/** @var array<int,PropTypeInterface> $propTypes */
$this->propTypes = $propTypes;
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Enum/Enum.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private function getConstantName(string $value): string

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

/**
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Enum/EnumGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
final class EnumGenerator
{
public function __construct(
private FileWriterInterface $fileWriter
private readonly FileWriterInterface $fileWriter
) {
}

Expand Down
13 changes: 11 additions & 2 deletions Classes/Domain/Enum/EnumName.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,21 @@ public function getPhpNamespace(): string
*/
public function getPhpClassName(): string
{
return $this->componentName->getPhpNamespace() . '\\' . $this->name;
/** @var class-string<mixed> $name */
$name = $this->componentName->getPhpNamespace() . '\\' . $this->name;

return $name;
}

/**
* @return class-string<mixed>
*/
public function getProviderName(): string
{
return $this->name . 'Provider';
/** @var class-string<mixed> $name */
$name = $this->name . 'Provider';

return $name;
}

public function getPhpFilePath(string $packagePath, bool $colocate): string
Expand Down
2 changes: 1 addition & 1 deletion Classes/Infrastructure/UriService.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getPersistentResourceUri(PersistentResource $resource): ?Uri
{
$uri = $this->resourceManager->getPublicPersistentResourceUri($resource);

return $uri
return is_string($uri)
? new Uri($uri)
: null;
}
Expand Down
3 changes: 2 additions & 1 deletion Classes/Presentation/Slot/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ final class Collection implements SlotInterface

private function __construct(SlotInterface ...$items)
{
/** @var array<int,SlotInterface> $items */
$this->items = $items;
}

public static function fromSlots(SlotInterface ...$items)
public static function fromSlots(SlotInterface ...$items): self
{
return new self(...$items);
}
Expand Down
5 changes: 4 additions & 1 deletion Tests/Unit/Domain/DummyFactoryRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public function setUp(): void

public function testGetFactoryContent(): void
{
/** @var Component $object */
$object = $this->component;

Assert::assertSame(
'<?php
Expand All @@ -81,7 +84,7 @@ final class MyNewComponentFactory extends AbstractComponentPresentationObjectFac
{
}
',
(new DummyFactoryRenderer())->renderFactoryContent($this->component)
(new DummyFactoryRenderer())->renderFactoryContent($object)
);
}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"sitegeist/monocle-presentationobjects": "For Monocle integration"
},
"scripts": {
"lint": "bin/phpunit -c phpunit.xml --enforce-time-limit --coverage-html Build/Reports/coverage Tests",
"lint": "bin/phpcs --standard=PSR12 --extensions=php --exclude=Generic.Files.LineLength Classes/ Tests/",
"analyse": "bin/phpstan analyse --level 8 Tests/Unit Classes",
"test": "bin/phpunit -c phpunit.xml --enforce-time-limit --coverage-html Build/Reports/coverage Tests"
},
"config": {
Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ parameters:
- Packages/Framework/Neos.Flow/Tests/UnitTestCase.php
- Packages/Framework/Neos.Flow/Tests/FunctionalTestCase.php
- Tests/Unit/Fixtures/Site/Presentation/Component/MyReflectionComponent/MyReflectionComponent.php
- Tests/Unit/Fixtures/Site/Presentation/Component/MyNewComponent/MyStringPseudoEnum.php
- Tests/Unit/Fixtures/Site/Presentation/Component/MyNewComponent/MyStringEnum.php
- phpstan.bootstrap.php
excludes_analyse:
- Tests/Unit/Helper/*
Expand Down

0 comments on commit 8cf3c9a

Please sign in to comment.