We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/** @@ -141,12 +135,6 @@ */ private function isConsignee(RemoteOrder $order, User $user): bool { - foreach ($user->getEmails() as $email) { - if ($email === $order->getSrcShippingEmail()) { - return true; - } - } - - return false; + return in_array($order->getSrcShippingEmail(), $user->getEmails(), true); } } ----------- end diff ----------- Applied rectors: * Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector
/** * @ORM\Entity * @ORM\Table(name="users") */ class User extends BaseUser { /** * @var ArrayCollection * * @ORM\OneToMany(targetEntity="App\Entity\Email", mappedBy="forUser") */ protected $emails; /** * @return Collection|Email[] */ public function getEmails(): Collection { return $this->emails; }
As you can see, and as pointed out in phpstan/phpstan#2176, Collection cannot be passed to in_array().
Collection
in_array()
Here there are two problems:
Collection::contains()
The text was updated successfully, but these errors were encountered:
I see. In that case, it should be skipped completely, because ForeachToInArrayRector should not handle any kinds of collections.
ForeachToInArrayRector
Could you send failing test (no change is expected)?
Sorry, something went wrong.
Failing test case created!
9dfb666
Merge pull request #1553 from rectorphp/in_collection
b2eb233
[CodeQuality] Skip collections ForeachToInArrayRector [closes #1533]
Updated Rector to commit c51fcbf
1cfe2fe
rectorphp/rector-src@c51fcbf [Core] [DeadCode] Refactor RectifiedAnalyzer and ExprUsedInNextNodeAnalyzer (#1533)
No branches or pull requests
As you can see, and as pointed out in phpstan/phpstan#2176,
Collection
cannot be passed toin_array()
.Here there are two problems:
in_array()
;Collection::contains()
.The text was updated successfully, but these errors were encountered: