diff --git a/.gitignore b/.gitignore index aeec2c4b5..d0a16a46a 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ docs/build/ /.php-cs-fixer.cache /.idea/ +/.psalm/ diff --git a/psalm.xml b/psalm.xml index be17d1d86..40e5d78e8 100644 --- a/psalm.xml +++ b/psalm.xml @@ -6,6 +6,7 @@ xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config tests/app/vendor/vimeo/psalm/config.xsd" errorBaseline="psalm-baseline.xml" + cacheDirectory="./.psalm" > @@ -13,4 +14,15 @@ + + + + + + + + + + + diff --git a/src/Bundle/ChillBudgetBundle/Menu/HouseholdMenuBuilder.php b/src/Bundle/ChillBudgetBundle/Menu/HouseholdMenuBuilder.php index f8033da7d..f9f295e17 100644 --- a/src/Bundle/ChillBudgetBundle/Menu/HouseholdMenuBuilder.php +++ b/src/Bundle/ChillBudgetBundle/Menu/HouseholdMenuBuilder.php @@ -13,6 +13,7 @@ namespace Chill\BudgetBundle\Menu; use Chill\BudgetBundle\Security\Authorization\BudgetElementVoter; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; +use Chill\PersonBundle\Entity\Household\Household; use Knp\Menu\MenuItem; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; diff --git a/src/Bundle/ChillBudgetBundle/Menu/PersonMenuBuilder.php b/src/Bundle/ChillBudgetBundle/Menu/PersonMenuBuilder.php index fdd38ac08..db2f66d6a 100644 --- a/src/Bundle/ChillBudgetBundle/Menu/PersonMenuBuilder.php +++ b/src/Bundle/ChillBudgetBundle/Menu/PersonMenuBuilder.php @@ -13,6 +13,7 @@ namespace Chill\BudgetBundle\Menu; use Chill\BudgetBundle\Security\Authorization\BudgetElementVoter; use Chill\MainBundle\Routing\LocalMenuBuilderInterface; +use Chill\PersonBundle\Entity\Person; use Knp\Menu\MenuItem; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Contracts\Translation\TranslatorInterface; diff --git a/src/Bundle/ChillFamilyMembersBundle/Repository/FamilyMemberRepository.php b/src/Bundle/ChillFamilyMembersBundle/Repository/FamilyMemberRepository.php index 571e94161..db3e2c727 100644 --- a/src/Bundle/ChillFamilyMembersBundle/Repository/FamilyMemberRepository.php +++ b/src/Bundle/ChillFamilyMembersBundle/Repository/FamilyMemberRepository.php @@ -9,9 +9,9 @@ declare(strict_types=1); -namespace Chill\AMLI\FamilyMembersBundle\Repository; +namespace Chill\FamilyMembersBundle\Repository; -use Chill\AMLI\FamilyMembersBundle\Entity\FamilyMember; +use Chill\FamilyMembersBundle\Entity\FamilyMember; use Chill\PersonBundle\Entity\Person; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index b978173d9..2207b224a 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -160,6 +160,8 @@ class EntityWorkflowStep /** * get all the users which are allowed to apply a transition: those added manually, and * those added automatically bu using an access key. + * + * @psalm-suppress DuplicateArrayKey */ public function getAllDestUser(): Collection { diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 8495afa89..e8108bcce 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -553,8 +553,6 @@ class AccompanyingPeriod implements * 'now'. * * @param mixed $person - * - * @return void */ public function closeParticipationFor($person): ?AccompanyingPeriodParticipation { diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 7f2630a1e..3df55d904 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -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 { diff --git a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php index 542144bc2..0fcf414ce 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Entity/AccompanyingPeriodTest.php @@ -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); diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php index 580fc4b48..9c71f442d 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/Relationship/RelationshipNoDuplicateValidator.php @@ -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],