fix some psalm errors

This commit is contained in:
2022-04-30 01:34:23 +02:00
parent 3f63bc803d
commit dae383dbd9
10 changed files with 36 additions and 11 deletions

View File

@@ -553,8 +553,6 @@ class AccompanyingPeriod implements
* 'now'.
*
* @param mixed $person
*
* @return void
*/
public function closeParticipationFor($person): ?AccompanyingPeriodParticipation
{

View File

@@ -880,7 +880,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
}
/**
* @return Collection|BudgetCharges[]
* @return Collection|Charge[]
*/
public function getBudgetCharges(): Collection
{
@@ -888,7 +888,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI
}
/**
* @return Collection|BudgetResources[]
* @return Collection|Resource[]
*/
public function getBudgetResources(): Collection
{

View File

@@ -181,8 +181,12 @@ final class AccompanyingPeriodTest extends \PHPUnit\Framework\TestCase
$this->assertEquals(1, $participations->count());
$participationL = $period->closeParticipationFor($person);
$this->assertSame($participationL, $participation);
$this->assertTrue($participationL->getEndDate() instanceof DateTimeInterface);
$this->assertNotNull($participationL);
if ($participationL instanceof AccompanyingPeriodParticipation) {
$this->assertSame($participationL, $participation);
$this->assertTrue($participationL->getEndDate() instanceof DateTimeInterface);
}
$participation = $period->getOpenParticipationContainsPerson($person);
$this->assertNull($participation);

View File

@@ -11,10 +11,12 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Validator\Constraints\Relationship;
use Chill\PersonBundle\Entity\Relationships\Relationship;
use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedValueException;
class RelationshipNoDuplicateValidator extends ConstraintValidator
{
@@ -25,14 +27,18 @@ class RelationshipNoDuplicateValidator extends ConstraintValidator
$this->relationshipRepository = $relationshipRepository;
}
public function validate($relationship, Constraint $constraint)
public function validate($value, Constraint $constraint)
{
if (!$constraint instanceof RelationshipNoDuplicate) {
throw new UnexpectedTypeException($constraint, RelationshipNoDuplicate::class);
}
$fromPerson = $relationship->getFromPerson();
$toPerson = $relationship->getToPerson();
if (!$value instanceof Relationship) {
throw new UnexpectedValueException($value, Relationship::class);
}
$fromPerson = $value->getFromPerson();
$toPerson = $value->getToPerson();
$relationships = $this->relationshipRepository->findBy([
'fromPerson' => [$fromPerson, $toPerson],