Skip to content

Commit

Permalink
Updated psalm to version 6.0. Updated cache configurations.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentmuller committed Jan 27, 2025
1 parent 5d8fc94 commit f5c3e99
Show file tree
Hide file tree
Showing 19 changed files with 457 additions and 105 deletions.
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,3 @@ symfony.lock
/deployment.phar
/deploy/
###< deploy ###

###> ci ###
.php-cs-fixer.cache
.phpunit.result.cache
.twig-cs-fixer.cache
###< ci ###
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@

return $config
->setParallelConfig(ParallelConfigFactory::detect())
->setCacheFile(__DIR__ . '/var/cache/php-cs-fixer/.php-cs-fixer.cache')
->setRiskyAllowed(true)
->setFinder($finder)
->setRules($rules);
6 changes: 6 additions & 0 deletions .twig-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@

use TwigCsFixer\Config\Config;

$cache_dir = __DIR__ . '/var/cache/twig-cs-fixer/';
if (!file_exists($cache_dir)) {
mkdir($cache_dir, 0777, true);
}

$config = new Config();
$config->allowNonFixableRules()
->setCacheFile($cache_dir . '/.twig-cs-fixer.cache')
->getFinder()
->in('templates');

Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
level: 8
tmpDir: var/cache/phpstan
paths:
- src
- tests
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
bootstrap="tests/bootstrap.php"
cacheDirectory="var/cache/phpunit"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<psalm xmlns="https://getpsalm.org/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
cacheDirectory="var/cache/psalm"
allowStringToStandInForClass="true"
findUnusedVariablesAndParams="true"
findUnusedBaselineEntry="true"
Expand Down
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Rector\Symfony\Set\TwigSetList;

return RectorConfig::configure()
->withCache(__DIR__ . '/var/cache/rector')
->withRootFiles()
->withPaths([
__DIR__ . '/config',
Expand Down
2 changes: 2 additions & 0 deletions src/Controller/HelpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ private function getTargetPath(HelpDownloadQuery $query): ?string
if (\is_numeric(\end($parts))) {
\array_pop($parts);
}
/** @psalm-var string $first */
$first = \reset($parts);
/** @psalm-var string $last */
$last = \end($parts);
if ($first === $last) {
$last = 'list';
Expand Down
4 changes: 3 additions & 1 deletion src/Pivot/Field/PivotWeekdayField.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ public function __construct(protected string $name, protected ?string $title = n
{
parent::__construct($name, self::PART_WEEK_DAY, $title);

$firstDay = \strtolower(\date('l', \strtotime('this week')));
/** @psalm-var int<1, max> $time */
$time = \strtotime('this week');
$firstDay = \strtolower(\date('l', $time));
$this->names = $short ? DateUtils::getShortWeekdays($firstDay) : DateUtils::getWeekdays($firstDay);
}

Expand Down
1 change: 1 addition & 0 deletions src/Report/CalculationByMonthReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ private function getArrowColor(PdfColorInterface $color): PdfTextColor
return $this->colors[$color] = $color->getTextColor();
}

/** @psalm-var PdfTextColor */
return $this->colors[$color];
}

Expand Down
1 change: 1 addition & 0 deletions src/Service/AES256EncryptorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public function encrypt(string $data): string|false
*/
public function encryptJson(mixed $data, int $flags = 0): string|false
{
/** @psalm-var non-empty-string $encoded */
$encoded = \json_encode($data, $flags | \JSON_THROW_ON_ERROR);

return $this->encrypt($encoded);
Expand Down
6 changes: 5 additions & 1 deletion src/Service/CountryFlagService.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ private function getChoiceEntry(string $code, string $name, bool $flagOnly): str

private function getEmojiChar(string $chr): string
{
return \mb_chr(self::REGIONAL_OFFSET + \mb_ord($chr, 'UTF-8'), 'UTF-8');
/** @psalm-var int $order */
$order = \mb_ord($chr, 'UTF-8');

/** @psalm-var string */
return \mb_chr(self::REGIONAL_OFFSET + $order, 'UTF-8');
}
}
1 change: 1 addition & 0 deletions src/Service/SwissPostUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public function import(UploadedFile|string|null $sourceFile, bool $overwrite): S

private function clean(string $str): string
{
/** @psalm-var string */
return \mb_convert_encoding(\trim($str), 'UTF-8', 'ISO-8859-1');
}

Expand Down
1 change: 1 addition & 0 deletions src/Utils/StringUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public static function decodeJson(string $value, bool $assoc = true, int $flags
public static function encodeJson(mixed $value, int $flags = 0): string
{
try {
/** @psalm-var non-empty-string */
return \json_encode($value, $flags | \JSON_THROW_ON_ERROR);
} catch (\JsonException $e) {
$message = \sprintf("Unable to encode value '%s'.", \get_debug_type($value));
Expand Down
2 changes: 1 addition & 1 deletion tests/Controller/HelpControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private function checkUrl(string $url): void
private function getDownloadImage(): string
{
$path = __DIR__ . '/../files/images/example.png';
$type = \mime_content_type($path);
$type = (string) \mime_content_type($path);
$data = (string) \file_get_contents($path);
$encoded = \base64_encode($data);

Expand Down
1 change: 1 addition & 0 deletions tests/Enums/ImageExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ImageExtensionTest extends TestCase
{
public static function getCreateImages(): \Iterator
{
/** @psalm-var non-empty-string $dir */
$dir = \realpath(__DIR__ . '/../files/images');
yield [ImageExtension::BMP, $dir . '/example.bmp'];
yield [ImageExtension::GIF, $dir . '/example.gif'];
Expand Down
6 changes: 4 additions & 2 deletions tests/Utils/StringUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ public function testCapitalize(string $value, string $expected): void
public function testDecodeJsonArray(): void
{
$expected = ['key' => 'value'];
/** @psalm-var non-empty-string $encoded */
$encoded = \json_encode($expected);
$actual = StringUtils::decodeJson($encoded); // @phpstan-ignore argument.type
$actual = StringUtils::decodeJson($encoded);
self::assertSame($expected, $actual);
}

Expand All @@ -149,8 +150,9 @@ public function testDecodeJsonObject(): void
$expected = new \stdClass();
$expected->key = 'value';
$expected->date = 'date';
/** @psalm-var non-empty-string $encoded */
$encoded = \json_encode($expected);
$actual = StringUtils::decodeJson($encoded, false); // @phpstan-ignore argument.type
$actual = StringUtils::decodeJson($encoded, false);
self::assertObjectHasProperty('key', $actual);
self::assertObjectHasProperty('date', $actual);
self::assertSame($expected->key, $actual->key);
Expand Down
2 changes: 1 addition & 1 deletion vendor-bin/psalm/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"require": {
"php": "^8.2",
"vimeo/psalm": "^5.0",
"vimeo/psalm": "^6.0",
"weirdan/doctrine-psalm-plugin": "^2.0",
"psalm/plugin-phpunit": "^0.19",
"psalm/plugin-symfony": "^5.0"
Expand Down
Loading

0 comments on commit f5c3e99

Please sign in to comment.