Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"ext-simplexml": "*",
"php-static-analysis/attributes": "^0.4.1 || dev-main",
"php-static-analysis/node-visitor": "^0.4.1 || dev-main",
"vimeo/psalm": "^6",
"vimeo/psalm": "^6.12",
"webmozart/assert": "^1.11"
},
"require-dev": {
Expand Down
16 changes: 16 additions & 0 deletions patches/vimeo-psalm-src-psalm-internal-codebase-analizer-php.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/src/Psalm/Internal/Codebase/Analyzer.php b/src/Psalm/Internal/Codebase/Analyzer.php
index f9127a517..41f94a174 100644
--- a/src/Psalm/Internal/Codebase/Analyzer.php
+++ b/src/Psalm/Internal/Codebase/Analyzer.php
@@ -812,7 +812,10 @@ final class Analyzer
);
}

- public function shiftFileOffsets(StatementsProvider $statements_provider): void
+ /**
+ * @param StatementsProvider $statements_provider
+ */
+ public function shiftFileOffsets($statements_provider): void
{
$diff_map = $statements_provider->getDiffMap();
$deletion_ranges = $statements_provider->getDeletionRanges();
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/Psalm/Internal/Provider/ParserCacheProvider.php b/src/Psalm/Internal/Provider/ParserCacheProvider.php
index f352519f2..c2351841e 100644
--- a/src/Psalm/Internal/Provider/ParserCacheProvider.php
+++ b/src/Psalm/Internal/Provider/ParserCacheProvider.php
@@ -13,7 +13,7 @@ use function filemtime;
use const DIRECTORY_SEPARATOR;

/** @internal */
-final class ParserCacheProvider
+class ParserCacheProvider
{
private const PARSER_CACHE_DIRECTORY = 'php-parser';

13 changes: 13 additions & 0 deletions patches/vimeo-psalm-tests-testconfig-php.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/tests/TestConfig.php b/tests/TestConfig.php
index b5bac8fcc..970ac2b40 100644
--- a/tests/TestConfig.php
+++ b/tests/TestConfig.php
@@ -12,7 +12,7 @@ use SimpleXMLElement;

use function getcwd;

-final class TestConfig extends Config
+class TestConfig extends Config
{
private static ?ProjectFileFilter $cached_project_files = null;

1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
ensureOverrideAttribute="false"
>
<projectFiles>
<directory name="src" />
Expand Down
23 changes: 18 additions & 5 deletions src/Composer/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Composer\Script\Event;
use PhpStaticAnalysis\Attributes\Returns;

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

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

exec("patch -p1 -d $dependencyPath --forward < $patchFile");
if ($patchFiles === false) {
echo "No patches to apply\n";
return;
}
foreach ($patchFiles as $patchFile) {
$escapedPatchFile = escapeshellarg($patchFile);
$escapedDependencyPath = escapeshellarg($dependencyPath);

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

exec("patch -p1 -d $dependencyPath --forward < $patchFile");
if ($returnVar !== 0) {
echo "Failed to apply patch: $patchFile\n";
} else {
echo "Applied patch: $patchFile\n";
}
}
}
}
2 changes: 1 addition & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Psalm\Plugin\RegistrationInterface;
use SimpleXMLElement;

class Plugin implements PluginEntryPointInterface
final class Plugin implements PluginEntryPointInterface
{
public function __invoke(RegistrationInterface $registration, ?SimpleXMLElement $config = null): void
{
Expand Down
4 changes: 3 additions & 1 deletion src/Provider/AttributeStatementProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Psalm\Progress\Progress;
use Webmozart\Assert\Assert;

class AttributeStatementProvider
final class AttributeStatementProvider
{
private StatementsProvider $statementsProvider;

Expand All @@ -27,12 +27,14 @@ public function __construct(StatementsProvider $statementsProvider)
public function getStatementsForFile(
string $file_path,
int $analysis_php_version_id,
bool $do_diff,
?Progress $progress = null
): array {
/** @psalm-suppress InternalMethod */
$ast = $this->statementsProvider->getStatementsForFile(
$file_path,
$analysis_php_version_id,
$do_diff,
$progress
);
return $this->traverseAst($ast);
Expand Down
2 changes: 1 addition & 1 deletion tests/AssertAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class AssertAttributeTest extends BaseAttributeTestCase
final class AssertAttributeTest extends BaseAttributeTestCase
{
public function testFunctionAssertAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/AssertIfFalseAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class AssertIfFalseAttributeTest extends BaseAttributeTestCase
final class AssertIfFalseAttributeTest extends BaseAttributeTestCase
{
public function testFunctionAssertIfFalseAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/AssertIfTrueAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class AssertIfTrueAttributeTest extends BaseAttributeTestCase
final class AssertIfTrueAttributeTest extends BaseAttributeTestCase
{
public function testFunctionAssertIfTrueAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/AttributeTestConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psalm\Progress\Progress;
use Psalm\Tests\TestConfig;

class AttributeTestConfig extends TestConfig
final class AttributeTestConfig extends TestConfig
{
protected function getContents(): string
{
Expand Down
2 changes: 1 addition & 1 deletion tests/DefineTypeAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class DefineTypeAttributeTest extends BaseAttributeTestCase
final class DefineTypeAttributeTest extends BaseAttributeTestCase
{
public function testClassDefineTypeAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/DeprecatedAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class DeprecatedAttributeTest extends BaseAttributeTestCase
final class DeprecatedAttributeTest extends BaseAttributeTestCase
{
public function testClassDeprecatedAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ImmutableAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class ImmutableAttributeTest extends BaseAttributeTestCase
final class ImmutableAttributeTest extends BaseAttributeTestCase
{
public function testClassImmutableAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ImportTypeAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class ImportTypeAttributeTest extends BaseAttributeTestCase
final class ImportTypeAttributeTest extends BaseAttributeTestCase
{
public function testClassImportTypeAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/InternalAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class InternalAttributeTest extends BaseAttributeTestCase
final class InternalAttributeTest extends BaseAttributeTestCase
{
public function testClassInternalAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/IsReadOnlyAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class IsReadOnlyAttributeTest extends BaseAttributeTestCase
final class IsReadOnlyAttributeTest extends BaseAttributeTestCase
{
public function testPropertyIsReadOnlyAttribute(): void
{
Expand Down
3 changes: 2 additions & 1 deletion tests/MethodAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class MethodAttributeTest extends BaseAttributeTestCase
final class MethodAttributeTest extends BaseAttributeTestCase
{
public function testClassMethodAttribute(): void
{
Expand All @@ -27,6 +27,7 @@ public function testInvalidClassMethodAttribute(): void
$errors = $this->analyzeTestFile( '/data/Method/InvalidClassMethodAttribute.php');

$expectedErrors = [
'Magic method test\PhpStaticAnalysis\PsalmPlugin\data\Method\InvalidClassMethodAttribute::badfunction does not exist' => 34,
'No @method entry specified in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Method\InvalidClassMethodAttribute' => 9,
'Attribute Method cannot be used on a method' => 11,
'string is not a valid method in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Method\AnotherInvalidClassMethodAttribute' => 29,
Expand Down
2 changes: 1 addition & 1 deletion tests/MixinAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class MixinAttributeTest extends BaseAttributeTestCase
final class MixinAttributeTest extends BaseAttributeTestCase
{
public function testClassMixinAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ParamAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class ParamAttributeTest extends BaseAttributeTestCase
final class ParamAttributeTest extends BaseAttributeTestCase
{
public function testFunctionParamAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ParamOutAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class ParamOutAttributeTest extends BaseAttributeTestCase
final class ParamOutAttributeTest extends BaseAttributeTestCase
{
public function testMethodParamOutAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/PropertyAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class PropertyAttributeTest extends BaseAttributeTestCase
final class PropertyAttributeTest extends BaseAttributeTestCase
{
public function testClassPropertyAttribute(): void
{
Expand Down
3 changes: 2 additions & 1 deletion tests/PropertyReadAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class PropertyReadAttributeTest extends BaseAttributeTestCase
final class PropertyReadAttributeTest extends BaseAttributeTestCase
{
public function testClassPropertyReadAttribute(): void
{
Expand All @@ -27,6 +27,7 @@ public function testInvalidClassPropertyReadAttribute(): void
$errors = $this->analyzeTestFile('/data/PropertyRead/InvalidClassPropertyReadAttribute.php');

$expectedErrors = [
'Magic instance property test\PhpStaticAnalysis\PsalmPlugin\data\PropertyRead\InvalidClassPropertyReadAttribute::$name is not defined' => 39,
'Badly-formatted @property in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\PropertyRead\InvalidClassPropertyReadAttribute' => 9,
'Attribute PropertyRead cannot be used on a method' => 11,
'Badly-formatted @property in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\PropertyRead\AnotherInvalidClassPropertyReadAttribute' => 29,
Expand Down
3 changes: 2 additions & 1 deletion tests/PropertyWriteAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class PropertyWriteAttributeTest extends BaseAttributeTestCase
final class PropertyWriteAttributeTest extends BaseAttributeTestCase
{
public function testClassPropertyWriteAttribute(): void
{
Expand All @@ -27,6 +27,7 @@ public function testInvalidClassPropertyWriteAttribute(): void
$errors = $this->analyzeTestFile('/data/PropertyWrite/InvalidClassPropertyWriteAttribute.php');

$expectedErrors = [
'Magic instance property test\PhpStaticAnalysis\PsalmPlugin\data\PropertyWrite\InvalidClassPropertyWriteAttribute::$name is not defined' => 39,
'Unable to determine the type that $foo is being assigned to' => 39,
'Badly-formatted @property in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\PropertyWrite\InvalidClassPropertyWriteAttribute' => 9,
'Attribute PropertyWrite cannot be used on a method' => 11,
Expand Down
2 changes: 1 addition & 1 deletion tests/PureAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class PureAttributeTest extends BaseAttributeTestCase
final class PureAttributeTest extends BaseAttributeTestCase
{
public function testMethodPureAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/RequireExtendsAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class RequireExtendsAttributeTest extends BaseAttributeTestCase
final class RequireExtendsAttributeTest extends BaseAttributeTestCase
{
public function testClassRequireExtendsAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/RequireImplementsAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class RequireImplementsAttributeTest extends BaseAttributeTestCase
final class RequireImplementsAttributeTest extends BaseAttributeTestCase
{
public function testClassRequireImplementsAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ReturnsAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class ReturnsAttributeTest extends BaseAttributeTestCase
final class ReturnsAttributeTest extends BaseAttributeTestCase
{
public function testFunctionReturnsAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/SelfOutAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class SelfOutAttributeTest extends BaseAttributeTestCase
final class SelfOutAttributeTest extends BaseAttributeTestCase
{
public function testMethodSelfOutAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/TemplateAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class TemplateAttributeTest extends BaseAttributeTestCase
final class TemplateAttributeTest extends BaseAttributeTestCase
{
public function testFunctionTemplateAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/TemplateCovariantAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class TemplateCovariantAttributeTest extends BaseAttributeTestCase
final class TemplateCovariantAttributeTest extends BaseAttributeTestCase
{
public function testClassTemplateCovariantAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/TemplateExtendsAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class TemplateExtendsAttributeTest extends BaseAttributeTestCase
final class TemplateExtendsAttributeTest extends BaseAttributeTestCase
{
public function testClassTemplateExtendsAttribute(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/TemplateImplementsAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace test\PhpStaticAnalysis\PsalmPlugin;

class TemplateImplementsAttributeTest extends BaseAttributeTestCase
final class TemplateImplementsAttributeTest extends BaseAttributeTestCase
{
public function testInterfaceTemplateImplementsAttribute(): void
{
Expand Down
Loading