From a563ef077de18e13c1be88a1ca989b92b617477d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 08:03:52 +0000 Subject: [PATCH 1/2] Initial plan From dfb56cc1be199d725e3902585a71820b603a0bff Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Feb 2026 08:08:26 +0000 Subject: [PATCH 2/2] Cache computed rules in Blacklist constructor to avoid repeated enum conversion Co-authored-by: makomweb <1567373+makomweb@users.noreply.github.com> --- src/Blacklist.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Blacklist.php b/src/Blacklist.php index 050446e..19d279a 100644 --- a/src/Blacklist.php +++ b/src/Blacklist.php @@ -27,6 +27,9 @@ 'Service' => [], ]; + /** @var array */ + private array $rules; + /** * Create a new Blacklist instance. * Format: ['FROM_ATTRIBUTE' => ['TO_ATTRIBUTE1', 'TO_ATTRIBUTE2'], ...] @@ -37,6 +40,7 @@ public function __construct(public array $data) { assert(!empty($data)); + $this->rules = $this->buildRules($data); } public function isForbidden(Relation $relation): bool @@ -54,7 +58,7 @@ public function isForbidden(Relation $relation): bool */ private function check(AttributeName $from, AttributeName $to): bool { - foreach ($this->getRules() as $rule) { + foreach ($this->rules as $rule) { if ($rule['from'] === $from) { return in_array($to, $rule['to'], true); } @@ -64,14 +68,16 @@ private function check(AttributeName $from, AttributeName $to): bool } /** - * Get rules from configuration, converting string names to AttributeName enums. + * Build rules from configuration, converting string names to AttributeName enums. + * + * @param array> $data * * @return array */ - private function getRules(): array + private function buildRules(array $data): array { $rules = []; - foreach ($this->data as $fromValue => $toValues) { + foreach ($data as $fromValue => $toValues) { try { $from = AttributeName::from($fromValue); $to = array_map(