Skip to content

Commit 766ea5e

Browse files
committed
add psalm
1 parent 628336c commit 766ea5e

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ script:
3131
- vendor/bin/phpunit # Run tests
3232
- vendor/bin/phpcs # Stylecheck against PHPCS's ruleset
3333
- vendor/bin/phpstan analyse --no-progress # Run PHPStan
34+
- vendor/bin/psalm --show-info=false # run psalm
3435
- if [ "${DEPENDENCIES}" = "highest" ]; then vendor/bin/phan -i; fi; # Run phan
3536
- if [ "${TRAVIS_PHP_VERSION}" != "7.3" ]; then php -d zend_extension=xdebug.so vendor/bin/phpunit --coverage-clover=coverage.xml; fi; # Generate Code coverage report
3637

MO4/Sniffs/Arrays/ArrayDoubleArrowAlignmentSniff.php

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public function register(): array
6060
* the stack passed in $tokens.
6161
*
6262
* @return void
63+
*
64+
* @psalm-suppress LoopInvalidation
6365
*/
6466
public function process(File $phpcsFile, $stackPtr): void
6567
{

MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,17 @@ public function process(File $phpcsFile, $stackPtr): void
160160
$docCommentTags[$content]
161161
);
162162
// phpcs:enable
163+
163164
foreach ($docLineTokens as $docLineToken) {
165+
// phpcs:disable
166+
/** @var array<string> $typeTokens */
164167
$typeTokens = PregLibrary::mo4_preg_split(
165168
'/\|/',
166169
$docLineToken,
167170
-1,
168171
PREG_SPLIT_NO_EMPTY
169172
);
173+
// phpcs:enable
170174

171175
foreach ($typeTokens as $typeToken) {
172176
if (\in_array($typeToken, $useStatements, true) === true) {
@@ -348,7 +352,7 @@ private function checkShorthandPossible(
348352
$code = 'UnnecessaryNamespaceUsage';
349353
$fixable = false;
350354
$replaceClassName = false;
351-
$replacement = null;
355+
$replacement = '';
352356

353357
$fullClassName = $this->getFullyQualifiedClassName($className);
354358

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"phpstan/phpdoc-parser": "^0.4.1",
2727
"phpstan/phpstan": "^0.12.2",
2828
"phpstan/phpstan-strict-rules": "^0.12",
29-
"phpunit/phpunit": "^7.0"
29+
"phpunit/phpunit": "^7.0",
30+
"vimeo/psalm": "^3.8"
3031
},
3132
"require": {
3233
"php": "~7.1",

psalm.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0"?>
2+
<psalm
3+
totallyTyped="false"
4+
resolveFromConfigFile="true"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xmlns="https://getpsalm.org/schema/config"
7+
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
8+
autoloader="tests/bootstrap.php"
9+
>
10+
<projectFiles>
11+
<directory name="MO4" />
12+
<ignoreFiles>
13+
<directory name="vendor" />
14+
<directory name="integrationtests" />
15+
</ignoreFiles>
16+
</projectFiles>
17+
18+
<issueHandlers>
19+
<PropertyNotSetInConstructor errorLevel="info" />
20+
<MissingConstructor errorLevel="info" />
21+
22+
<UndefinedClass errorLevel="info" /> <!-- somehow this is showing up in travis -->
23+
</issueHandlers>
24+
</psalm>

0 commit comments

Comments
 (0)