Skip to content

Commit 33ceaaf

Browse files
Merge pull request #3 from php-static-analysis/psalm-6.12
Updates for PSalm 6.12
2 parents ca9dccd + 35daa6d commit 33ceaaf

36 files changed

+97
-36
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"ext-simplexml": "*",
3030
"php-static-analysis/attributes": "^0.4.1 || dev-main",
3131
"php-static-analysis/node-visitor": "^0.4.1 || dev-main",
32-
"vimeo/psalm": "^6",
32+
"vimeo/psalm": "^6.12",
3333
"webmozart/assert": "^1.11"
3434
},
3535
"require-dev": {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/src/Psalm/Internal/Codebase/Analyzer.php b/src/Psalm/Internal/Codebase/Analyzer.php
2+
index f9127a517..41f94a174 100644
3+
--- a/src/Psalm/Internal/Codebase/Analyzer.php
4+
+++ b/src/Psalm/Internal/Codebase/Analyzer.php
5+
@@ -812,7 +812,10 @@ final class Analyzer
6+
);
7+
}
8+
9+
- public function shiftFileOffsets(StatementsProvider $statements_provider): void
10+
+ /**
11+
+ * @param StatementsProvider $statements_provider
12+
+ */
13+
+ public function shiftFileOffsets($statements_provider): void
14+
{
15+
$diff_map = $statements_provider->getDiffMap();
16+
$deletion_ranges = $statements_provider->getDeletionRanges();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/Psalm/Internal/Provider/ParserCacheProvider.php b/src/Psalm/Internal/Provider/ParserCacheProvider.php
2+
index f352519f2..c2351841e 100644
3+
--- a/src/Psalm/Internal/Provider/ParserCacheProvider.php
4+
+++ b/src/Psalm/Internal/Provider/ParserCacheProvider.php
5+
@@ -13,7 +13,7 @@ use function filemtime;
6+
use const DIRECTORY_SEPARATOR;
7+
8+
/** @internal */
9+
-final class ParserCacheProvider
10+
+class ParserCacheProvider
11+
{
12+
private const PARSER_CACHE_DIRECTORY = 'php-parser';
13+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/tests/TestConfig.php b/tests/TestConfig.php
2+
index b5bac8fcc..970ac2b40 100644
3+
--- a/tests/TestConfig.php
4+
+++ b/tests/TestConfig.php
5+
@@ -12,7 +12,7 @@ use SimpleXMLElement;
6+
7+
use function getcwd;
8+
9+
-final class TestConfig extends Config
10+
+class TestConfig extends Config
11+
{
12+
private static ?ProjectFileFilter $cached_project_files = null;
13+

psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
errorLevel="1"
88
findUnusedBaselineEntry="true"
99
findUnusedCode="false"
10+
ensureOverrideAttribute="false"
1011
>
1112
<projectFiles>
1213
<directory name="src" />

src/Composer/Plugin.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use Composer\Script\Event;
1010
use PhpStaticAnalysis\Attributes\Returns;
1111

12-
class Plugin implements PluginInterface, EventSubscriberInterface
12+
final class Plugin implements PluginInterface, EventSubscriberInterface
1313
{
1414
public function activate(Composer $composer, IOInterface $io)
1515
{
@@ -50,12 +50,25 @@ private static function applyPatches(Event $event): void
5050
$vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
5151

5252
$dependencyPath = $vendorDir . '/vimeo/psalm';
53-
$patchFile = __DIR__ . '/../../patches/vimeo-psalm-src-psalm-config-php.patch';
53+
$patchesDir = __DIR__ . '/../../patches/';
54+
$patchFiles = glob($patchesDir . '*.patch');
5455

55-
exec("patch -p1 -d $dependencyPath --forward < $patchFile");
56+
if ($patchFiles === false) {
57+
echo "No patches to apply\n";
58+
return;
59+
}
60+
foreach ($patchFiles as $patchFile) {
61+
$escapedPatchFile = escapeshellarg($patchFile);
62+
$escapedDependencyPath = escapeshellarg($dependencyPath);
5663

57-
$patchFile = __DIR__ . '/../../patches/vimeo-psalm-src-psalm-codebase-php.patch';
64+
$cmd = "patch -p1 -d $escapedDependencyPath --forward < $escapedPatchFile";
65+
exec($cmd, $output, $returnVar);
5866

59-
exec("patch -p1 -d $dependencyPath --forward < $patchFile");
67+
if ($returnVar !== 0) {
68+
echo "Failed to apply patch: $patchFile\n";
69+
} else {
70+
echo "Applied patch: $patchFile\n";
71+
}
72+
}
6073
}
6174
}

src/Plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use Psalm\Plugin\RegistrationInterface;
1111
use SimpleXMLElement;
1212

13-
class Plugin implements PluginEntryPointInterface
13+
final class Plugin implements PluginEntryPointInterface
1414
{
1515
public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
1616
{

src/Provider/AttributeStatementProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Psalm\Progress\Progress;
1515
use Webmozart\Assert\Assert;
1616

17-
class AttributeStatementProvider
17+
final class AttributeStatementProvider
1818
{
1919
private StatementsProvider $statementsProvider;
2020

@@ -27,12 +27,14 @@ public function __construct(StatementsProvider $statementsProvider)
2727
public function getStatementsForFile(
2828
string $file_path,
2929
int $analysis_php_version_id,
30+
bool $do_diff,
3031
?Progress $progress = null
3132
): array {
3233
/** @psalm-suppress InternalMethod */
3334
$ast = $this->statementsProvider->getStatementsForFile(
3435
$file_path,
3536
$analysis_php_version_id,
37+
$do_diff,
3638
$progress
3739
);
3840
return $this->traverseAst($ast);

tests/AssertAttributeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace test\PhpStaticAnalysis\PsalmPlugin;
66

7-
class AssertAttributeTest extends BaseAttributeTestCase
7+
final class AssertAttributeTest extends BaseAttributeTestCase
88
{
99
public function testFunctionAssertAttribute(): void
1010
{

tests/AssertIfFalseAttributeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace test\PhpStaticAnalysis\PsalmPlugin;
66

7-
class AssertIfFalseAttributeTest extends BaseAttributeTestCase
7+
final class AssertIfFalseAttributeTest extends BaseAttributeTestCase
88
{
99
public function testFunctionAssertIfFalseAttribute(): void
1010
{

0 commit comments

Comments
 (0)