Skip to content

Commit

Permalink
Drop Psalm (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored Jan 15, 2025
1 parent 3e29e44 commit 3d17f1e
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 108 deletions.
27 changes: 1 addition & 26 deletions .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
php-version: 8.4
coverage: none
tools: composer:v2
ini-file: development
Expand All @@ -31,28 +31,3 @@ jobs:

- name: Run PHPStan
run: vendor/bin/phpstan analyse --no-progress --error-format=github

psalm:
name: Psalm
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none
tools: composer:v2
ini-file: development

- name: Install Composer dependencies
uses: ramsey/composer-install@v3
with:
dependency-versions: highest
composer-options: --prefer-dist --prefer-stable

- name: Run Psalm
run: vendor/bin/psalm --no-progress --output-format=github --shepherd
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'no_trailing_whitespace_in_string' => false, // For string comparison in tests
'operator_linebreak' => true, // Instead of ['only_booleans' => true]
'phpdoc_to_comment' => [
'ignored_tags' => ['phpstan-var', 'psalm-suppress'],
'ignored_tags' => ['phpstan-var'],
],
'single_line_throw' => false,

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
[![License](https://poser.pugx.org/vincentlanglet/twig-cs-fixer/license)](https://github.com/VincentLanglet/Twig-CS-Fixer/blob/main/LICENCE)
[![Actions Status](https://github.com/VincentLanglet/Twig-CS-Fixer/workflows/Test/badge.svg)](https://github.com/RobDWaller/csp-generator/actions)
[![Coverage](https://codecov.io/gh/VincentLanglet/Twig-CS-Fixer/branch/main/graph/badge.svg)](https://codecov.io/gh/VincentLanglet/Twig-CS-Fixer/branch/main)
[![Type Coverage](https://shepherd.dev/github/VincentLanglet/Twig-CS-Fixer/coverage.svg)](https://shepherd.dev/github/VincentLanglet/Twig-CS-Fixer)
[![Infection MSI](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FVincentLanglet%2FTwig-CS-Fixer%2Fmain)](https://dashboard.stryker-mutator.io/reports/github.com/VincentLanglet/Twig-CS-Fixer/main)

## Installation
Expand Down
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,12 @@
"phpstan/phpstan-symfony": "^2.0",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^9.5.26 || ^10.0.9",
"psalm/plugin-phpunit": "^0.19.0",
"psalm/plugin-symfony": "^5.0.0",
"rector/rector": "^2.0.0",
"shipmonk/composer-dependency-analyser": "^1.6",
"symfony/process": "^5.4 || ^6.4 || ^7.0",
"symfony/twig-bridge": "^5.4 || ^6.4 || ^7.0",
"symfony/ux-twig-component": "^2.2.0",
"twig/cache-extra": "^3.2",
"vimeo/psalm": "^5.2.0"
"twig/cache-extra": "^3.2"
},
"autoload": {
"psr-4": {
Expand Down
40 changes: 0 additions & 40 deletions psalm.xml

This file was deleted.

5 changes: 0 additions & 5 deletions src/Environment/StubbedEnvironment.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public static function satisfiesTwigVersion(int $major, int $minor = 0, int $pat
public function getFilter($name): ?TwigFilter
{
if (!\array_key_exists($name, $this->stubFilters)) {
/** @psalm-suppress InternalMethod */
$existingFilter = parent::getFilter($name);
$this->stubFilters[$name] = $existingFilter instanceof TwigFilter
? $existingFilter
Expand All @@ -118,7 +117,6 @@ public function getFilter($name): ?TwigFilter
public function getFunction($name): ?TwigFunction
{
if (!\array_key_exists($name, $this->stubFunctions)) {
/** @psalm-suppress InternalMethod */
$existingFunction = parent::getFunction($name);
$this->stubFunctions[$name] = $existingFunction instanceof TwigFunction
? $existingFunction
Expand All @@ -134,7 +132,6 @@ public function getFunction($name): ?TwigFunction
public function getTest($name): ?TwigTest
{
if (!\array_key_exists($name, $this->stubTests)) {
/** @psalm-suppress InternalMethod */
$existingTest = parent::getTest($name);
$this->stubTests[$name] = $existingTest instanceof TwigTest
? $existingTest
Expand Down Expand Up @@ -168,11 +165,9 @@ private function handleOptionalDependencies(): void
$this->addTokenParser(new ComponentTokenParser());
}
if (class_exists(PropsTokenParser::class)) {
/** @psalm-suppress InternalClass */
$this->addTokenParser(new PropsTokenParser());
}
if (class_exists(ComponentLexer::class)) {
/** @psalm-suppress InternalClass */
$this->setLexer(new ComponentLexer($this));
}
}
Expand Down
1 change: 0 additions & 1 deletion src/Test/TestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public static function generateDiff(string $contents, string $filePath): string
$filename = escapeshellarg($filename);
$cmd = "diff -u -L{$filename} -LTwigCsFixer {$filename} \"{$tempName}\"";

/** @psalm-suppress ForbiddenCode */
$diff = shell_exec($cmd);

fclose($fixedFile);
Expand Down
7 changes: 0 additions & 7 deletions src/Token/Tokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,6 @@ private function pushState(int $state): void
$this->state[] = [$state, []];
}

/**
* @psalm-suppress PossiblyInvalidArrayAssignment, PropertyTypeCoercion
*
* @see https://github.com/vimeo/psalm/issues/8989
*/
private function setStateParam(string $name, ?string $value): void
{
Assert::notEmpty($this->state, 'Cannot set state params without a current state.');
Expand Down Expand Up @@ -769,9 +764,7 @@ private function lexString(string $string): void
*/
private function getOperatorRegex(Environment $env): string
{
/** @psalm-suppress InternalMethod */
$unaryOperators = array_keys($env->getUnaryOperators());
/** @psalm-suppress InternalMethod */
$binaryOperators = array_keys($env->getBinaryOperators());

/** @var string[] $operators */
Expand Down
8 changes: 4 additions & 4 deletions tests/Cache/Manager/FileCacheManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class FileCacheManagerTest extends TestCase
public function testNeedFixing(): void
{
$cacheManager = new FileCacheManager(
self::createStub(CacheFileHandlerInterface::class),
static::createStub(CacheFileHandlerInterface::class),
new Signature('8.0', '1', [])
);

Expand All @@ -36,7 +36,7 @@ public function testNeedFixingWithCache(): void
$cache = new Cache($signature);
$cache->set($file, md5($content));

$cacheFileHandler = self::createStub(CacheFileHandlerInterface::class);
$cacheFileHandler = static::createStub(CacheFileHandlerInterface::class);
$cacheFileHandler->method('read')->willReturn($cache);

$cacheManager = new FileCacheManager($cacheFileHandler, $signature);
Expand All @@ -57,7 +57,7 @@ public function testNeedFixingWithOutdatedCache(): void
$cache = new Cache(new Signature('8.0', '1', []));
$cache->set($file, md5($content));

$cacheFileHandler = self::createStub(CacheFileHandlerInterface::class);
$cacheFileHandler = static::createStub(CacheFileHandlerInterface::class);
$cacheFileHandler->method('read')->willReturn($cache);

$cacheManager = new FileCacheManager(
Expand All @@ -83,7 +83,7 @@ public function testDestructWriteCache(): void
public function testCannotSerialize(): void
{
$cacheManager = new FileCacheManager(
self::createStub(CacheFileHandlerInterface::class),
static::createStub(CacheFileHandlerInterface::class),
new Signature('8.0', '1', [])
);

Expand Down
2 changes: 1 addition & 1 deletion tests/Cache/SignatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function testSignatureFromRuleset(): void
{
$ruleset = new Ruleset();

$rule = self::createStub(RuleInterface::class);
$rule = static::createStub(RuleInterface::class);
$ruleset->addRule($rule);

$configurableRule = new class extends AbstractRule implements ConfigurableRuleInterface {
Expand Down
7 changes: 0 additions & 7 deletions tests/Console/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,4 @@ public function testNotInstalledLib(): void
static::assertSame('Foo', $app->getName());
static::assertSame('UNKNOWN', $app->getVersion());
}

public function testLibWithoutVersion(): void
{
$app = new Application('Psalm', 'psalm/psalm');
static::assertSame('Psalm', $app->getName());
static::assertSame('dev', $app->getVersion());
}
}
6 changes: 3 additions & 3 deletions tests/Ruleset/RulesetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public function testAddStandard(): void
$rule1 = new SingleQuoteRule(true);
$rule2 = new SingleQuoteRule(false);

$standard1 = self::createStub(StandardInterface::class);
$standard1 = static::createStub(StandardInterface::class);
$standard1->method('getRules')->willReturn([$rule1]);

$standard2 = self::createStub(StandardInterface::class);
$standard2 = static::createStub(StandardInterface::class);
$standard2->method('getRules')->willReturn([$rule2]);

$ruleset->addStandard($standard1);
Expand All @@ -81,7 +81,7 @@ protected function process(int $tokenIndex, Tokens $tokens): void
{
}
};
$standard = self::createStub(StandardInterface::class);
$standard = static::createStub(StandardInterface::class);
$standard->method('getRules')->willReturn([$rule1, $rule2]);

$ruleset->addStandard($standard);
Expand Down
2 changes: 1 addition & 1 deletion tests/Runner/FixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testInvalidFile(): void
{
$exception = CannotTokenizeException::unknownError();

$tokenizer = self::createStub(TokenizerInterface::class);
$tokenizer = static::createStub(TokenizerInterface::class);
$tokenizer->method('tokenize')->willThrowException($exception);
$ruleset = new Ruleset();

Expand Down
12 changes: 5 additions & 7 deletions tests/Runner/LinterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,11 @@ public function testUntokenizableFilesAreReported(): void
$filePath2 = $this->getTmpPath(__DIR__.'/Fixtures/Linter/file2.twig');

$env = new StubbedEnvironment();
$tokenizer = self::createStub(TokenizerInterface::class);
$tokenizer = static::createStub(TokenizerInterface::class);

$call = 0;
$tokenizer->method('tokenize')->willReturnCallback(
static function () use (&$call): Tokens {
/** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/10513 */
if (0 === $call) {
++$call;
throw CannotTokenizeException::unknownError();
Expand Down Expand Up @@ -118,7 +117,7 @@ public function testUserDeprecationAreReported(): void
$filePath = $this->getTmpPath(__DIR__.'/Fixtures/Linter/file.twig');

$env = new StubbedEnvironment();
$tokenizer = self::createStub(TokenizerInterface::class);
$tokenizer = static::createStub(TokenizerInterface::class);
$tokenizer->method('tokenize')->willReturnCallback(static function (): Tokens {
@trigger_error('Default');
trigger_error('User Deprecation', \E_USER_DEPRECATED);
Expand Down Expand Up @@ -176,10 +175,9 @@ public function testBuggyFixesAreReported(
$ruleset = new Ruleset();

$call = 0;
$fixer = self::createStub(FixerInterface::class);
$fixer = static::createStub(FixerInterface::class);
$fixer->method('fixFile')->willReturnCallback(
static function () use (&$call, $exception): string {
/** @psalm-suppress RedundantCondition https://github.com/vimeo/psalm/issues/10513 */
if (0 === $call) {
++$call;
throw $exception;
Expand Down Expand Up @@ -329,9 +327,9 @@ public function testNodeVisitorWithInvalidFiles(): void
$ruleset->addRule(new ForbiddenBlockRule(['trans']));
$ruleset->addRule(new ForbiddenFunctionRule(['t']));

$env = self::createStub(Environment::class);
$env = static::createStub(Environment::class);
$env->method('tokenize')->willThrowException(new SyntaxError('Error.'));
$tokenizer = self::createStub(TokenizerInterface::class);
$tokenizer = static::createStub(TokenizerInterface::class);
$tokenizer->method('tokenize')->willReturn(new Tokens());

$linter = new Linter($env, $tokenizer);
Expand Down

0 comments on commit 3d17f1e

Please sign in to comment.