Skip to content

Commit

Permalink
Less issue with psalm (#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet authored Apr 17, 2024
1 parent 274ea10 commit d626cf5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 32 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
"symfony/security-bundle": "^5.4 || ^6.2 || ^7.0",
"symfony/twig-bundle": "^5.4 || ^6.2 || ^7.0",
"symfony/var-dumper": "^5.4 || ^6.2 || ^7.0",
"vimeo/psalm": "^5.7",
"weirdan/doctrine-psalm-plugin": "^2.8"
"vimeo/psalm": "^5.7"
},
"conflict": {
"doctrine/doctrine-bundle": "<2.7",
Expand Down
17 changes: 0 additions & 17 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,4 @@
<code>Controller</code>
</UndefinedClass>
</file>
<file src="tests/BaseTest.php">
<ArgumentTypeCoercion>
<code><![CDATA[$value]]></code>
<code><![CDATA[$value]]></code>
</ArgumentTypeCoercion>
</file>
<file src="tests/CoreTest.php">
<InvalidArgument>
<code><![CDATA[ProfileAudit::class]]></code>
<code><![CDATA[UserAudit::class]]></code>
</InvalidArgument>
</file>
<file src="tests/Issue/Issue318Test.php">
<ArgumentTypeCoercion>
<code><![CDATA[$user::class]]></code>
</ArgumentTypeCoercion>
</file>
</files>
1 change: 0 additions & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
<pluginClass class="Psalm\SymfonyPsalmPlugin\Plugin"/>
<pluginClass class="Weirdan\DoctrinePsalmPlugin\Plugin"/>
</plugins>
<issueHandlers>
<!-- Psalm equivalent of PHPStan config `treatPhpDocTypesAsCertain: false` -->
Expand Down
20 changes: 11 additions & 9 deletions src/Collection/AuditedCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public function __construct(
}

/**
* @return true
* @return void
*
* @phpstan-ignore-next-line https://github.com/phpstan/phpstan-doctrine/pull/560
*/
#[\ReturnTypeWillChange]
public function add(mixed $element)
Expand Down Expand Up @@ -293,9 +295,10 @@ public function exists(\Closure $p)
/**
* @return Collection<TKey, T>
*
* @phpstan-param \Closure(T, int|string):bool $p
* @psalm-param \Closure(T=):bool $p
* @psalm-return Collection<TKey, T>
* @phpstan-param \Closure(T, TKey):bool $p
* @phpstan-return Collection<TKey, T>
*
* @psalm-suppress MoreSpecificImplementedParamType https://github.com/doctrine/collections/pull/411
*/
#[\ReturnTypeWillChange]
public function filter(\Closure $p)
Expand Down Expand Up @@ -323,9 +326,7 @@ public function forAll(\Closure $p)
*
* @phpstan-template U
* @phpstan-param \Closure(T):U $func
* @psalm-return Collection<TKey, U>
*
* @psalm-suppress ImplementedParamTypeMismatch,InvalidArgument
* @phpstan-return Collection<TKey, U>
*/
#[\ReturnTypeWillChange]
public function map(\Closure $func)
Expand All @@ -339,7 +340,9 @@ public function map(\Closure $func)
* @return array<Collection<TKey, T>>
*
* @phpstan-param \Closure(TKey, T):bool $p
* @psalm-return array{0: Collection<TKey, T>, 1: Collection<TKey, T>}
* @phpstan-return array{0: Collection<TKey, T>, 1: Collection<TKey, T>}
*
* @psalm-suppress MoreSpecificImplementedParamType https://github.com/doctrine/collections/pull/411
*/
#[\ReturnTypeWillChange]
public function partition(\Closure $p)
Expand Down Expand Up @@ -454,7 +457,6 @@ public function count()
* @return T|null
*
* @phpstan-return T|null
* @psalm-return mixed|null
*/
#[\ReturnTypeWillChange]
public function findFirst(\Closure $p)
Expand Down
4 changes: 1 addition & 3 deletions tests/Fixtures/Issue/Issue308User.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ public function addChild(self $child): void
*/
public function getChildren(): ReadableCollection
{
$activeChildren = $this->children->filter(
return $this->children->filter(
static fn (self $user): bool => $user->isActive()
);

return $activeChildren;
}

public function getParent(): ?self
Expand Down

0 comments on commit d626cf5

Please sign in to comment.