Skip to content

Commit b371b3d

Browse files
committed
Fix further psalm issues
1 parent 04fce65 commit b371b3d

File tree

5 files changed

+12
-23
lines changed

5 files changed

+12
-23
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ script:
4444
- vendor/bin/phpunit # Run tests
4545
- vendor/bin/phpcs # Stylecheck against MO4
4646
- vendor/bin/phpstan analyse --no-progress # Run PHPStan
47-
- vendor/bin/psalm --show-info=false # run psalm
47+
- vendor/bin/psalm --show-info=true # run psalm
4848
- if [ "${DEPENDENCIES}" = "highest" ]; then vendor/bin/phan; fi; # Run phan
4949
# Generate Code coverage report
5050
- |

MO4/Sniffs/Formatting/AlphabeticalUseStatementsSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class AlphabeticalUseStatementsSniff extends UseDeclarationSniff
7474
*
7575
* @var string
7676
*/
77-
private $currentFile;
77+
private $currentFile = '';
7878

7979
/**
8080
* Processes this test, when one of its tokens is encountered.

MO4/Sniffs/Strings/VariableInDoubleQuotedStringSniff.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@
3232
*/
3333
class VariableInDoubleQuotedStringSniff implements Sniff
3434
{
35-
/**
36-
* The PHP_CodeSniffer object controlling this run.
37-
*
38-
* @var File
39-
*/
40-
private $phpCsFile;
41-
4235
/**
4336
* Registers the tokens that this sniff wants to listen for.
4437
*
@@ -67,8 +60,6 @@ public function register(): array
6760
*/
6861
public function process(File $phpcsFile, $stackPtr): void
6962
{
70-
$this->phpCsFile = $phpcsFile;
71-
7263
$varRegExp = '/\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/';
7364

7465
$tokens = $phpcsFile->getTokens();
@@ -104,7 +95,7 @@ public function process(File $phpcsFile, $stackPtr): void
10495
}
10596
}
10697

107-
$fix = $this->phpCsFile->addFixableError(
98+
$fix = $phpcsFile->addFixableError(
10899
\sprintf(
109100
'must surround variable %s with { }',
110101
$var
@@ -122,7 +113,8 @@ public function process(File $phpcsFile, $stackPtr): void
122113
$pos,
123114
$var
124115
);
125-
$this->fixPhpCsFile($stackPtr, $correctVariable);
116+
117+
$this->fixPhpCsFile($stackPtr, $correctVariable, $phpcsFile);
126118
}
127119
}
128120
}
@@ -149,13 +141,12 @@ private function surroundVariableWithBraces(string $content, int $pos, string $v
149141
*
150142
* @param int $stackPtr stack pointer
151143
* @param string $correctVariable correct variable
144+
* @param File $phpCsFile PHP_CodeSniffer File object
152145
*
153146
* @return void
154147
*/
155-
private function fixPhpCsFile(int $stackPtr, string $correctVariable): void
148+
private function fixPhpCsFile(int $stackPtr, string $correctVariable, File $phpCsFile): void
156149
{
157-
$phpCsFile = $this->phpCsFile;
158-
159150
$phpCsFile->fixer->beginChangeset();
160151
$phpCsFile->fixer->replaceToken($stackPtr, $correctVariable);
161152
$phpCsFile->fixer->endChangeset();

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
"phpstan/phpstan": "^0.12.58",
2727
"phpstan/phpstan-strict-rules": "^0.12.4",
2828
"phpunit/phpunit": "^7.0",
29-
"vimeo/psalm": "^4.4"
29+
"psalm/plugin-phpunit": "^0.16.1",
30+
"vimeo/psalm": "^4.5.2"
3031
},
3132
"require": {
3233
"php": "~7.2 || ~8.0",

psalm.xml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
</ignoreFiles>
1616
</projectFiles>
1717

18-
<issueHandlers>
19-
<PropertyNotSetInConstructor errorLevel="info" />
20-
<MissingConstructor errorLevel="info" />
21-
22-
<UndefinedClass errorLevel="info" /> <!-- somehow this is showing up in travis -->
23-
</issueHandlers>
18+
<plugins>
19+
<pluginClass class="Psalm\PhpUnitPlugin\Plugin" />
20+
</plugins>
2421
</psalm>

0 commit comments

Comments
 (0)