Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ jobs:
- name: Run PHPStan
run: vendor/bin/phpstan analyse

- name: Run Psalm
run: vendor/bin/psalm --no-cache

- name: Run Rector
run: vendor/bin/rector process --ansi --dry-run --config rector.php Kununu/ tests/

Expand Down
2 changes: 1 addition & 1 deletion Kununu/ArchitectureSniffer/ArchitectureSniffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testArchitecture(): iterable
$architecture,
static fn(array $group) => !array_filter(
is_array($group[Group::INCLUDES_KEY] ?? null) ? $group[Group::INCLUDES_KEY] : [],
static fn($include) => str_starts_with((string) $include, 'App\\')
static fn(mixed $include): bool => str_starts_with((string) $include, 'App\\')
)
);

Expand Down
8 changes: 1 addition & 7 deletions Kununu/ArchitectureSniffer/Helper/TypeChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ public static function isArrayKeysOfStrings(mixed $arr): bool
return false;
}

foreach (array_keys($arr) as $key) {
if (!is_string($key)) {
return false;
}
}

return true;
return array_all(array_keys($arr), static fn($key) => is_string($key));
}

public static function isArrayOfStrings(mixed $arr): bool
Expand Down
2 changes: 1 addition & 1 deletion Kununu/CsFixer/Command/CsFixerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return self::FAILURE;
}

$configSource = $input->getOption(self::OPTION_CONFIG) ?: __DIR__ . '/../../../php-cs-fixer.php';
$configSource = $input->getOption(self::OPTION_CONFIG) ?? __DIR__ . '/../../../php-cs-fixer.php';
$configPath = realpath($configSource);

if ($configPath === false || !is_file($configPath)) {
Expand Down
4 changes: 3 additions & 1 deletion Kununu/CsFixer/Command/CsFixerGitHookCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ private function resolveVendorDir(string $rootGitPath): string

foreach ($candidates as $candidate) {
if (is_dir($candidate)) {
return realpath($candidate) ?: $candidate;
$resolved = realpath($candidate);

return $resolved !== false ? $resolved : $candidate;
}
}

Expand Down
8 changes: 6 additions & 2 deletions Kununu/CsFixer/CsFixerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

final class CsFixerPlugin implements PluginInterface, EventSubscriberInterface, Capable
{
private Composer $composer;
private IOInterface $io;
private ?Composer $composer = null;
private ?IOInterface $io = null;

public static function getSubscribedEvents(): array
{
Expand Down Expand Up @@ -54,6 +54,10 @@ public function getCapabilities(): array
/** @throws ExceptionInterface */
public function addCsFixerGitHooks(): void
{
if ($this->composer === null || $this->io === null) {
return;
}

$command = new CsFixerGitHookCommand();
$command->setComposer($this->composer);
$command->setIO($this->io);
Expand Down
5 changes: 5 additions & 0 deletions bin/code-tools
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fi
readonly CONFIG_FILES=(
"dist/php-cs-fixer.php.dist"
"dist/phpcs.xml.dist"
"dist/psalm.xml.dist"
"dist/rector.php.dist"
"dist/.editorconfig.dist"
)
Expand All @@ -32,6 +33,7 @@ Usage: vendor/bin/code-tools publish:config [tool-name]
Valid tool names:
cs-fixer => copies dist/php-cs-fixer.php.dist
code-sniffer => copies dist/phpcs.xml.dist
psalm => copies dist/psalm.xml.dist
rector => copies dist/rector.php.dist
editorconfig => copies dist/.editorconfig.dist
EOF
Expand Down Expand Up @@ -79,6 +81,9 @@ case "$tool_name" in
code-sniffer)
copy_config_file "dist/phpcs.xml.dist"
;;
psalm)
copy_config_file "dist/psalm.xml.dist"
;;
rector)
copy_config_file "dist/rector.php.dist"
;;
Expand Down
2 changes: 2 additions & 0 deletions composer-dependency-analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
[
'friendsofphp/php-cs-fixer',
'phpstan/phpstan',
'psalm/plugin-symfony',
'rector/rector',
'squizlabs/php_codesniffer',
'vimeo/psalm',
],
[ErrorType::UNUSED_DEPENDENCY]
);
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
"friendsofphp/php-cs-fixer": "^3.93",
"phpat/phpat": "^0.11.4",
"phpstan/phpstan": "^2.1",
"psalm/plugin-symfony": "^5.3",
"rector/rector": "^2.0",
"squizlabs/php_codesniffer": "^3.10",
"symfony/console": "^6.4 || ^7.4",
"symfony/process": "^6.4 || ^7.4",
"symfony/yaml": "^6.4 || ^7.4"
"symfony/yaml": "^6.4 || ^7.4",
"vimeo/psalm": "^6.16"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.50",
Expand Down Expand Up @@ -57,12 +59,15 @@
"@cs-check",
"@stan",
"@rector",
"@psalm",
"@test-unit"
],
"cs-check": "phpcs --standard=phpcs.xml Kununu/ tests/",
"cs-fix": "phpcbf --standard=phpcs.xml Kununu/ tests/",
"cs-fixer-check": "php-cs-fixer check --config=php-cs-fixer.php",
"cs-fixer-fix": "php-cs-fixer fix --config=php-cs-fixer.php",
"psalm": "psalm --no-cache",
"psalm-baseline": "psalm --no-cache --set-baseline=psalm-baseline.xml",
"rector": "rector process --dry-run Kununu/ tests/",
"rector-fix": "rector process Kununu/ tests/",
"stan": "phpstan analyze",
Expand Down
20 changes: 20 additions & 0 deletions dist/psalm.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<psalm
errorLevel="2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedCode="false"
ensureOverrideAttribute="false"
>
<projectFiles>
<directory name="src"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>

<plugins>
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
</plugins>
</psalm>
34 changes: 34 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>
<psalm
errorLevel="2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
findUnusedCode="false"
ensureOverrideAttribute="false"
>
<projectFiles>
<directory name="Kununu"/>
<ignoreFiles>
<directory name="vendor"/>
</ignoreFiles>
</projectFiles>

<stubs>
<file name="vendor/squizlabs/php_codesniffer/src/Sniffs/Sniff.php"/>
<file name="vendor/squizlabs/php_codesniffer/src/Files/File.php"/>
<file name="vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php"/>
</stubs>

<plugins>
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
</plugins>

<issueHandlers>
<ClassMustBeFinal>
<errorLevel type="suppress">
<directory name="Kununu/Sniffs"/>
</errorLevel>
</ClassMustBeFinal>
</issueHandlers>
</psalm>
Loading