Skip to content

Commit

Permalink
[TASK] Add static analysis with phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
s2b committed Aug 21, 2020
1 parent 10cb67e commit 13899f0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"editorconfig-checker/editorconfig-checker": "^10.0",
"squizlabs/php_codesniffer": "^3.0",
"phpunit/phpunit": "^9.2",
"symfony/var-dumper": "^5.1"
"symfony/var-dumper": "^5.1",
"phpstan/phpstan": "^0.12.38"
},
"autoload": {
"psr-4": {
Expand All @@ -35,9 +36,11 @@
"scripts": {
"lint": [
"@lint:php",
"@analyse:php",
"@lint:editorconfig"
],
"lint:php": "phpcs --standard=PSR2 --extensions=php --exclude=Generic.Files.LineLength --ignore='vendor' .",
"analyse:php": "phpstan analyse --no-progress --level 1 src/ tests/",
"lint:editorconfig": "ec .",
"test": "phpunit tests/"
}
Expand Down
1 change: 1 addition & 0 deletions src/Classes/CodeQuality/Check/ParamNamingCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function check(): array
protected function extractParamNamesAndTypes(): array
{
return array_reduce($this->component->paramNodes, function (array $carry, ViewHelperNode $node) {
/** @var \TYPO3Fluid\Fluid\Core\Parser\SyntaxTree\TextNode */
$arguments = $node->getArguments();
$carry[(string) $arguments['name']] = (string) $arguments['type'];
return $carry;
Expand Down
4 changes: 3 additions & 1 deletion src/Classes/CodeQuality/Check/ViewHelpersCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ protected function extractUsedViewHelpers(): array
return $node->getUninitializedViewHelper() instanceof IntrospectionViewHelper;
});
return array_map(function (ViewHelperNode $node) {
return $node->getUninitializedViewHelper()->getViewhelperTagName();
/** @var IntrospectionViewHelper */
$introspectionViewHelper = $node->getUninitializedViewHelper();
return $introspectionViewHelper->getViewhelperTagName();
}, $introspectedViewHelpers);
}
}
1 change: 1 addition & 0 deletions src/Classes/CodeQuality/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Component
public $path;

public $rootNode;
public $fluidService;

public $componentNode;
public $paramNodes = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/Service/ComponentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function scanForComponents(string $path, string $ext): array
// Continue recursively
$components = array_merge(
$components,
$this->scanForComponents($componentPath, $ext, $this->scannedPaths)
$this->scanForComponents($componentPath, $ext)
);
}

Expand Down

0 comments on commit 13899f0

Please sign in to comment.