mirror of
https://github.com/danog/psalm-plugin-symfony.git
synced 2024-11-26 20:04:58 +01:00
Fix tests and a var annotation (#166)
* Add tests and fix var * Run form tests on ci * Ignore unused errors * Fix
This commit is contained in:
parent
567d5d6e32
commit
e363384dfa
@ -6,4 +6,9 @@
|
||||
<code>string</code>
|
||||
</UnnecessaryVarAnnotation>
|
||||
</file>
|
||||
<file src="src/Test/CodeceptionModule.php">
|
||||
<UnusedPsalmSuppress occurrences="1">
|
||||
<code>NonInvariantDocblockPropertyType</code>
|
||||
</UnusedPsalmSuppress>
|
||||
</file>
|
||||
</files>
|
||||
|
@ -13,7 +13,7 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||
* @psalm-suppress MixedArrayAssignment
|
||||
* @psalm-suppress InvalidArrayOffset
|
||||
*
|
||||
* @psalm-var array<string, mixed>&array{value: ?T, attr: array<array-key, mixed>, string}
|
||||
* @psalm-var array{value: ?T, attr: array<array-key, mixed>}&array<string, mixed>
|
||||
*/
|
||||
public array $vars = [
|
||||
'value' => null,
|
||||
|
@ -19,7 +19,10 @@ use Twig\Loader\FilesystemLoader;
|
||||
*/
|
||||
class CodeceptionModule extends BaseModule
|
||||
{
|
||||
/** @var array<string,string> */
|
||||
/**
|
||||
* @var mixed[]
|
||||
* @psalm-suppress NonInvariantDocblockPropertyType
|
||||
*/
|
||||
protected $config = [
|
||||
'default_dir' => 'tests/_run/',
|
||||
];
|
||||
|
@ -13,6 +13,9 @@ Feature: AbstractController
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -16,6 +16,9 @@ Feature: Annotation class
|
||||
<containerXml>../../tests/acceptance/container.xml</containerXml>
|
||||
</pluginClass>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -14,6 +14,9 @@ Feature: AuthenticatorInterface
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -14,6 +14,9 @@ Feature: CacheInterface
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedClosureParam errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -13,6 +13,9 @@ Feature: ConsoleArgument
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -13,6 +13,10 @@ Feature: ConsoleOption
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedParam errorLevel="info"/>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -13,6 +13,9 @@ Feature: ConstraintValidator
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -16,6 +16,9 @@ Feature: ContainerDependency
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
@ -33,7 +36,7 @@ Feature: ContainerDependency
|
||||
"""
|
||||
When I run Psalm
|
||||
Then I see these errors
|
||||
| Type | Message |
|
||||
| Type | Message |
|
||||
| ContainerDependency | Container must not inject into services as dependency! |
|
||||
And I see no other errors
|
||||
|
||||
|
@ -15,6 +15,9 @@ Feature: Container service
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -17,6 +17,9 @@ Feature: Container XML config
|
||||
<containerXml>../../tests/acceptance/container.xml</containerXml>
|
||||
</pluginClass>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -15,6 +15,9 @@ Feature: Denormalizer interface
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -14,6 +14,9 @@ Feature: Doctrine QueryBuilder
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -14,6 +14,9 @@ Feature: Messenger Envelope
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -14,6 +14,9 @@ Feature: Header get
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedFunctionCall errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -13,6 +13,10 @@ Feature: InputBag get return type
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedFunctionCall errorLevel="info"/>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -13,6 +13,9 @@ Feature: LockableTrait
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -17,6 +17,9 @@ Feature: Naming conventions
|
||||
<containerXml>../../tests/acceptance/container.xml</containerXml>
|
||||
</pluginClass>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -13,6 +13,10 @@ Feature: PropertyAccessorInterface
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
<UnusedFunctionCall errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -14,6 +14,10 @@ Feature: PropertyPathInterface
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedParam errorLevel="info"/>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -14,13 +14,13 @@ Feature: RepositoryStringShortcut
|
||||
<ignoreFiles> <directory name="../../vendor"/> </ignoreFiles>
|
||||
</projectFiles>
|
||||
|
||||
<issueHandlers>
|
||||
<UndefinedClass errorLevel="info" />
|
||||
</issueHandlers>
|
||||
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
<UndefinedClass errorLevel="info" />
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -15,6 +15,9 @@ Feature: Request getContent
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedFunctionCall errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -16,6 +16,9 @@ Feature: Annotation class
|
||||
<containerXml>../../tests/acceptance/container.xml</containerXml>
|
||||
</pluginClass>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -14,6 +14,9 @@ Feature: RouteCollection
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -15,6 +15,9 @@ Feature: Serializer interface
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -16,6 +16,9 @@ Feature: Service Subscriber
|
||||
<containerXml>../../tests/acceptance/container.xml</containerXml>
|
||||
</pluginClass>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -13,6 +13,9 @@ Feature: Tainting
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -10,15 +10,16 @@ Feature: Test Container service
|
||||
<directory name="."/>
|
||||
</projectFiles>
|
||||
|
||||
<issueHandlers>
|
||||
<PropertyNotSetInConstructor errorLevel="info" />
|
||||
</issueHandlers>
|
||||
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin">
|
||||
<containerXml>../../tests/acceptance/container.xml</containerXml>
|
||||
</pluginClass>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<PropertyNotSetInConstructor errorLevel="info" />
|
||||
<UnusedFunctionCall errorLevel="info"/>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
|
||||
|
@ -21,6 +21,9 @@ Feature: Twig tainting with analyzer
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin" />
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -21,6 +21,9 @@ Feature: Twig tainting with cached templates
|
||||
<twigCachePath>/cache/twig</twigCachePath>
|
||||
</pluginClass>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -14,6 +14,9 @@ Feature: Voter abstract class
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
And I have the following code preamble
|
||||
|
@ -1,4 +1,4 @@
|
||||
@symfony-form
|
||||
@symfony-common
|
||||
Feature: FormType templates
|
||||
|
||||
Background:
|
||||
@ -14,6 +14,9 @@ Feature: FormType templates
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
Scenario: Assert FormType is using nullable template value in methods
|
||||
|
@ -1,4 +1,4 @@
|
||||
@symfony-form
|
||||
@symfony-5
|
||||
Feature: FormType templates
|
||||
|
||||
Background:
|
||||
@ -14,6 +14,9 @@ Feature: FormType templates
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
Scenario: FormExtension::getExtendedTypes must return iterables of FormTypeInterface
|
||||
|
@ -1,4 +1,4 @@
|
||||
@symfony-form
|
||||
@symfony-4, @symfony-5
|
||||
Feature: Form test
|
||||
|
||||
Background:
|
||||
@ -14,6 +14,9 @@ Feature: Form test
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
Scenario: Assert that Form::getData() will return nullable type (empty_data failure)
|
||||
|
@ -1,5 +1,5 @@
|
||||
@symfony-form
|
||||
Feature: Form events
|
||||
@symfony-common
|
||||
Feature: Form builder
|
||||
|
||||
Background:
|
||||
Given I have the following config
|
||||
@ -14,6 +14,9 @@ Feature: Form events
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
Scenario: Depending of typehinted form event, psalm will know type of data attached
|
||||
|
@ -1,5 +1,5 @@
|
||||
@symfony-form
|
||||
Feature: Form events
|
||||
@symfony-common
|
||||
Feature: Form config builder
|
||||
|
||||
Background:
|
||||
Given I have the following config
|
||||
@ -14,6 +14,9 @@ Feature: Form events
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
Scenario: Depending of typehinted form event, psalm will know type of data attached
|
||||
|
@ -1,5 +1,5 @@
|
||||
@symfony-form
|
||||
Feature: Form events
|
||||
@symfony-common
|
||||
Feature: Form config
|
||||
|
||||
Background:
|
||||
Given I have the following config
|
||||
@ -14,6 +14,9 @@ Feature: Form events
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
Scenario: FormConfigInterface::getData() will return ?T
|
||||
|
@ -1,5 +1,5 @@
|
||||
@symfony-form
|
||||
Feature: Form test
|
||||
@symfony-common
|
||||
Feature: Form factory
|
||||
|
||||
Background:
|
||||
Given I have the following config
|
||||
@ -14,6 +14,9 @@ Feature: Form test
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
Scenario: Test factory methods
|
||||
|
@ -1,5 +1,5 @@
|
||||
@symfony-form
|
||||
Feature: Form events
|
||||
@symfony-common
|
||||
Feature: Form interface
|
||||
|
||||
Background:
|
||||
Given I have the following config
|
||||
@ -14,6 +14,9 @@ Feature: Form events
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
Scenario: FormInterface test
|
||||
|
@ -1,5 +1,5 @@
|
||||
@symfony-form
|
||||
Feature: Form events
|
||||
@symfony-common
|
||||
Feature: Form view
|
||||
|
||||
Background:
|
||||
Given I have the following config
|
||||
@ -14,6 +14,9 @@ Feature: Form events
|
||||
<plugins>
|
||||
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
|
||||
</plugins>
|
||||
<issueHandlers>
|
||||
<UnusedVariable errorLevel="info"/>
|
||||
</issueHandlers>
|
||||
</psalm>
|
||||
"""
|
||||
Scenario: FormView test
|
||||
@ -38,12 +41,16 @@ Feature: Form events
|
||||
$children = $view->children;
|
||||
/** @psalm-trace $children */
|
||||
|
||||
|
||||
$viewData = $view->vars['value'];
|
||||
/** @psalm-trace $viewData */
|
||||
|
||||
// assert no errors
|
||||
$view->vars['random'] = new \stdClass();
|
||||
|
||||
$attr = $view->vars['attr'];
|
||||
/** @psalm-trace $attr */
|
||||
$view->vars['attr']['placeholder'] = 'test';
|
||||
$savedValue = $view->vars['attr']['placeholder'];
|
||||
}
|
||||
}
|
||||
"""
|
||||
@ -51,7 +58,8 @@ Feature: Form events
|
||||
Then I see these errors
|
||||
| Type | Message |
|
||||
| Trace | $parentView: Symfony\Component\Form\FormView\|null |
|
||||
| Trace | $children: list<Symfony\Component\Form\FormView> |
|
||||
| Trace | $children: array<string, Symfony\Component\Form\FormView> |
|
||||
| Trace | $viewData: User\|null |
|
||||
| Trace | $attr: array<array-key, mixed> |
|
||||
And I see no other errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user