Skip to content

Commit 87e577f

Browse files
committed
Fix QA
1 parent 38546e6 commit 87e577f

File tree

10 files changed

+26
-23
lines changed

10 files changed

+26
-23
lines changed

.github/workflows/php-qa.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
- name: Check syntax error in sources
3636
run: find ./src/ ./tests/src/ ./tests/cases/ -type f -name '*.php' -print0 | xargs -0 -L 1 -P 4 -- php -l
3737

38+
- name: Remove Psalm before tests, to prevent installation conflicts
39+
run: composer.phar remove vimeo/psalm --no-update
40+
3841
- name: Install dependencies
3942
uses: "ramsey/composer-install@v1"
4043
with:

.psalm/autoloader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
$vendor = dirname(__DIR__) . '/vendor';
44
$phpcsSrc = "{$vendor}/squizlabs/php_codesniffer/src";
55

6+
require_once dirname(__DIR__) . '/Inpsyde/PhpcsHelpers.php';
67
require_once "{$phpcsSrc}/Sniffs/Sniff.php";
78
require_once "{$phpcsSrc}/Files/File.php";
89
require_once "{$phpcsSrc}/Fixer.php";

Inpsyde/PhpcsHelpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ public static function findNamespace(File $file, int $position): array
653653
*/
654654
public static function minPhpTestVersion(): string
655655
{
656-
$testVersion = trim((string)(Config::getConfigData('testVersion') ?: ''));
656+
$testVersion = trim(Config::getConfigData('testVersion') ?: '');
657657
if (!$testVersion) {
658658
return '';
659659
}

Inpsyde/Sniffs/CodeQuality/FunctionLengthSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function process(File $file, $position)
8181
'Your function is too long. Currently using %d lines%s, max is %d.',
8282
$length,
8383
$suffix,
84-
(int)$this->maxLength
84+
$this->maxLength
8585
);
8686

8787
$file->addError($error, $position, 'TooLong');

Inpsyde/Sniffs/CodeQuality/LineLengthSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private function isLongSingleWord(
265265
return false;
266266
}
267267

268-
$word = (string)reset($words);
268+
$word = reset($words);
269269
$firstNonWhitePos = $file->findNext(T_WHITESPACE, $position, $lineEnd, true);
270270
$firstNonWhite = ($firstNonWhitePos === false) ? null : $tokens[$firstNonWhitePos];
271271
$tolerance = is_array($firstNonWhite) ? ((int)($firstNonWhite['column'] ?? 1) + 3) : 4;

Inpsyde/Sniffs/CodeQuality/Psr4Sniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private function checkPsr4Folders(
166166
foreach ($folders as $folder) {
167167
$folder = trim(str_replace('\\', '/', $folder), './');
168168
$folderSplit = explode("/{$folder}/", $filePath);
169-
if (!$folderSplit || count($folderSplit) < 2) {
169+
if (count($folderSplit) < 2) {
170170
continue;
171171
}
172172

Inpsyde/Sniffs/CodeQuality/ReturnTypeDeclarationSniff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ private function returnTypeInfo(File $file, int $functionPosition): array
308308
/**
309309
* @param File $file
310310
* @param int $functionPosition
311-
* @return array{mixed:bool, null:bool}
311+
* @return array{'mixed': bool, 'null': bool}
312312
*/
313313
private function hasReturnNullOrMixedDocBloc(File $file, int $functionPosition): array
314314
{
@@ -317,12 +317,12 @@ private function hasReturnNullOrMixedDocBloc(File $file, int $functionPosition):
317317
return ['mixed' => false, 'null' => false];
318318
}
319319

320-
$returnContentParts = preg_split('~\s+~', (string)reset($return), PREG_SPLIT_NO_EMPTY);
320+
$returnContentParts = preg_split('~\s+~', reset($return), PREG_SPLIT_NO_EMPTY);
321321
if (!$returnContentParts) {
322322
return ['mixed' => false, 'null' => false];
323323
}
324324

325-
$returnTypes = array_map('strtolower', explode('|', (string)reset($returnContentParts)));
325+
$returnTypes = array_map('strtolower', explode('|', reset($returnContentParts)));
326326
$returnTypes = array_map('trim', $returnTypes);
327327
$returnTypesCount = count($returnTypes);
328328
// Only if 1 or 2 types

Inpsyde/Sniffs/CodeQuality/VariablesNameSniff.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ private function allIgnored(): array
199199
$this->ignoredNames = [];
200200
}
201201

202-
/** @var array $ignored */
203202
$ignored = $this->ignoredNames;
204203

205204
/** @var array<string> $normalized */

composer.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"require-dev": {
4040
"phpunit/phpunit": "6.5.* || 9.4.*",
41-
"vimeo/psalm": "^3"
41+
"vimeo/psalm": "@stable"
4242
},
4343
"autoload-dev": {
4444
"psr-4": {
@@ -54,8 +54,16 @@
5454
}
5555
},
5656
"scripts" : {
57-
"phpcompat": [
58-
"@php ./vendor/squizlabs/php_codesniffer/bin/phpcs -p . --standard=PHPCompatibility --ignore=*/vendor/*,*tests/fixtures/* --extensions=php --basepath=./ --runtime-set testVersion 7.0-"
57+
"cs": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs",
58+
"phpcompat": "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs -p . --standard=PHPCompatibility --ignore=*/vendor/*,*tests/fixtures/* --extensions=php --basepath=./ --runtime-set testVersion 7.0-",
59+
"tests": "@php ./vendor/phpunit/phpunit/phpunit",
60+
"tests:no-cov": "@php ./vendor/phpunit/phpunit/phpunit --no-coverage",
61+
"psalm": "@php ./vendor/vimeo/psalm/psalm --no-cache",
62+
"qa": [
63+
"@cs",
64+
"@phpcompat",
65+
"@tests:no-cov",
66+
"@psalm"
5967
]
6068
}
6169
}

psalm.xml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,21 @@
22
<psalm
33
autoloader="./.psalm/autoloader.php"
44
totallyTyped="true"
5-
useDocblockTypes="true"
65
useDocblockPropertyTypes="true"
76
usePhpDocMethodsWithoutMagicCall="true"
87
strictBinaryOperands="true"
9-
requireVoidReturnType="true"
10-
useAssertForType="true"
11-
rememberPropertyAssignmentsAfterCall="true"
128
allowPhpStormGenerics="true"
139
allowCoercionFromStringToClassConst="true"
14-
allowStringToStandInForClass="false"
15-
memoizeMethodCallResults="false"
16-
hoistConstants="false"
17-
addParamDefaultToDocblockType="false"
18-
checkForThrowsInGlobalScope="false"
1910
ignoreInternalFunctionFalseReturn="false"
2011
ignoreInternalFunctionNullReturn="false"
2112
hideExternalErrors="true"
22-
allowFileIncludes="true"
2313
allowNamedArgumentCalls="false"
14+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
15+
xmlns="https://getpsalm.org/schema/config"
16+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
2417
>
2518
<projectFiles>
26-
<directory name="Inpsyde/Sniffs"/>
27-
<file name="Inpsyde/PhpcsHelpers.php"/>
19+
<directory name="Inpsyde"/>
2820
<ignoreFiles>
2921
<directory name="vendor" />
3022
</ignoreFiles>

0 commit comments

Comments
 (0)