Skip to content

Commit

Permalink
Add Constraint stub (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
enumag committed Apr 1, 2021
1 parent 9138d0b commit 4fceec0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Stubs/common/Constraint.stubphp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Symfony\Component\Validator;

use Symfony\Component\Validator\Context\ExecutionContextInterface;

abstract class Constraint
{
/**
* @var array<string, string>
*/
protected static $errorNames = [];
}
37 changes: 37 additions & 0 deletions tests/acceptance/acceptance/Constraint.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@symfony-common
Feature: Constraint

Background:
Given I have the following config
"""
<?xml version="1.0"?>
<psalm errorLevel="1">
<projectFiles>
<directory name="."/>
<ignoreFiles> <directory name="../../vendor"/> </ignoreFiles>
</projectFiles>
<plugins>
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
</plugins>
</psalm>
"""

Scenario: NonInvariantDocblockPropertyType error about $errorNames is not raised
Given I have the following code
"""
<?php
use Symfony\Component\Validator\Constraint;
class CustomConstraint extends Constraint
{
/**
* @var array<string, string>
*/
protected static $errorNames = [
'test' => 'test',
];
}
"""
When I run Psalm
Then I see no errors

0 comments on commit 4fceec0

Please sign in to comment.