Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 71d7744

Browse filesBrowse files
committed
psalm correction
fabpot use interface
1 parent 419fa3d commit 71d7744
Copy full SHA for 71d7744

14 files changed

+54
-24
lines changed

‎src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DataCollector/SecurityDataCollectorTest.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,4 +464,8 @@ final class DummyVoter implements VoterInterface
464464
public function vote(TokenInterface $token, mixed $subject, array $attributes): int
465465
{
466466
}
467+
468+
public function getVote(TokenInterface $token, mixed $subject, array $attributes): VoterInterface
469+
{
470+
}
467471
}

‎src/Symfony/Component/Security/Core/Authorization/AccessDecision.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/AccessDecision.php
+12-13Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
namespace Symfony\Component\Security\Core\Authorization;
1313

14-
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
15-
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
14+
use Symfony\Component\Security\Core\Authorization\Voter\VoteInterface;
1615
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
1716

1817
/**
@@ -24,8 +23,8 @@
2423
final class AccessDecision
2524
{
2625
/**
27-
* @param int $access One of the VoterInterface constants (ACCESS_GRANTED, ACCESS_ABSTAIN, ACCESS_DENIED)
28-
* @param Vote[] $votes
26+
* @param int $access One of the VoterInterface constants (ACCESS_GRANTED, ACCESS_ABSTAIN, ACCESS_DENIED)
27+
* @param VoteInterface[] $votes
2928
*/
3029
public function __construct(
3130
private readonly int $access,
@@ -60,42 +59,42 @@ public function getMessage(): string
6059
}
6160

6261
/**
63-
* @return Vote[]
62+
* @return VoteInterface[]
6463
*/
6564
public function getVotes(): array
6665
{
6766
return $this->votes;
6867
}
6968

7069
/**
71-
* @return Vote[]
70+
* @return VoteInterface[]
7271
*/
7372
public function getGrantedVotes(): array
7473
{
75-
return $this->getVotesByAccess(Voter::ACCESS_GRANTED);
74+
return $this->getVotesByAccess(VoterInterface::ACCESS_GRANTED);
7675
}
7776

7877
/**
79-
* @return Vote[]
78+
* @return VoteInterface[]
8079
*/
8180
public function getAbstainedVotes(): array
8281
{
83-
return $this->getVotesByAccess(Voter::ACCESS_ABSTAIN);
82+
return $this->getVotesByAccess(VoterInterface::ACCESS_ABSTAIN);
8483
}
8584

8685
/**
87-
* @return Vote[]
86+
* @return VoteInterface[]
8887
*/
8988
public function getDeniedVotes(): array
9089
{
91-
return $this->getVotesByAccess(Voter::ACCESS_DENIED);
90+
return $this->getVotesByAccess(VoterInterface::ACCESS_DENIED);
9291
}
9392

9493
/**
95-
* @return Vote[]
94+
* @return VoteInterface[]
9695
*/
9796
private function getVotesByAccess(int $access): array
9897
{
99-
return array_filter($this->votes, static fn (Vote $vote): bool => $vote->getAccess() === $access);
98+
return array_filter($this->votes, static fn (VoteInterface $vote): bool => $vote->getAccess() === $access);
10099
}
101100
}

‎src/Symfony/Component/Security/Core/Authorization/Strategy/AffirmativeStrategy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/Strategy/AffirmativeStrategy.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Security\Core\Authorization\AccessDecision;
1515
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
16+
use Symfony\Component\Security\Core\Authorization\Voter\VoteInterface;
1617
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
1718

1819
/**
@@ -41,7 +42,7 @@ public function getDecision(\Traversable $votes): AccessDecision
4142
$currentVotes = [];
4243
$deny = 0;
4344

44-
/** @var Vote $vote */
45+
/** @var VoteInterface $vote */
4546
foreach ($votes as $vote) {
4647
$currentVotes[] = $vote;
4748

‎src/Symfony/Component/Security/Core/Authorization/Strategy/ConsensusStrategy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/Strategy/ConsensusStrategy.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Security\Core\Authorization\AccessDecision;
1515
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
16+
use Symfony\Component\Security\Core\Authorization\Voter\VoteInterface;
1617
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
1718

1819
/**
@@ -51,7 +52,7 @@ public function getDecision(\Traversable $votes): AccessDecision
5152
$grant = 0;
5253
$deny = 0;
5354

54-
/** @var Vote $vote */
55+
/** @var VoteInterface $vote */
5556
foreach ($votes as $vote) {
5657
$currentVotes[] = $vote;
5758
if ($vote->isGranted()) {

‎src/Symfony/Component/Security/Core/Authorization/Strategy/PriorityStrategy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/Strategy/PriorityStrategy.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Security\Core\Authorization\AccessDecision;
1515
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
16+
use Symfony\Component\Security\Core\Authorization\Voter\VoteInterface;
1617
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
1718

1819
/**
@@ -41,7 +42,7 @@ public function getDecision(\Traversable $votes): AccessDecision
4142
{
4243
$currentVotes = [];
4344

44-
/** @var Vote $vote */
45+
/** @var VoteInterface $vote */
4546
foreach ($votes as $vote) {
4647
$currentVotes[] = $vote;
4748
if ($vote->isGranted()) {

‎src/Symfony/Component/Security/Core/Authorization/Strategy/ScoringStrategy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/Strategy/ScoringStrategy.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Security\Core\Authorization\AccessDecision;
1515
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
16+
use Symfony\Component\Security\Core\Authorization\Voter\VoteInterface;
1617
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
1718

1819
/**
@@ -40,7 +41,7 @@ public function getDecision(\Traversable $votes): AccessDecision
4041
$currentVotes = [];
4142
$score = 0;
4243

43-
/** @var Vote $vote */
44+
/** @var VoteInterface $vote */
4445
foreach ($votes as $vote) {
4546
$currentVotes[] = $vote;
4647
$score += $vote->getAccess();

‎src/Symfony/Component/Security/Core/Authorization/Strategy/UnanimousStrategy.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/Strategy/UnanimousStrategy.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Security\Core\Authorization\AccessDecision;
1515
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
16+
use Symfony\Component\Security\Core\Authorization\Voter\VoteInterface;
1617
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
1718

1819
/**
@@ -41,7 +42,7 @@ public function getDecision(\Traversable $votes): AccessDecision
4142
$currentVotes = [];
4243
$grant = 0;
4344

44-
/** @var Vote $vote */
45+
/** @var VoteInterface $vote */
4546
foreach ($votes as $vote) {
4647
$currentVotes[] = $vote;
4748

‎src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/TraceableAccessDecisionManager.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function decide(TokenInterface $token, array $attributes, mixed $object =
9393
*/
9494
public function addVoterVote(VoterInterface $voter, array $attributes, VoteInterface|int $vote): void
9595
{
96-
if (!$vote instanceof Vote) {
96+
if (!$vote instanceof VoteInterface) {
9797
$vote = new Vote($vote);
9898
}
9999

‎src/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Authorization/Voter/VoterInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* @author Fabien Potencier <fabien@symfony.com>
2020
*
21-
* method Vote getVote(TokenInterface $token, mixed $subject, array $attributes)
21+
* @method VoteInterface getVote(TokenInterface $token, mixed $subject, array $attributes)
2222
*/
2323
interface VoterInterface
2424
{

‎src/Symfony/Component/Security/Core/Event/VoteEvent.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Event/VoteEvent.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
*/
2626
final class VoteEvent extends Event
2727
{
28+
private VoteInterface $vote;
29+
2830
public function __construct(
2931
private VoterInterface $voter,
3032
private mixed $subject,
3133
private array $attributes,
32-
private Vote|int $vote,
34+
VoteInterface|int $vote,
3335
) {
34-
if (!$vote instanceof Vote) {
35-
$this->vote = new Vote($vote);
36-
}
36+
$this->vote = $vote instanceof VoteInterface ? $vote : new Vote($vote);
3737
}
3838

3939
public function getVoter(): VoterInterface

‎src/Symfony/Component/Security/Core/Test/AccessDecisionStrategyTestCase.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Test/AccessDecisionStrategyTestCase.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\Security\Core\Authorization\Strategy\AccessDecisionStrategyInterface;
1919
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
2020
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
21+
use Symfony\Component\Security\Core\Exception\LogicException;
2122

2223
/**
2324
* Abstract test case for access decision strategies.
@@ -91,6 +92,11 @@ public function vote(TokenInterface $token, $subject, array $attributes): int
9192
{
9293
return $this->vote;
9394
}
95+
96+
public function __call($function, $args)
97+
{
98+
throw new LogicException('This function must not be acceded.');
99+
}
94100
};
95101
}
96102

‎src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Tests/Authorization/AccessDecisionManagerTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ public function vote(TokenInterface $token, $subject, array $attributes): int
354354
{
355355
return $this->vote;
356356
}
357+
358+
public function __call($function, $args)
359+
{
360+
throw new LogicException('This function must not be acceded.');
361+
}
357362
};
358363
}
359364

‎src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/ScoringStrategyTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Tests/Authorization/Strategy/ScoringStrategyTest.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
1212
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
1313
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
14+
use Symfony\Component\Security\Core\Exception\LogicException;
1415

1516
class ScoringStrategyTest extends TestCase
1617
{
@@ -100,6 +101,11 @@ public function vote(TokenInterface $token, $subject, array $attributes): int
100101
{
101102
return $this->vote;
102103
}
104+
105+
public function __call($function, $args)
106+
{
107+
throw new LogicException('This function must not be acceded.');
108+
}
103109
};
104110
}
105111

‎src/Symfony/Component/Security/Core/Tests/Fixtures/DummyVoter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Security/Core/Tests/Fixtures/DummyVoter.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
namespace Symfony\Component\Security\Core\Tests\Fixtures;
1313

1414
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
15+
use Symfony\Component\Security\Core\Authorization\Voter\Vote;
1516
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
1617

1718
final class DummyVoter implements VoterInterface
1819
{
1920
public function vote(TokenInterface $token, $subject, array $attributes): int
2021
{
2122
}
23+
24+
public function getVote(TokenInterface $token, mixed $subject, array $attributes): VoterInterface
25+
{
26+
}
2227
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.