diff --git a/.github/workflows/all_tests.yml b/.github/workflows/all_tests.yml
index f23a0ed..1c66584 100644
--- a/.github/workflows/all_tests.yml
+++ b/.github/workflows/all_tests.yml
@@ -14,10 +14,10 @@ jobs:
fail-fast: false
matrix:
php-version:
- - "8.0"
- "8.1"
- "8.2"
- "8.3"
+ - "8.4"
steps:
- name: "Checkout"
diff --git a/.gitignore b/.gitignore
index 56300ef..9451543 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@ composer.lock
.phpunit.result.cache
.idea
cache
+.codebase_patch_applied
+.config_patch_applied
diff --git a/README.md b/README.md
index 751d106..19caf11 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,10 @@ However, static analysis tools like Psalm have not made this transition to attri
This is a Psalm plugin that allows Psalm to understand a new set of attributes that replace the PHPDoc annotations. These attributes are defined in [this repository](https://github.com/php-static-analysis/attributes)
+NOTE: Version 0.4.0 of this plugin requires Php Parser v5. The current available version of Psalm (v5) does not support this
+version of the parser, so currently this library only supports the `dev-master` version of Psalm. If you need to
+use Psalm 5, you will need to use version 0.3 of this plugin.
+
## Example
In order to show how code would look with these attributes, we can look at the following example. This is how a class looks like with the current annotations:
@@ -74,6 +78,12 @@ To use this plugin, require it in Composer:
composer require --dev php-static-analysis/psalm-plugin
```
+NOTE: When adding this dependency, composer will ask you
+if you want to allow this dependency as a composer plugin.
+This is needed so that this plugin can patch Psalm in order
+to enable its functionality. This will add an entry in your
+`allow-plugins` composer config entry.
+
Then run this command to enable the plugin:
```
diff --git a/composer.json b/composer.json
index 8ea5c70..0b43e7e 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "php-static-analysis/psalm-plugin",
"description": "Psalm plugin to read static analysis attributes",
- "type": "psalm-plugin",
+ "type": "composer-plugin",
"keywords": ["dev", "static analysis"],
"license": "MIT",
"autoload": {
@@ -24,17 +24,19 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
- "php": ">=8.0",
+ "php": ">=8.1",
+ "composer-plugin-api": "^2.0",
"ext-simplexml": "*",
- "php-static-analysis/attributes": "^0.3.1 || dev-main",
- "php-static-analysis/node-visitor": "^0.3.1 || dev-main",
- "vimeo/psalm": "^5",
+ "php-static-analysis/attributes": "^0.3.2 || dev-main",
+ "php-static-analysis/node-visitor": "^0.3.2 || dev-main",
+ "vimeo/psalm": "dev-master",
"webmozart/assert": "^1.11"
},
"require-dev": {
- "php-static-analysis/phpstan-extension": "dev-main",
+ "composer/composer": "^2.0",
+ "php-static-analysis/phpstan-extension": "^0.3.2 || dev-main",
"phpstan/extension-installer": "^1.3",
- "phpstan/phpstan": "^1.10",
+ "phpstan/phpstan": "^1.8 | ^2.0",
"phpunit/phpunit": "^9.0",
"symplify/easy-coding-standard": "^12.1"
},
@@ -50,7 +52,8 @@
"extra": {
"psalm": {
"pluginClass": "PhpStaticAnalysis\\PsalmPlugin\\Plugin"
- }
+ },
+ "class": "PhpStaticAnalysis\\PsalmPlugin\\Composer\\Plugin"
},
"scripts": {
"tests": [
@@ -64,6 +67,8 @@
"ecs": "ecs",
"ecs-fix": "ecs --fix",
"phpunit": "phpunit",
- "phpstan": "phpstan analyse"
+ "phpstan": "phpstan analyse",
+ "post-install-cmd": "PhpStaticAnalysis\\PsalmPlugin\\Composer\\Plugin::onPostInstall",
+ "post-update-cmd": "PhpStaticAnalysis\\PsalmPlugin\\Composer\\Plugin::onPostUpdate"
}
}
diff --git a/patches/vimeo-psalm-src-psalm-codebase-php.patch b/patches/vimeo-psalm-src-psalm-codebase-php.patch
new file mode 100644
index 0000000..cba354a
--- /dev/null
+++ b/patches/vimeo-psalm-src-psalm-codebase-php.patch
@@ -0,0 +1,14 @@
+--- /dev/null
++++ ../src/Psalm/Codebase.php
+@@ -131,7 +131,10 @@
+
+ public FileReferenceProvider $file_reference_provider;
+
+- public StatementsProvider $statements_provider;
++ /**
++ * @var StatementsProvider
++ */
++ public $statements_provider;
+
+ private readonly Progress $progress;
+
diff --git a/patches/vimeo-psalm-src-psalm-config-php.patch b/patches/vimeo-psalm-src-psalm-config-php.patch
new file mode 100644
index 0000000..91c4ab2
--- /dev/null
+++ b/patches/vimeo-psalm-src-psalm-config-php.patch
@@ -0,0 +1,11 @@
+--- /dev/null
++++ ../src/Psalm/Config.php
+@@ -130,7 +130,7 @@
+ * @psalm-suppress PropertyNotSetInConstructor
+ * @psalm-consistent-constructor
+ */
+-final class Config
++class Config
+ {
+ final public const DEFAULT_BASELINE_NAME = 'psalm-baseline.xml';
+ private const DEFAULT_FILE_NAMES = [
diff --git a/phpstan.neon b/phpstan.neon
index 70604f6..2b841a7 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -4,4 +4,4 @@ parameters:
- src
- tests
excludePaths:
- - tests/data/*
\ No newline at end of file
+ - tests/data/*
diff --git a/psalm.xml b/psalm.xml
index 59835b6..92e584a 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -12,7 +12,6 @@
-
diff --git a/src/Composer/Plugin.php b/src/Composer/Plugin.php
new file mode 100644
index 0000000..9fe18e9
--- /dev/null
+++ b/src/Composer/Plugin.php
@@ -0,0 +1,61 @@
+')]
+ public static function getSubscribedEvents(): array
+ {
+ return [
+ 'post-install-cmd' => 'onPostInstall',
+ 'post-update-cmd' => 'onPostUpdate'
+ ];
+ }
+
+ public static function onPostInstall(Event $event): void
+ {
+ self::applyPatches($event);
+ }
+
+ public static function onPostUpdate(Event $event): void
+ {
+ self::applyPatches($event);
+ }
+
+ private static function applyPatches(Event $event): void
+ {
+ /**
+ * @var string $vendorDir
+ */
+ $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
+
+ $dependencyPath = $vendorDir . '/vimeo/psalm';
+ $patchFile = __DIR__ . '/../../patches/vimeo-psalm-src-psalm-config-php.patch';
+
+ exec("patch -p1 -d $dependencyPath --forward < $patchFile");
+
+ $patchFile = __DIR__ . '/../../patches/vimeo-psalm-src-psalm-codebase-php.patch';
+
+ exec("patch -p1 -d $dependencyPath --forward < $patchFile");
+ }
+}
diff --git a/src/Provider/AttributeStatementProvider.php b/src/Provider/AttributeStatementProvider.php
index ad90685..14d0ad9 100644
--- a/src/Provider/AttributeStatementProvider.php
+++ b/src/Provider/AttributeStatementProvider.php
@@ -38,7 +38,7 @@ public function getStatementsForFile(
return $this->traverseAst($ast);
}
- #[Param(args: 'mixed[]')]
+ #[Param(args: 'array')]
public function __call(string $method, array $args): mixed
{
$callable = [$this->statementsProvider, $method];
diff --git a/tests/AssertAttributeTest.php b/tests/AssertAttributeTest.php
index 0ecd052..b66c653 100644
--- a/tests/AssertAttributeTest.php
+++ b/tests/AssertAttributeTest.php
@@ -22,7 +22,7 @@ public function testInvalidMethodAssertAttribute(): void
{
$errors = $this->analyzeTestFile('/data/Assert/InvalidMethodAssertAttribute.php');
$this->checkExpectedErrors($errors,[
- 'Argument 1 of PhpStaticAnalysis\Attributes\Assert::__construct expects string, but 0 provided' => 9,
+ 'Misplaced variable in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Assert\InvalidMethodAssertAttribute::checkString' => 9,
'Attribute Assert cannot be used on a property' => 14,
]);
}
diff --git a/tests/AssertIfFalseAttributeTest.php b/tests/AssertIfFalseAttributeTest.php
index 7a7557e..a1c873f 100644
--- a/tests/AssertIfFalseAttributeTest.php
+++ b/tests/AssertIfFalseAttributeTest.php
@@ -22,7 +22,7 @@ public function testInvalidMethodAssertIfFalseAttribute(): void
{
$errors = $this->analyzeTestFile('/data/AssertIfFalse/InvalidMethodAssertIfFalseAttribute.php');
$this->checkExpectedErrors($errors,[
- 'Argument 1 of PhpStaticAnalysis\Attributes\AssertIfFalse::__construct expects string, but 0 provided' => 9,
+ 'Misplaced variable in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\AssertIfFalse\InvalidMethodAssertIfFalseAttribute::checkString' => 9,
'Attribute AssertIfFalse cannot be used on a property' => 15,
]);
}
diff --git a/tests/AssertIfTrueAttributeTest.php b/tests/AssertIfTrueAttributeTest.php
index ae43580..5a0e0ca 100644
--- a/tests/AssertIfTrueAttributeTest.php
+++ b/tests/AssertIfTrueAttributeTest.php
@@ -22,7 +22,7 @@ public function testInvalidMethodAssertIfTrueAttribute(): void
{
$errors = $this->analyzeTestFile('/data/AssertIfTrue/InvalidMethodAssertIfTrueAttribute.php');
$this->checkExpectedErrors($errors,[
- 'Argument 1 of PhpStaticAnalysis\Attributes\AssertIfTrue::__construct expects string, but 0 provided' => 9,
+ 'Misplaced variable in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\AssertIfTrue\InvalidMethodAssertIfTrueAttribute::checkString' => 9,
'Attribute AssertIfTrue cannot be used on a property' => 15,
]);
}
diff --git a/tests/BaseAttributeTestCase.php b/tests/BaseAttributeTestCase.php
index 040baf2..40afbbe 100644
--- a/tests/BaseAttributeTestCase.php
+++ b/tests/BaseAttributeTestCase.php
@@ -74,7 +74,7 @@ protected function checkExpectedErrors(
$errorNum = 0;
foreach ($expectedErrors as $error => $line) {
- /** @psalm-suppress InternalProperty */
+ /** @psalm-suppress InternalProperty, UndefinedPropertyFetch */
$this->assertSame($error, $errors[$errorNum]->message);
/** @psalm-suppress InternalProperty */
$this->assertSame($line, $errors[$errorNum]->line_from);
diff --git a/tests/DefineTypeAttributeTest.php b/tests/DefineTypeAttributeTest.php
index 91ff718..7bb3cb4 100644
--- a/tests/DefineTypeAttributeTest.php
+++ b/tests/DefineTypeAttributeTest.php
@@ -28,7 +28,6 @@ public function testInvalidClassDefineTypeAttribute(): void
$expectedErrors = [
'Misplaced brackets' => 7,
- 'Argument 1 of PhpStaticAnalysis\Attributes\DefineType::__construct expects string, but 0 provided' => 7,
'Attribute DefineType cannot be used on a method' => 12,
];
diff --git a/tests/DeprecatedAttributeTest.php b/tests/DeprecatedAttributeTest.php
index dbc66b5..f3bec7d 100644
--- a/tests/DeprecatedAttributeTest.php
+++ b/tests/DeprecatedAttributeTest.php
@@ -54,7 +54,6 @@ public function testInvalidMethodDeprecatedAttribute(): void
$expectedErrors = [
'Attribute Deprecated cannot be used on a function/method parameter' => 12,
- 'Attribute Deprecated is not repeatable' => 19,
];
$this->checkExpectedErrors($errors, $expectedErrors);
diff --git a/tests/ImmutableAttributeTest.php b/tests/ImmutableAttributeTest.php
index f591f76..f4c7714 100644
--- a/tests/ImmutableAttributeTest.php
+++ b/tests/ImmutableAttributeTest.php
@@ -32,7 +32,6 @@ public function testInvalidClassImmutableAttribute(): void
$errors = $this->analyzeTestFile( '/data/Immutable/InvalidClassImmutableAttribute.php');
$expectedErrors = [
- 'Attribute Immutable is not repeatable' => 10,
'Attribute Immutable cannot be used on a property' => 13,
];
diff --git a/tests/ImportTypeAttributeTest.php b/tests/ImportTypeAttributeTest.php
index d5182ba..2f9dd06 100644
--- a/tests/ImportTypeAttributeTest.php
+++ b/tests/ImportTypeAttributeTest.php
@@ -29,7 +29,6 @@ public function testInvalidClassImportTypeAttribute(): void
$expectedErrors = [
'Invalid import in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\ImportType\InvalidClassImportTypeAttribute, expecting " from ", got "" instead.' => 9,
'Invalid import in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\ImportType\InvalidClassImportTypeAttribute, expecting " from ", got "string" instead.' => 10,
- 'Argument 1 of PhpStaticAnalysis\Attributes\ImportType::__construct expects string, but 0 provided' => 8,
'Attribute ImportType cannot be used on a method' => 13,
'Docblock-defined class, interface or enum named test\PhpStaticAnalysis\PsalmPlugin\data\ImportType\count($a) does not exist' => 11,
];
diff --git a/tests/InternalAttributeTest.php b/tests/InternalAttributeTest.php
index a575e0e..6891912 100644
--- a/tests/InternalAttributeTest.php
+++ b/tests/InternalAttributeTest.php
@@ -49,9 +49,7 @@ public function testInvalidMethodInternalAttribute(): void
$errors = $this->analyzeTestFile('/data/Internal/InvalidMethodInternalAttribute.php');
$expectedErrors = [
'psalm-internal annotation used without specifying namespace in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Internal\InvalidMethodInternalAttribute::getName' => 9,
- 'Argument 1 of PhpStaticAnalysis\Attributes\Internal::__construct expects null|string, but 0 provided' => 9,
'Attribute Internal cannot be used on a function/method parameter' => 15,
- 'Attribute Internal is not repeatable' => 22,
];
$this->checkExpectedErrors($errors, $expectedErrors);
diff --git a/tests/IsReadOnlyAttributeTest.php b/tests/IsReadOnlyAttributeTest.php
index de92796..ccc12ac 100644
--- a/tests/IsReadOnlyAttributeTest.php
+++ b/tests/IsReadOnlyAttributeTest.php
@@ -19,8 +19,6 @@ public function testInvalidPropertyIsReadOnlyAttribute(): void
$errors = $this->analyzeTestFile('/data/IsReadOnly/InvalidPropertyIsReadOnlyAttribute.php');
$this->checkExpectedErrors($errors,[
'Attribute IsReadOnly cannot be used on a method' => 16,
- 'Too many arguments for PhpStaticAnalysis\Attributes\IsReadOnly::__construct - expecting 0 but saw 1' => 9,
- 'Attribute IsReadOnly is not repeatable' => 13,
]);
}
}
diff --git a/tests/MethodAttributeTest.php b/tests/MethodAttributeTest.php
index b23aa6c..46b75d1 100644
--- a/tests/MethodAttributeTest.php
+++ b/tests/MethodAttributeTest.php
@@ -28,7 +28,6 @@ public function testInvalidClassMethodAttribute(): void
$expectedErrors = [
'No @method entry specified in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Method\InvalidClassMethodAttribute' => 9,
- 'Argument 1 of PhpStaticAnalysis\Attributes\Method::__construct expects string, but 0 provided' => 8,
'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,
];
diff --git a/tests/MixinAttributeTest.php b/tests/MixinAttributeTest.php
index f7d4d0c..89f0ad2 100644
--- a/tests/MixinAttributeTest.php
+++ b/tests/MixinAttributeTest.php
@@ -28,7 +28,6 @@ public function testInvalidClassMixinAttribute(): void
$expectedErrors = [
'@mixin annotation used without specifying class in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Mixin\InvalidClassMixinAttribute' => 9,
- 'Argument 1 of PhpStaticAnalysis\Attributes\Mixin::__construct expects string, but 0 provided' => 7,
'Attribute Mixin cannot be used on a method' => 11,
];
diff --git a/tests/ParamAttributeTest.php b/tests/ParamAttributeTest.php
index b8d183b..ad0d6d2 100644
--- a/tests/ParamAttributeTest.php
+++ b/tests/ParamAttributeTest.php
@@ -24,7 +24,6 @@ public function testInvalidMethodParamAttribute(): void
$this->checkExpectedErrors($errors,[
'Badly-formatted @param in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Param\InvalidMethodParamAttribute::getNameLength' => 9,
'Badly-formatted @param in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Param\InvalidMethodParamAttribute::getOtherNameLength' => 15,
- 'Argument 1 of PhpStaticAnalysis\Attributes\Param::__construct expects string, but 0 provided' => 9,
'Misplaced brackets in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Param\InvalidMethodParamAttribute::getAnotherNameLength' => 22,
'Found duplicated @param or prefixed @param tag in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Param\InvalidMethodParamAttribute::countEvenMoreNames' => 30,
'Argument 1 of count cannot be mixed, expecting Countable|array' => 33,
diff --git a/tests/ParamOutAttributeTest.php b/tests/ParamOutAttributeTest.php
index 0f1ac15..24243b0 100644
--- a/tests/ParamOutAttributeTest.php
+++ b/tests/ParamOutAttributeTest.php
@@ -23,7 +23,6 @@ public function testInvalidMethodParamOutAttribute(): void
$expectedErrors = [
'Badly-formatted @param in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\ParamOut\InvalidMethodParamOutAttribute::setName' => 9,
'Badly-formatted @param in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\ParamOut\InvalidMethodParamOutAttribute::setOtherName' => 15,
- 'Argument 1 of PhpStaticAnalysis\Attributes\ParamOut::__construct expects string, but 0 provided' => 9,
'Misplaced brackets in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\ParamOut\InvalidMethodParamOutAttribute::setAnotherName' => 21,
'Attribute ParamOut cannot be used on a property' => 27,
];
diff --git a/tests/PropertyAttributeTest.php b/tests/PropertyAttributeTest.php
index 6a7a776..e6319df 100644
--- a/tests/PropertyAttributeTest.php
+++ b/tests/PropertyAttributeTest.php
@@ -28,7 +28,6 @@ public function testInvalidClassPropertyAttribute(): void
$expectedErrors = [
'Badly-formatted @property in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Property\InvalidClassPropertyAttribute' => 8,
- 'Argument 1 of PhpStaticAnalysis\Attributes\Property::__construct expects string, but 0 provided' => 7,
'Attribute Property cannot be used on a method' => 10,
'Badly-formatted @property in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Property\AnotherInvalidClassPropertyAttribute' => 18,
'Misplaced brackets in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Property\AndAnotherInvalidClassPropertyAttribute' => 23,
diff --git a/tests/PropertyReadAttributeTest.php b/tests/PropertyReadAttributeTest.php
index db3d21a..229bdc2 100644
--- a/tests/PropertyReadAttributeTest.php
+++ b/tests/PropertyReadAttributeTest.php
@@ -28,7 +28,6 @@ public function testInvalidClassPropertyReadAttribute(): void
$expectedErrors = [
'Badly-formatted @property in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\PropertyRead\InvalidClassPropertyReadAttribute' => 9,
- 'Argument 1 of PhpStaticAnalysis\Attributes\PropertyRead::__construct expects string, but 0 provided' => 7,
'Attribute PropertyRead cannot be used on a method' => 11,
'Badly-formatted @property in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\PropertyRead\AnotherInvalidClassPropertyReadAttribute' => 29,
'Misplaced brackets in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\PropertyRead\AndAnotherInvalidClassPropertyReadAttribute' => 34,
diff --git a/tests/PropertyWriteAttributeTest.php b/tests/PropertyWriteAttributeTest.php
index 00bb3c6..7ff00fd 100644
--- a/tests/PropertyWriteAttributeTest.php
+++ b/tests/PropertyWriteAttributeTest.php
@@ -29,7 +29,6 @@ public function testInvalidClassPropertyWriteAttribute(): void
$expectedErrors = [
'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,
- 'Argument 1 of PhpStaticAnalysis\Attributes\PropertyWrite::__construct expects string, but 0 provided' => 7,
'Attribute PropertyWrite cannot be used on a method' => 11,
'Badly-formatted @property in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\PropertyWrite\AnotherInvalidClassPropertyWriteAttribute' => 29,
'Misplaced brackets in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\PropertyWrite\AndAnotherInvalidClassPropertyWriteAttribute' => 34,
diff --git a/tests/PureAttributeTest.php b/tests/PureAttributeTest.php
index 27e298d..45935d9 100644
--- a/tests/PureAttributeTest.php
+++ b/tests/PureAttributeTest.php
@@ -21,7 +21,6 @@ public function testInvalidMethodPureAttribute(): void
$errors = $this->analyzeTestFile('/data/Pure/InvalidMethodPureAttribute.php');
$expectedErrors = [
- 'Attribute Pure is not repeatable' => 15,
'Attribute Pure cannot be used on a property' => 11,
];
diff --git a/tests/ReturnsAttributeTest.php b/tests/ReturnsAttributeTest.php
index acbcb0e..7c1bd0c 100644
--- a/tests/ReturnsAttributeTest.php
+++ b/tests/ReturnsAttributeTest.php
@@ -22,10 +22,7 @@ public function testInvalidMethodReturnsAttribute(): void
{
$errors = $this->analyzeTestFile('/data/Returns/InvalidMethodReturnsAttribute.php');
$this->checkExpectedErrors($errors,[
- 'Argument 1 of PhpStaticAnalysis\Attributes\Returns::__construct expects string, but 0 provided' => 9,
'Found duplicated @return or prefixed @return tag in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Returns\InvalidMethodReturnsAttribute::getOtherName' => 15,
- 'Attribute Returns is not repeatable' => 16,
- 'Too many arguments for PhpStaticAnalysis\Attributes\Returns::__construct - expecting 1 but saw 2' => 22,
'Found duplicated @return or prefixed @return tag in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Returns\InvalidMethodReturnsAttribute::getSomeMoreNames' => 31,
'Misplaced variable in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Returns\InvalidMethodReturnsAttribute::getMoreAndMoreNames' => 37,
'Attribute Returns cannot be used on a property' => 43,
diff --git a/tests/SelfOutAttributeTest.php b/tests/SelfOutAttributeTest.php
index ef9547a..84148d3 100644
--- a/tests/SelfOutAttributeTest.php
+++ b/tests/SelfOutAttributeTest.php
@@ -15,7 +15,6 @@ public function testInvalidMethodSelfOutAttribute(): void
$errors = $this->analyzeTestFile('/data/SelfOut/InvalidMethodSelfOutAttribute.php');
$expectedErrors = [
- 'Attribute SelfOut is not repeatable' => 15,
'Attribute SelfOut cannot be used on a property' => 20,
];
diff --git a/tests/TemplateAttributeTest.php b/tests/TemplateAttributeTest.php
index 4fe4ab0..8c0765f 100644
--- a/tests/TemplateAttributeTest.php
+++ b/tests/TemplateAttributeTest.php
@@ -41,9 +41,7 @@ public function testInvalidMethodTemplateAttribute(): void
$errors = $this->analyzeTestFile('/data/Template/InvalidMethodTemplateAttribute.php');
$this->checkExpectedErrors($errors,[
'Empty @template tag in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Template\InvalidMethodTemplateAttribute::getName' => 11,
- 'Argument 1 of PhpStaticAnalysis\Attributes\Template::__construct expects string, but 0 provided' => 11,
'Empty @template tag in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\Template\InvalidMethodTemplateAttribute::getAnotherName' => 17,
- 'Argument 2 of PhpStaticAnalysis\Attributes\Template::__construct expects null|string, but 0 provided' => 26,
'Attribute Template cannot be used on a property' => 23,
]);
}
diff --git a/tests/TemplateCovariantAttributeTest.php b/tests/TemplateCovariantAttributeTest.php
index 519ec0a..ab91a51 100644
--- a/tests/TemplateCovariantAttributeTest.php
+++ b/tests/TemplateCovariantAttributeTest.php
@@ -29,8 +29,6 @@ public function testInvalidClassTemplateCovariantAttribute(): void
$errors = $this->analyzeTestFile('/data/TemplateCovariant/InvalidClassTemplateCovariantAttribute.php');
$this->checkExpectedErrors($errors,[
'Empty @template-covariant tag in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\TemplateCovariant\InvalidClassTemplateCovariantAttribute' => 10,
- 'Argument 1 of PhpStaticAnalysis\Attributes\TemplateCovariant::__construct expects string, but 0 provided' => 7,
- 'Argument 2 of PhpStaticAnalysis\Attributes\TemplateCovariant::__construct expects null|string, but 0 provided' => 9,
'Attribute TemplateCovariant cannot be used on a property' => 12,
]);
}
diff --git a/tests/TemplateExtendsAttributeTest.php b/tests/TemplateExtendsAttributeTest.php
index 9cce2f8..41ac3eb 100644
--- a/tests/TemplateExtendsAttributeTest.php
+++ b/tests/TemplateExtendsAttributeTest.php
@@ -17,10 +17,8 @@ public function testInvalidClassTemplateExtendsAttribute(): void
$expectedErrors = [
'Extended class cannot be empty in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\TemplateExtends\InvalidClassTemplateExtendsAttributeChild' => 13,
'test\PhpStaticAnalysis\PsalmPlugin\data\TemplateExtends\InvalidClassTemplateExtendsAttributeChild has missing template params when extending test\PhpStaticAnalysis\PsalmPlugin\data\TemplateExtends\InvalidClassTemplateExtendsAttribute, expecting 1' => 14,
- 'Argument 1 of PhpStaticAnalysis\Attributes\TemplateExtends::__construct expects string, but 0 provided' => 13,
'Invalid type \'test\PhpStaticAnalysis\PsalmPlugin\data\TemplateExtends\+5\' in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\TemplateExtends\InvalidClassTemplateExtendsAttributeChild2' => 18,
'test\PhpStaticAnalysis\PsalmPlugin\data\TemplateExtends\InvalidClassTemplateExtendsAttributeChild2 has missing template params when extending test\PhpStaticAnalysis\PsalmPlugin\data\TemplateExtends\InvalidClassTemplateExtendsAttribute, expecting 1' => 19,
- 'Attribute TemplateExtends is not repeatable' => 24,
'Attribute TemplateExtends cannot be used on a property' => 27,
];
diff --git a/tests/TemplateImplementsAttributeTest.php b/tests/TemplateImplementsAttributeTest.php
index be8f5fc..bae65f3 100644
--- a/tests/TemplateImplementsAttributeTest.php
+++ b/tests/TemplateImplementsAttributeTest.php
@@ -17,7 +17,6 @@ public function testInvalidInterfaceTemplateImplementsAttribute(): void
$expectedErrors = [
'Extended class cannot be empty in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\TemplateImplements\InvalidClassTemplateImplementsAttribute' => 13,
'test\PhpStaticAnalysis\PsalmPlugin\data\TemplateImplements\InvalidClassTemplateImplementsAttribute has missing template params when extending test\PhpStaticAnalysis\PsalmPlugin\data\TemplateImplements\InvalidInterfaceTemplateImplementsAttribute, expecting 1' => 14,
- 'Argument 1 of PhpStaticAnalysis\Attributes\TemplateImplements::__construct expects string, but 0 provided' => 13,
'Invalid type \'test\PhpStaticAnalysis\PsalmPlugin\data\TemplateImplements\+5\' in docblock for test\PhpStaticAnalysis\PsalmPlugin\data\TemplateImplements\InvalidClassTemplateImplementsAttribute2' => 18,
'test\PhpStaticAnalysis\PsalmPlugin\data\TemplateImplements\InvalidClassTemplateImplementsAttribute2 has missing template params when extending test\PhpStaticAnalysis\PsalmPlugin\data\TemplateImplements\InvalidInterfaceTemplateImplementsAttribute, expecting 1' => 19,
'Attribute TemplateImplements cannot be used on a property' => 21,
diff --git a/tests/TypeAttributeTest.php b/tests/TypeAttributeTest.php
index c0f8657..eec5ff4 100644
--- a/tests/TypeAttributeTest.php
+++ b/tests/TypeAttributeTest.php
@@ -18,10 +18,7 @@ public function testInvalidPropertyTypeAttribute(): void
$this->checkExpectedErrors($errors,[
'Misplaced variable' => 19,
'Attribute Type cannot be used on a function/method parameter' => 23,
- 'Argument 1 of PhpStaticAnalysis\Attributes\Type::__construct expects string, but 0 provided' => 9,
'Property test\PhpStaticAnalysis\PsalmPlugin\data\Type\InvalidPropertyTypeAttribute::$invalidProperty does not have a declared type - consider string' => 10,
- 'Attribute Type is not repeatable' => 13,
- 'Too many arguments for PhpStaticAnalysis\Attributes\Type::__construct - expecting 1 but saw 2' => 16,
'Property test\PhpStaticAnalysis\PsalmPlugin\data\Type\InvalidPropertyTypeAttribute::$andAnotherinvalidProperty does not have a declared type - consider string' => 20,
]);
}