Skip to content

Commit 0416e8e

Browse files
minor #53073 Set strict parameter of in_array to true where possible (alexandre-daubois)
This PR was merged into the 7.1 branch. Discussion ---------- Set `strict` parameter of `in_array` to true where possible | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT This pull request introduces a comprehensive update where the `in_array` function is now consistently invoked with the `strict` parameter set to `true`. This change is implemented across various components of the framework to enhance type safety and reliability. To me, this update is a step towards more explicit and error-resistant code. Commits ------- 442329a50f Set `strict` parameter of `in_array` to true where possible
2 parents afa665f + bb53c52 commit 0416e8e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Tests/Authorization/TraceableAccessDecisionManagerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function testAccessDecisionManagerCalledByVoter()
197197
->expects($this->any())
198198
->method('vote')
199199
->willReturnCallback(function (TokenInterface $token, $subject, array $attributes) use ($sut, $voter1) {
200-
$vote = \in_array('attr1', $attributes) ? VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_ABSTAIN;
200+
$vote = \in_array('attr1', $attributes, true) ? VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_ABSTAIN;
201201
$sut->addVoterVote($voter1, $attributes, $vote);
202202

203203
return $vote;
@@ -207,7 +207,7 @@ public function testAccessDecisionManagerCalledByVoter()
207207
->expects($this->any())
208208
->method('vote')
209209
->willReturnCallback(function (TokenInterface $token, $subject, array $attributes) use ($sut, $voter2) {
210-
if (\in_array('attr2', $attributes)) {
210+
if (\in_array('attr2', $attributes, true)) {
211211
$vote = null == $subject ? VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED;
212212
} else {
213213
$vote = VoterInterface::ACCESS_ABSTAIN;
@@ -222,7 +222,7 @@ public function testAccessDecisionManagerCalledByVoter()
222222
->expects($this->any())
223223
->method('vote')
224224
->willReturnCallback(function (TokenInterface $token, $subject, array $attributes) use ($sut, $voter3) {
225-
if (\in_array('attr2', $attributes) && $subject) {
225+
if (\in_array('attr2', $attributes, true) && $subject) {
226226
$vote = $sut->decide($token, $attributes) ? VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED;
227227
} else {
228228
$vote = VoterInterface::ACCESS_ABSTAIN;

0 commit comments

Comments
 (0)